PHP code example of aqayepardakht / php-sdk

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

    

aqayepardakht / php-sdk example snippets




$api = new Aqayepardakht\PhpSdk\Api([
     'pin'     => 'Your Pin',
]);

try {       
    $pay = $api->gateway()
                ->invoice(['amount' => 500])
                ->callback('Your Callback')
                ->create();

    $traceCode = $pay->getTraceCode(); // دریافت کد رهگیری
    $pay->start(); // ریدایرکت کاربر به صفحه پرداخت
} catch (Exception $e) { 
    echo $e->getCode().' : '.$e->getMessage();
}



$trackingNumber = $_POST['tracking_number']; // کد رهگیری بانکی
$traceCode      = $_POST['transid']; // کد رهگیری برای تایید تراکنش
$api            = new Aqayepardakht\PhpSdk\Api();

try {
    $pay = $api->gateway('Your Pin')
                ->invoice(['amount' => 1100])
                ->verify($traceCode);
} catch (Exception $e) { 
    echo $e->getCode().' : '.$e->getMessage();
}
bash
composer