Download the PHP package surepay-one/sdk without Composer
On this page you can find all versions of the php package surepay-one/sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download surepay-one/sdk
More information about surepay-one/sdk
Files in surepay-one/sdk
Package sdk
Short Description Official PHP SDK for the SurePay Payment Gateway API
License MIT
Informations about the package sdk
surepay-php-sdk
Official PHP client library for the SurePay Merchant API.
Requirements
- PHP 8.1+
- ext-curl
- ext-json
- Zero non-stdlib dependencies
Install
Quick start
Configuration
| Option | Default | Description |
|---|---|---|
baseUrl(string) |
https://api.surepay.one/merchant/v1 |
Override base URL for local dev or staging |
timeout(int) |
30 |
HTTP request timeout in seconds |
maxRetries(int) |
3 |
Retry attempts on 5xx and network errors |
Authentication
Every request requires an API key sent as an X-API-Key header. When apiSecret is provided to builder(), every outgoing request is automatically signed with HMAC-SHA256 — the X-Signature and X-Timestamp headers are attached with no extra code needed.
API reference
Balance
$client->balance->get()
Get current wallet balance. Requires: balance:read scope.
Deposits
$client->deposits->list(params)
Paginated list of deposit (thu hộ) orders. Requires: deposits:read scope.
$client->deposits->create(req)
Create a new deposit order. Returns a checkoutUrl (redirect) and qrCode (VietQR). Requires: deposits:write scope.
Response fields:
| Field | Type | Description |
|---|---|---|
id |
string | SurePay transaction UUID |
requestId |
string | Your order ID |
amount |
int | Amount in VND |
status |
string | pending, processing, success, failed, expired, cancelled |
checkoutUrl |
string | Redirect URL for payer |
qrCode |
string | VietQR data string |
createdAt |
string | ISO 8601 timestamp |
updatedAt |
string | ISO 8601 timestamp |
$client->deposits->get(id)
Fetch a single deposit order by UUID. Requires: deposits:read scope.
Payouts
$client->payouts->list(params)
Paginated list of payout (chi hộ) orders. Requires: payouts:read scope.
$client->payouts->create(req)
Initiate a payout bank transfer. Funds are deducted from your wallet immediately on success. Requires: payouts:write scope.
Payouts are irreversible once status moves past
pending. Verify bank details with$client->bankInquiry->verify()first.
$client->payouts->get(id)
Fetch a single payout by UUID. Requires: payouts:read scope.
Bank Inquiry
$client->bankInquiry->verify(req)
Look up the account holder name for a bank account. Call this before creating a payout to confirm the recipient. Requires: payouts:read scope.
Idempotency
Pass an idempotency key as the second argument to any create() method. The key is forwarded as an Idempotency-Key header — safe to retry on network errors without risk of duplicate transactions.
Webhook verification
Every inbound webhook event from SurePay is HMAC-signed. Pass the raw request body string (before any JSON parsing) to $client->webhooks->verify():
Or pass the X-Surepay-Signature header value explicitly:
Error handling
Error codes:
| HTTP | getErrorCode() |
Meaning |
|---|---|---|
| 400 | validation_error |
Invalid request body or parameters |
| 401 | unauthorized |
Missing or invalid API key |
| 401 | signature_invalid |
HMAC signature failed or timestamp > 5 min |
| 403 | permission_denied |
API key lacks required scope |
| 403 | ip_not_allowed |
Request IP not in allowlist |
| 404 | not_found |
Resource not found |
| 409 | duplicate_request |
Idempotency key conflict |
| 422 | insufficient_balance |
Top up wallet first |
| 422 | invalid_state_transition |
Operation not allowed for current status |
| 429 | rate_limit_exceeded |
Slow down — back off and retry |
| 500 | internal_error |
Server error |
HMAC signing
When apiSecret is set, all requests are signed automatically. The signing algorithm for manual use:
Attach as headers: X-Signature: <signature> and X-Timestamp: <unix_timestamp>.
Signatures expire after 300 seconds — generate per-request, never cache or reuse.
License
MIT
All versions of sdk with dependencies
ext-curl Version *
ext-json Version *