PHP code example of 202ecommerce / bridge-sdk

1. Go to this page and download the library: Download 202ecommerce/bridge-sdk 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/ */

    

202ecommerce / bridge-sdk example snippets




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());
}



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();



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());
}



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);



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());
}



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);



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());
}



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);


    
try {
    $client = new \BridgeSDK\Client();
    $response = $client->retrieveWebhookResponse();
    
    $model = $response->getModel();
} catch (Exception $e) {
    // handle exception
}

// Do webhook process