paymentsgate / easy-api-php
PHP SDK for PaymentsGate Easy API
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-11-05 12:30:16 UTC
README
This is a lightweight PHP SDK for communication with the PaymentsGate Easy API service.
Features
- Wallet balance requests
- Bank list requests with optional filters
- Deal lookup by ID
- PayIn creation
- PayOut creation
- FX calculation via GET and POST requests
- Typed enums for common API values
- DTO/value objects for typed requests and responses
- Specialized exceptions for config, transport and HTTP errors
Requirements & Dependencies
- PHP 8.1 or higher
ext-curl- native PHP extension for HTTP requestsext-json- native PHP extension for JSON payload manipulation
Installation
You can install the package via composer:
composer require paymentsgate/easy-api-php
Usage
<?php require_once __DIR__ . '/vendor/autoload.php'; use PaymentsGate\Client; use PaymentsGate\Data\DealPayOutRecipient; use PaymentsGate\Data\DealPayOutRequest; use PaymentsGate\Data\FxCalculationRequest; use PaymentsGate\Enums\BanksFindTags; use PaymentsGate\Enums\Currencies; use PaymentsGate\Enums\DealLanguages; use PaymentsGate\Enums\DealSubtypes; use PaymentsGate\Enums\RecipientTypes; $client = new Client( endpoint: 'https://api.example.com', credentialsPath: __DIR__ . '/credentials.json', ); $wallet = $client->getWallet(); $walletDto = $client->getWalletDto(); print_r($wallet); echo $walletDto->assets[0]->currency->code . PHP_EOL;
The credentials.json file is used to connect to the client and should contain your API key:
{
"api_key": "your-api-key"
}
If you prefer not to store credentials in a file, you can pass the API key directly:
<?php use PaymentsGate\Client; $client = new Client( endpoint: 'https://api.example.com', apiKey: 'your-api-key', );
Examples
You can keep using plain arrays, or switch to typed DTO/value objects.
Get banks
$banks = $client->getBanks( search: 'bank', tag: BanksFindTags::FAST->value, );
Get banks as DTO
$banks = $client->getBanksDto(); foreach ($banks->rows as $bank) { echo $bank->name . ' ' . $bank->currency . PHP_EOL; }
Get deal by ID
$deal = $client->getDeal('deal-id');
Create PayIn
$result = $client->createPayIn([ 'amount' => 100, 'currency' => Currencies::USDT, 'invoiceId' => 'INV-1001', 'type' => DealSubtypes::P2P, 'lang' => DealLanguages::RU, ]);
Create PayOut
$result = $client->createPayOut([ 'amount' => 100, 'currency' => Currencies::USDT, 'invoiceId' => 'INV-1002', 'recipient' => [ 'account_number' => '4000000000000012', 'account_owner' => 'CARD HOLDER', 'type' => RecipientTypes::CARD, ], ]);
Create PayOut with DTO
$result = $client->createPayOutDto( new DealPayOutRequest( currency: Currencies::USDT->value, currencyTo: Currencies::KZT->value, amount: 100, invoiceId: 'INV-1002', recipient: new DealPayOutRecipient( accountOwner: 'CARD HOLDER', type: RecipientTypes::CARD->value, accountNumber: '4000000000000012', ), ), ); echo $result->id . PHP_EOL; echo $result->status . PHP_EOL;
Calculate FX via GET
$result = $client->calculateFxGet([ 'amount' => 100, 'currency_from' => Currencies::USDT, 'currency_to' => Currencies::EUR, ]);
Calculate FX via POST
$result = $client->calculateFxPost([ 'amount' => 100, 'currency_from' => Currencies::USDT, 'currency_to' => Currencies::EUR, ]);
Calculate FX with DTO
$result = $client->calculateFxPostDto( new FxCalculationRequest( currencyFrom: Currencies::USDT->value, currencyTo: Currencies::KZT->value, amount: 100, subtype: DealSubtypes::P2P->value, ), ); echo $result->finalAmount . PHP_EOL; echo $result->quotes[0]->rate . PHP_EOL;
Error handling
All SDK-specific exceptions extend PaymentsGate\ApiException, so you can either catch the base class or a more specific subtype:
<?php use PaymentsGate\ApiException; use PaymentsGate\Exceptions\CredentialsFileException; use PaymentsGate\Exceptions\DuplicateDealException; use PaymentsGate\Exceptions\InvalidCurrencyFromException; use PaymentsGate\Exceptions\RequestException; use PaymentsGate\Exceptions\TransportException; try { $wallet = $client->getWallet(); } catch (CredentialsFileException $e) { echo 'Bad credentials config' . PHP_EOL; } catch (TransportException $e) { echo 'Network error: ' . $e->getMessage() . PHP_EOL; } catch (DuplicateDealException $e) { echo 'Duplicate invoiceId' . PHP_EOL; } catch (InvalidCurrencyFromException $e) { echo 'Bad currency_from: ' . $e->errorCode . PHP_EOL; } catch (RequestException $e) { echo 'API error: ' . $e->statusCode . PHP_EOL; } catch (ApiException $e) { echo $e->getMessage() . PHP_EOL; print_r($e->details); }
Available enums
PaymentsGate\Enums\BankPaymentSystemsPaymentsGate\Enums\BanksFindTagsPaymentsGate\Enums\BankTypesPaymentsGate\Enums\CurrenciesPaymentsGate\Enums\DealDirectionsPaymentsGate\Enums\DealLanguagesPaymentsGate\Enums\DealStatusesPaymentsGate\Enums\DealSubtypesPaymentsGate\Enums\DealTypesPaymentsGate\Enums\HttpMethodsPaymentsGate\Enums\RecipientTypesPaymentsGate\Enums\TtlUnitsPaymentsGate\Enums\WidgetVersions
Available DTOs
PaymentsGate\Data\WalletPaymentsGate\Data\WalletAssetPaymentsGate\Data\CurrencyPaymentsGate\Data\BanksPaymentsGate\Data\BankPaymentsGate\Data\DealPaymentsGate\Data\DealStatusPaymentsGate\Data\DealPayInRequestPaymentsGate\Data\DealPayInResponsePaymentsGate\Data\DealPayOutRecipientPaymentsGate\Data\DealPayOutRequestPaymentsGate\Data\DealPayOutResponsePaymentsGate\Data\FxCalculationRequestPaymentsGate\Data\FxCalculationPaymentsGate\Data\Quote