Download the PHP package gobtcpay/php-merchant-sdk without Composer

On this page you can find all versions of the php package gobtcpay/php-merchant-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-merchant-sdk

gobtcpay/php-merchant-sdk

CI Packagist Version

PHP client for the GoBTC Pay API — accept Bitcoin payments and track them until they settle on-chain. Two clients share one toolkit:

Both share webhook verification and payment polling helpers.

Requirements

Installation

guzzlehttp/guzzle is a suggestion, not a hard dependency: any PSR-18 client works. With Guzzle installed you don't need to wire anything up.

⚠️ The POS apiKey and the server sk_live_… key are secrets. Keep them server-side or on a controlled POS device. Never ship them to a browser.

Quick start

POS terminal (GoBTCPay)

Server-side shop (GoBTCPayServer)

Bring your own HTTP client

Any PSR-18 client + PSR-17 factories work. Pass them explicitly to skip auto-discovery (or to reuse a configured client):

Configuration

GoBTCPay (POS)

Option Required Default Description
apiKey yes — Per-terminal secret used to sign every request.
posTerminalId no — Default terminal for createPayment.
baseUrl no https://api.gobtcpay.com/public/api/v1.1 Override for staging/dev environments.
timeoutMs no 30000 Per-request timeout.
httpClient no auto-discovered Guzzle Your PSR-18 client.
requestFactory no auto-discovered Guzzle/Nyholm Your PSR-17 request factory.
streamFactory no auto-discovered Guzzle/Nyholm Your PSR-17 stream factory.

GoBTCPayServer

Option Required Default Description
apiKey yes — Merchant secret key (sk_live_…). pk_live_… rejected.
baseUrl no https://api.gobtcpay.com/public/api/v1.2 Override for staging/dev environments.
timeoutMs no 30000 Per-request timeout.
maxRetries no 2 Retries after the first attempt (network / 429 / 5xx).
onEvent no — callable(array $event) called once per attempt.
httpClient / requestFactory / streamFactory no auto-discovered Same as above.

Methods

GoBTCPay

GoBTCPayServer

listPayments() is a generator that pages transparently, newest first:

Auto-polling

watchPayment() returns a PaymentPoller. Because PHP request handlers are synchronous, poll() is a blocking loop: it calls getPayment on an interval until the payment reaches one of the statuses it stops at (paid / cleared / expired / canceled / failed). The interval defaults to and is clamped to a minimum of 3 seconds.

Options (array keys): paymentId (required), intervalMs, timeoutMs, immediate (default true), until (list of PaymentStatus), stopOnError.

paid vs cleared: paid means the funds are confirmed on-chain — the success state for external wallet payments. To stop as soon as that happens, pass 'until' => [PaymentStatus::Paid], or react to onPaid while polling continues.

Stopping is not the same as deciding. The default stop set is "no longer worth polling", not "nothing can change". expired in particular is not terminal on the server: the window closing does not close the payment, and funds arriving within the grace period still move it to paid afterwards — so cancelling an order on expired can strand a payment that later succeeds. When your decision is irreversible, read $payment->paidAt (settlement time, null until the payment settles) and $payment->transactions rather than PaymentStatus::isFinal().

Webhooks

Register a webhook URL in the merchant dashboard to receive payment.status.updated events. The handler verifies the X-GoBTCPay-Signature header (t={timestamp},v1={hmac_hex}), enforces a replay window, and de-duplicates on eventId.

Guard on hasPaymentData(). A test delivery (see below) arrives correctly signed, through the same listener, with no payment behind it — $event->test is true and $event->data is empty. Calling payment() on one throws a GoBTCPayException; answering 2xx anyway is the right behaviour, and it is what tells the sender the endpoint works.

handle() returns the parsed WebhookEvent, or null if it was a duplicate. Use constructEvent() to only verify + parse without dispatching. Always feed the raw request body — do not decode and re-encode it, or the signature will not match.

Inspecting and testing endpoints

listWebhooks() returns the endpoints configured for the merchant, and testWebhook() asks the platform to send a test delivery to one of them:

The test delivery is a normal signed delivery of type payment.status.updated carrying test: true and no payment data, so your existing handler receives it — guard with hasPaymentData() as shown above and answer 2xx.

Three things worth knowing before you build a "test my webhook" button on this:

Plain PHP

Laravel

Symfony

Error handling

Every error extends GoBTCPay\PosApiSdk\Exception\GoBTCPayException:

Exception When
ApiException Any API error envelope / non-2xx (->httpStatus, ->body, ->requestId, ->type()). Base for the ones below.
AuthException 401 / 403 — key missing, malformed, revoked, not permitted.
ValidationException 400 / 402 — request rejected; retrying unchanged won't help.
NotFoundException 404 — no such payment or webhook endpoint.
RateLimitException 429 — too many requests (->retryAfterMs).
ServerException 5xx — the API failed; safe to retry idempotent calls.
NetworkException No response: connection / DNS / TLS / timeout (->isTimeout).
WebhookSignatureException A webhook signature failed verification.

The server client retries network failures, 429 and 5xx automatically (maxRetries, default 2) with exponential backoff + jitter. Reads and idempotent create calls (those with an externalId) are retried; a create without an externalId is not, so a retry can't double-charge. The POS client does not retry — a human at the terminal sees the failure and taps again.

Development

Docker

A Dockerfile is included so that all checks run in an identical environment locally and in CI:

CI builds this image per pipeline and runs lint, phpstan, and test jobs against it.

Testing

Unit tests — pure logic, no network. They gate every MR and run in CI: request signing (HMAC cross-checked against hash_hmac), the envelope transport (retries, typed exceptions), webhook verification (signature / replay window / de-dup), and the poller lifecycle.

Integration tests — exercise the SDK end-to-end against a live POS API on the test contour. Opt-in and self-skipping unless credentials are present:

Use test-contour credentials only — never a production key.

Versioning

The API version is pinned inside each client (POS v1.1, server v1.2), exported as GoBTCPay::API_VERSION / GoBTCPayServer::SERVER_API_VERSION — you don't put it in a URL. Need a different version or environment? Override baseUrl.

Publishing

How it works

  1. A merge into main triggers the lint, phpstan, and test GitHub Actions jobs.
  2. If they pass, the release job runs semantic-release, which reads the Conventional Commits since the last release: fix: bumps a patch version, feat: bumps minor, a BREAKING CHANGE: footer bumps major. Anything else (docs:, chore:, ci:, …) does not trigger a release.
  3. On a release, semantic-release updates CHANGELOG.md, bumps SDK_VERSION in src/GoBTCPay.php / src/GoBTCPayServer.php, commits chore(release): x.y.z [skip ci], tags it, and creates a GitHub release.
  4. That push fires a GitHub webhook (Settings → Webhooks, configured on this repo) that pings https://packagist.org/api/github. Packagist re-reads the tag from GitHub and publishes it as a new version — no manual "Update" click, no separate publish step.

Distribution is through the public Packagist package gobtcpay/php-merchant-sdk.

Giving this to a merchant

Nothing special — it's a public Composer package like any other. Point them at this repo or the Packagist page; they run composer require gobtcpay/php-merchant-sdk in their own project and follow Quick start. No token, no invite, no access request. Their apiKey / sk_live_… credentials are issued separately and are unrelated to installing the package.

Exception — WordPress/WooCommerce/Shopify plugins: those merchants typically don't run Composer at all, and bundling this SDK's dependencies (Guzzle, PSR interfaces) as-is risks class name collisions with other plugins on the same site. A plugin that embeds this SDK should vendor it at build time with a namespace-prefixing tool (php-scoper or Strauss) and ship the prefixed code inside the plugin's own zip — the merchant never touches Composer or this package directly.

По-русски **Как это работает.** 1. Мерж в `main` запускает джобы `lint`, `phpstan`, `test` в GitHub Actions. 2. Если они прошли — джоба `release` запускает [semantic-release](https://semantic-release.gitbook.io/), которая читает [Conventional Commits](https://www.conventionalcommits.org/) с прошлого релиза: `fix:` поднимает patch-версию, `feat:` — minor, футер `BREAKING CHANGE:` — major. Остальное (`docs:`, `chore:`, `ci:` и т.п.) релиз не создаёт. 3. При релизе semantic-release обновляет `CHANGELOG.md`, поднимает `SDK_VERSION` в `src/GoBTCPay.php` / `src/GoBTCPayServer.php`, коммитит `chore(release): x.y.z [skip ci]`, ставит тег и создаёт GitHub release. 4. Этот пуш триггерит GitHub webhook (настроен в **Settings → Webhooks** этого репозитория), который стучится в `https://packagist.org/api/github`. Packagist сам подтягивает новый тег с GitHub и публикует версию — без ручного нажатия Update, без отдельного шага публикации. Дистрибуция — через публичный [Packagist](https://packagist.org/), пакет `gobtcpay/php-merchant-sdk`. **Как передать этот пакет мерчанту.** Ничего особенного делать не нужно — это обычный публичный Composer-пакет. Дайте ссылку на этот репозиторий или на [страницу пакета на Packagist](https://packagist.org/packages/gobtcpay/php-merchant-sdk); у себя в проекте мерчант просто выполняет `composer require gobtcpay/php-merchant-sdk` и дальше следует разделам [Installation](#installation) / [Quick start](#quick-start). Токен, приглашение или согласование доступа не требуются. Ключи `apiKey` / `sk_live_…` выдаются отдельно и никак не связаны с установкой пакета. **Исключение — плагины для WordPress/WooCommerce/Shopify.** Такие мерчанты обычно вообще не используют Composer, а прямое встраивание зависимостей SDK (Guzzle, PSR-интерфейсы) рискует конфликтом имён классов с другими плагинами на том же сайте. Плагин, встраивающий этот SDK, должен вендорить его на этапе сборки инструментом с префиксацией неймспейсов ([php-scoper](https://github.com/humbug/php-scoper) или [Strauss](https://github.com/BrianHenryIE/strauss)) и поставлять уже префиксированный код внутри zip-архива плагина — мерчант напрямую с Composer или этим пакетом не взаимодействует.

License

MIT — see LICENSE. You may freely use, copy, modify, merge, publish, distribute, sublicense, and sell the software, including in closed-source and commercial products. Keep the copyright notice and license text in copies. Provided "as is", without warranty.


All versions of php-merchant-sdk with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gobtcpay/php-merchant-sdk contains the following files

Loading the files please wait ...