Download the PHP package wpzinc/airwallex-php without Composer
On this page you can find all versions of the php package wpzinc/airwallex-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wpzinc/airwallex-php
More information about wpzinc/airwallex-php
Files in wpzinc/airwallex-php
Package airwallex-php
Short Description Unofficial PHP SDK for the Airwallex API
License MIT
Homepage https://github.com/wpzinc/airwallex-php
Informations about the package airwallex-php
Airwallex PHP SDK
An unofficial PHP library for the Airwallex API, modelled on Stripe's PHP SDK.
- Covers the full Airwallex API: Payments, Billing, Checkout, Payouts (incl. batch transfers and payers), Spend, Transactional FX, Issuing, Embedded Finance, Lending, Finance, Reconciliation, Accounting, Risk and the sandbox Simulation endpoints (460+ endpoints, see docs/SERVICES.md)
- Handles authentication: exchanges your client ID and API key for an access token, caches it and refreshes it when it expires
- Adds
request_ididempotency keys automatically on the endpoints that take them - Retries connection errors,
429s and5xxs with backoff (POSTs are only retried when idempotent) - Typed exceptions, auto-pagination for both of Airwallex's pagination styles, and webhook signature verification
- No dependencies beyond
ext-curlandext-json. Bring your own HTTP client or token cache if you want
This package is not affiliated with or endorsed by Airwallex. "Airwallex" is a trademark of Airwallex Pty Ltd, used here only to describe API compatibility.
Requirements
PHP 8.2 or later.
Installation
Getting started
Create an API key in the Airwallex web app under Developer > API keys.
Services are properties on the client. Resources from the core payments and treasury APIs live at the top level. Other products are grouped by namespace, as in Stripe's SDK:
Every method takes path parameters first, then $params (query string for GET, JSON body otherwise) and $opts (request options). See docs/SERVICES.md for the full list.
Billing (subscriptions)
Field names follow the Airwallex API reference. The SDK passes $params through unchanged, so check the docs for each endpoint's fields.
Pagination
List methods return a Collection. Iterate the current page, or use autoPagingIterator() to walk every page lazily. Both of Airwallex's pagination styles are handled: page_num with has_more, and the page cursor with page_after / page_before.
Endpoints that return a bare JSON array, such as balances->current(), also come back as a Collection.
Request options
Idempotency
Airwallex uses a request_id body field as its idempotency key. The SDK adds a random UUID on the endpoints that accept one, and reuses it when it retries. Pass your own to make retries across processes safe:
Airwallex doesn't replay a reused request_id. It rejects it with duplicate_request, which the SDK throws as IdempotencyException. If you get one after a timeout or retry, the original request almost certainly succeeded, so look the resource up (e.g. by merchant_order_id) rather than creating it again.
Set 'auto_request_id' => false in the config to turn this off.
Errors
API errors throw a subclass of WPZinc\Airwallex\Exception\ApiErrorException:
| Exception | Status |
|---|---|
InvalidRequestException |
400 |
AuthenticationException |
401 |
PermissionException |
403, or 401 "Insufficient permissions" (scoped key missing a permission) |
NotFoundException |
404 |
IdempotencyException |
400 duplicate_request (extends InvalidRequestException) |
ConflictException |
409 |
RateLimitException |
429 |
ServerException |
5xx |
UnknownApiErrorException |
other |
Network failures throw ApiConnectionException. Every SDK exception implements ExceptionInterface.
Webhooks
Airwallex signs each delivery with HMAC-SHA256 over the x-timestamp header followed by the raw body. Verify it before trusting the event:
Webhook::constructEventFromHeaders($payload, $headers, $secret) reads the headers from an array instead (e.g. getallheaders() or a PSR-7 request). Timestamps older than 5 minutes are rejected; pass a different tolerance in seconds, or null to skip the check.
Manage webhook endpoints with $airwallex->webhooks.
Files
Uploads go to Airwallex's separate files host:
Configuration
| Option | Default | Description |
|---|---|---|
client_id, api_key |
Your credentials | |
access_token |
Use an existing bearer token (e.g. from the Partner API OAuth flow) instead of logging in | |
environment |
production |
production or sandbox |
api_version |
AirwallexClient::API_VERSION |
Sent as x-api-version. Set to null to use your account's default |
login_as |
x-login-as account ID, for scoped keys linked to several accounts |
|
on_behalf_of |
Default x-on-behalf-of connected account ID |
|
max_network_retries |
2 |
Retries for connection errors, 429 and 5xx |
timeout |
80 |
Request timeout in seconds |
auto_request_id |
true |
Add request_id automatically where needed |
http_client |
CurlClient |
Any HttpClient\ClientInterface implementation |
token_store |
InMemoryTokenStore |
Any Auth\TokenStoreInterface implementation |
base_url, files_base_url |
Override the API hosts |
Caching access tokens
Access tokens last 30 minutes. The default store only keeps them for the current PHP process, so a web app would otherwise log in on every request. Implement TokenStoreInterface against your cache to share tokens:
Custom HTTP client
Implement WPZinc\Airwallex\HttpClient\ClientInterface (one request() method) to send requests through Guzzle, Laravel's HTTP client, or a mock in your tests.
Endpoints the SDK doesn't wrap yet
Development
Sandbox tests
tests/Sandbox runs real requests against the Airwallex sandbox: payments, billing checkout, pagination, webhooks, file uploads and errors. Create a scoped sandbox API key, then add a .env (git-ignored):
The default composer test only runs the offline unit suite.
The service classes, resource classes and codegen/README.md.
Roadmap
- Laravel package: service provider, config, cache-backed token store, webhook route and middleware
- A Cashier-style billing package for Laravel on top of Airwallex Billing
License
MIT
All versions of airwallex-php with dependencies
ext-curl Version *
ext-json Version *