Search by

blupay / sdk-php

blupay-dev

Server-side BluPay REST API client

v0.1.1 2026-11-27 14:40 UTC

This package is auto-updated.

Last update: 2026-11-29 11:44:33 UTC


README

Version 0.1.1. Requires PHP 8.1+ with cURL and Composer 2. Uses BluPay's public v1 API at https://blupay.me/api.

BluPay website

Install

Install the tagged release from GitHub:

composer config repositories.blupay-php vcs https://github.com/blupay-dev/blupay-php.git
composer require 'blupay/sdk-php:0.1.1'

With the 0.1.1 source directory unpacked alongside your project:

composer config repositories.blupay-php path ./blupay-php && composer require 'blupay/sdk-php:@dev'

Distribution and registry status are listed in the BluPay integration docs.

Create a test invoice

Configure BLUPAY_API_KEY in the server environment using a key for a Sandbox shop with invoices:write and invoices:read. Persist a distinct SAVED_ATTEMPT_KEY with the order and request body before the first call. Use an enabled quote currency.

From the SDK checkout with its dependencies installed:

php examples/invoice.php 49.00 USD order-1024 "$SAVED_ATTEMPT_KEY"

The command prints the invoice link and hosted payment URL. Save the link with the order. A merchant-hosted page reads the checkout from its own authenticated backend, posts a returned currency-network ID, and renders the exact instructions returned by BluPay.

Methods

createInvoice, getInvoice, getCheckout, selectCurrency, getReceipt, Webhook::verify

Operation API path Permission
Create invoice POST /v1/invoices/ invoices:write
Read invoice GET /v1/invoices/{link}/ invoices:read
Read checkout GET /v1/invoices/{link}/checkout/ invoices:read
Select asset and network POST /v1/invoices/{link}/checkout/select-currency/ invoices:write
Read receipt GET /v1/invoices/{link}/received/ invoices:read

All amounts are handled as decimal strings. The SDK unwraps the success envelope and exposes the HTTP status and request ID on API errors. Defaults to 10 seconds (timeoutMs). Supply API keys from server configuration and keep them out of client bundles and logs.

Reconcile and confirm

  • On a timed-out invoice creation, use the same saved attempt key and identical body. A 409 can mean the first request is still in progress or the key was reused with a different body.
  • On selection timeout or 409, read the checkout again to reconcile its current quote before retrying. Use paymentInstructions.amount and handle a missing instruction by checking checkout state.
  • The browser return is a status view. Look up the invoice on your server and compare stored link, order ID, decimal amount, currency and environment. Fulfill a production order once after authoritative Paid.
  • For webhooks pass the exact raw request body, X-BluPay-Timestamp, X-BluPay-Signature and X-BluPay-Event-Id to the verifier. It authenticates HMAC-SHA256 and a five-minute timestamp window. Persist events in a durable inbox keyed by event ID and make order fulfillment idempotent. A verification result is an authentication check.
  • Use the receipt to reconcile the confirmed received amount and any overpayment separately.

Tests

composer install && composer test

Run the tests against the included isolated fixture. The contract suite uses loopback endpoints and fixture credentials. For version changes compare routes, scopes, envelopes and signatures with the API reference, then exercise a Sandbox shop and record its outcomes before a release.

See CHANGELOG.md for compatibility changes.