1. Go to this page and download the library: Download wpzinc/airwallex-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
wpzinc / airwallex-php example snippets
use WPZinc\Airwallex\AirwallexClient;
$airwallex = new AirwallexClient([
'client_id' => getenv('AIRWALLEX_CLIENT_ID'),
'api_key' => getenv('AIRWALLEX_API_KEY'),
'environment' => 'sandbox', // or 'production' (the default)
]);
$intent = $airwallex->paymentIntents->create([
'amount' => 49.99,
'currency' => 'SGD',
'merchant_order_id' => 'order_1001',
]);
echo $intent->id; // property access
echo $intent['client_secret']; // or array access
echo $intent->latest_payment_attempt?->status; // nested objects
$page = $airwallex->paymentIntents->all(['status' => 'SUCCEEDED', 'page_size' => 100]);
foreach ($page as $intent) {
// current page only
}
foreach ($page->autoPagingIterator() as $intent) {
// every page
}
$next = $page->nextPage(); // null on the last page
$prev = $page->previousPage();
$airwallex->balances->current([], [
'on_behalf_of' => 'acct_...', // x-on-behalf-of, for connected accounts
'api_version' => '2025-02-14', // override x-api-version for this call
'headers' => ['x-custom' => 'value'],
'timeout' => 30,
]);
use WPZinc\Airwallex\Auth\AccessToken;
use WPZinc\Airwallex\Auth\TokenStoreInterface;
final class RedisTokenStore implements TokenStoreInterface
{
public function __construct(private \Redis $redis) {}
public function get(string $key): ?AccessToken
{
$data = $this->redis->get($key);
return $data ? AccessToken::fromArray(json_decode($data, true)) : null;
}
public function put(string $key, AccessToken $token): void
{
$this->redis->setex($key, max(1, $token->expiresAt - time()), json_encode($token->toArray()));
}
public function forget(string $key): void
{
$this->redis->del($key);
}
}
$airwallex = new AirwallexClient([..., 'token_store' => new RedisTokenStore($redis)]);