PHP code example of growincapps / sdk-payment-page

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

    

growincapps / sdk-payment-page example snippets


use Payment\PaymentClient;

$client = new PaymentClient(username: '[email protected]', apiKey:'@Password123');

try {
    $session = $client->createPaymentSession(
        [
            'payment_method_id'=> 1,
            'items' => [
                [
                    "name" => "item1",
                    "qty" => 1, 
                    "price" => "100",
                    "code" => "BSU-2009"
                ],
                [
                    "name" => "item2", 
                    "qty" => 2, 
                    "price" => "50", 
                    "code" => "ABC-2024"
                ],
            ],
            'redirect_url' => 'http://google.com/?return', //optional
            'callback_url' => 'http://google.com/?callback', //optional
            'payment_identifier' => 'PHP-SDK-NP' // wajib
        ]
    );

    print('Session ID:' . $session->session_id . PHP_EOL);
    print('Total:' . $session->total_amount . PHP_EOL);

    print_r($session);
} catch (\Throwable $th) {
    print('Gagal buat sesi: ' . $th->getMessage());
}

$session = $client->createPaymentSession(
    ...
);

$client = new PaymentClient('[email protected]', '@Password123');
$recheckstatus = $client->checkStatusPayment($session->session_id, $session->access_token);