202ecommerce / bridge-sdk
Bridge API SDK
Installs: 4 902
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 1
Requires
- ext-curl: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.4
- phpstan/phpstan: ^0.12.81
- phpunit/phpunit: ^9.0
- psr/cache: ^1.0.0
- psr/http-message: ^1.0
- psr/log: ^1.0
This package is not auto-updated.
Last update: 2024-11-20 10:52:49 UTC
README
This package is a Bridge PHP SDK. It let you manage exchange between your shop and Bridge.
This package is a dependency for Bridge PrestaShop module or Magento plugin.
Versions scope
This package is compatible with PHP 5.6+.
How to install it ?
composer require 202ecommerce/bridge-sdk
To use this package with php 5.6 or in production mode, please install this dependency with :
composer update --ignore-platform-reqs --no-dev
in a development environment
composer update
How to try this SDK ?
Get List of Banks
You can easily get list of banks by creating a request
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Model\Bank\ListBanks; use BridgeSDK\Request\ListBanksRequest; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $request = new ListBanksRequest(); $client = new Client(); $model = $response->getModel(); try { $response = $client->setCredential($clientId, $clientSecret) ->sendRequest($request); echo '<pre>'; var_dump($response->getModel()); echo '</pre>'; } catch (Exception $e) { echo ($e->getMessage() . $e->getFile() . ':' . $e->getLine() . $e->getTraceAsString()); }
You can also use the client api service to get list of offer
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Service\ClientApiService; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $client = (new Client()) ->setCredential($clientId, $clientSecret); $response = (new ClientApiService($client)) ->getListBanks();
Get Bank by ID
You can easily get a bank by ID by creating a request
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Model\Bank\Bank; use BridgeSDK\Request\BankRequest; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $id = 'bank-id'; $request = (new BankRequest()) ->setModel((new Bank()) ->setId($id) ); $client = new Client(); $model = $response->getModel(); try { $response = $client->setCredential($clientId, $clientSecret) ->sendRequest($request); echo '<pre>'; var_dump($response->getModel()); echo '</pre>'; } catch (Exception $e) { echo ($e->getMessage() . $e->getFile() . ':' . $e->getLine() . $e->getTraceAsString()); }
You can also use the client api service to get list of offer
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Service\ClientApiService; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $id = 'bank-id'; $client = (new Client()) ->setCredential($clientId, $clientSecret); $response = (new ClientApiService($client)) ->getBankById($id);
Get Payment by ID
Get payment by ID documentation
You can easily get a payment by ID by creating a request
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Model\Payment\Payment; use BridgeSDK\Request\PaymentRequest; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $id = 'payment-id'; $request = (new PaymentRequest()) ->setModel((new Payment()) ->setId($id) ); $client = new Client(); $model = $response->getModel(); try { $response = $client->setCredential($clientId, $clientSecret) ->sendRequest($request); echo '<pre>'; var_dump($response->getModel()); echo '</pre>'; } catch (Exception $e) { echo ($e->getMessage() . $e->getFile() . ':' . $e->getLine() . $e->getTraceAsString()); }
You can also use the client api service to get list of offer
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Service\ClientApiService; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $id = 'payment-id'; $client = (new Client()) ->setCredential($clientId, $clientSecret); $response = (new ClientApiService($client)) ->getPayment($id);
Create Payment
You can easily get create a payment by creating a request
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Model\Payment\CreatePayment; use BridgeSDK\Model\Payment\CreatePaymentTransaction; use BridgeSDK\Model\Payment\PaymentUser; use BridgeSDK\Request\CreatePaymentRequest; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $body = (new CreatePayment()) ->setBankId(6) ->setSuccessfulCallbackUrl('http://test.tot/?success') ->setUnsuccessfulCallbackUrl('http://test.tot/?error') ->setTransactions([ (new CreatePaymentTransaction()) ->setCurrency('EUR') ->setLabel('Label Unit test') ->setAmount(10.50) ->setClientReference('unit_test') ->setEndToEndId('unit_test') ]) ->setUser( (new PaymentUser()) ->setFirstName('Unit') ->setLastName('Test') ->setExternalReference('unit_test') ->setIpAddress('192.168.1.1') ); $request = (new CreatePaymentRequest()) ->setModel($body); $client = new Client(); $model = $response->getModel(); try { $response = $client->setCredential($clientId, $clientSecret) ->sendRequest($request); echo '<pre>'; var_dump($response->getModel()); echo '</pre>'; } catch (Exception $e) { echo ($e->getMessage() . $e->getFile() . ':' . $e->getLine() . $e->getTraceAsString()); }
You can also use the client api service to get list of offer
require 'vendor/autoload.php'; use BridgeSDK\Client; use BridgeSDK\Model\Payment\CreatePayment; use BridgeSDK\Model\Payment\CreatePaymentTransaction; use BridgeSDK\Model\Payment\PaymentUser; use BridgeSDK\Service\ClientApiService; $clientId = 'your-client-id'; $clientSecret = 'your-secret-idtoken'; $body = (new CreatePayment()) ->setBankId(6) ->setSuccessfulCallbackUrl('http://test.tot/?success') ->setUnsuccessfulCallbackUrl('http://test.tot/?error') ->setTransactions([ (new CreatePaymentTransaction()) ->setCurrency('EUR') ->setLabel('Label Unit test') ->setAmount(10.50) ->setClientReference('unit_test') ->setEndToEndId('unit_test') ]) ->setUser( (new PaymentUser()) ->setFirstName('Unit') ->setLastName('Test') ->setExternalReference('unit_test') ->setIpAddress('192.168.1.1') ); $client = (new Client()) ->setCredential($clientId, $clientSecret); $response = (new ClientApiService($client)) ->createPayment($body);
Get Webhook Response
You can easily subscribe to the webhook using this code. Webhook can come from next IPs: \BridgeSDK\Constant\WebhookIP.
require 'vendor/autoload.php'; try { $client = new \BridgeSDK\Client(); $response = $client->retrieveWebhookResponse(); $model = $response->getModel(); } catch (Exception $e) { // handle exception } // Do webhook process