PHP code example of plaramart / tbi-bank

1. Go to this page and download the library: Download plaramart/tbi-bank 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/ */

    

plaramart / tbi-bank example snippets

 
$client = new \Plaramart\TbiBank\Client('your-api-secret', __DIR__.'/folder/pub.pem');

// Inside AppServiceProvider.php
$this->app->singleton(\Plaramart\TbiBank\Client::class, function () {    
    $apiSecretKey = 'your-api-secret';
    $pathToCert = storage_path('app/pub.pem');
    return new \Plaramart\TbiBank\Client($apiSecretKey, $pathToCert);
});
      
// (float $price, float $initialPayment = 0, int $category = 10, $insurance = 'n')
$calculationRequest = new \Plaramart\TbiBank\Requests\CalculateForAllPeriodSchemesRequest(
    price: 113
);

$response = $client->execute($calculationRequest);

// (float $price, int $period = 3, float $initialPayment = 0, int $category = 10, $insurance = 'n')
$calculationRequest = new \Plaramart\TbiBank\Requests\CalculateForPeriodRequest(
    price: 113, 
    period: 3
);

$response = $client->execute($calculationRequest);

$order = new CreateOrderRequest(price: 113, months: 3, initialPayment: 50);

$order->setUser(
    name: 'Zgdevv LordGeorgex', 
    id: 9808027528, 
    address: 'Na borovets batko', 
    phone: '+35988888888', 
    email: '[email protected]'
);

// You can add as much as u want products. 
// Product ID from your database. nothing to do with their API
$order->addProduct(
    id: 1, 
    name: 'test', 
    quantity: 2, 
    price: 113
);

$response = $client->execute($order);