PHP SDK provides API options for integrating Solidgate’s payment orchestrator into your PHP applications.
Check our
- Payment guide to understand business value better
- API Reference to find more examples of usage
SDK for PHP contains | Table of contents |
---|---|
src/solidgate/ – main library source code for developmentcomposer.json – script for managing dependencies and library imports
|
Requirements Installation Usage Errors |
- PHP: 7.2 or later
- Composer: Dependency manager for PHP
- Solidgate account: Public and secret key (request via sales@solidgate.com)
To start using the PHP SDK:
- Ensure you have your public and secret key.
- Install the SDK in your project using Composer:
composer require solidgate/php-sdk
- Alternatively, add the library to your composer.json file
{ "require": { "solidgate/php-sdk": "~1.0" } }
- Import the installed libraries into your application.
- Use test credentials to validate your integration.
- After successful testing, request production credentials and deploy your service.
Composer simplifies the installation and management of SDK dependencies, ensuring seamless integration.
<?php
use SolidGate\API\Api;
$api = new Api('YourMerchantId', 'YourPrivateKey');
$response = $api->charge(['SomePaymentAttributes from API reference']);
<?php
use SolidGate\API\Api;
$api = new Api('YourMerchantId', 'YourPrivateKey');
$dateFrom = new \DateTime("2019-01-01 00:00:00+00:00");
$dateTo = new \DateTime("2020-01-06 00:00:00+00:00");
$orderIterator = $api->getUpdatedOrders($dateFrom, $dateTo);
//$orderIterator = $api->getUpdatedChargebacks($dateFrom, $dateTo);
//$orderIterator = $api->getUpdatedAlerts($dateFrom, $dateTo);
foreach ($orderIterator as $order) {
// process one order
}
if ($api->getException() instanceof \Throwable) {
// save exception to log and retry request (if necessary)
}
<?php
use SolidGate\API\Api;
$api = new Api('YourMerchantId', 'YourPrivateKey');
$response = $api->formResign(['SomePaymentAttributes from API reference']);
$response->toArray(); // pass to your Frontend
Handle errors, using a try/catch block.
try {
$response = $api->charge([...]);
} catch (Throwable $e) {
error_log($e->getMessage());
}