PHP code example of sadegh-pm / saman_bank

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

    

sadegh-pm / saman_bank example snippets



use SadeghPM\SamanBank\Saman;
use SadeghPM\SamanBank\SamanStorageAdapterInterface;
//seller ID
$merchantId = 'xxxxxxxx';
//database storage adapter that implements SamanStorageAdapterInterface
$myStorageAdapter = new myImplimentedStorageAdapter();
$payment = new Saman($myStorageAdapter,$merchantId);

$amountInRial = 10000;
//return customer after payment
$callbackUrl = 'http://mysite.ir/callback';
//request payment and redirect user to saman payment page
echo $payment->payRequest($amountInRial,$callbackUrl)->getRedirectScript();


use SadeghPM\SamanBank\Saman;
use SadeghPM\SamanBank\SamanStorageAdapterInterface;
//seller ID
$merchantId = 'xxxxxxxx';
//database storage adapter that implements SamanStorageAdapterInterface
$myStorageAdapter = new myImplimentedStorageAdapter();
$payment = new Saman($myStorageAdapter,$merchantId);

try{
    $payment->getPayStat($_POST);
    echo 'Thanks...successful payment.';
}catch (\Throwable $throwable){
    echo "error :".$throwable->getMessage();
}