PHP code example of cynobit / crediborg-client

1. Go to this page and download the library: Download cynobit/crediborg-client 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/ */

    

cynobit / crediborg-client example snippets


$ composer 

$amount = 75000;

$secret = ".....";
$token = "...";

$invoice = new CrediBorg\Invoice($amount);

$invoice->setCode('AHYT645623')
    ->setEmail('[email protected]');
    ->setCustomer([
        'first_name'  => 'John',
        'middle_name' => 'Alfred',
        'last_name'   => 'Doe'
    ])
    ->setMetaData([
        // Possible cart items or anything you want.
        'items' => [
            [
                'name'       => 'Raspberry Pi'
                'qty'        => 2,
                'unit_price' => 25000
            ],
            [
                'name'       => 'ESP32 Module'
                'qty'        => 20,
                'unit_price' => 2000
            ]
        ]
    ]);
$crediborg = new CrediBorg\CrediBorg($secret, $token);

$crediborg->createInvoice($invoice);

echo $invoice->getCode(); // Invoice Code

$secret = ".....";
$token = "...";

$crediborg = new CrediBorg\CrediBorg($secret, $token);

$event = $crediborg->getEventPayload();

foreach ($event->getMatchedInvoices() as $invoice) {
    echo $invoice->code . PHP_EOL;
    foreach ($invoice->getMatchedTransactions() as $transaction) {
        echo $transaction->narration . PHP_EOL;
        echo $transaction->type . PHP_EOL;
        echo $transaction->amount . PHP_EOL;
    }
}