PHP code example of soltanihossein / saman-payment
1. Go to this page and download the library: Download soltanihossein/saman-payment 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/ */
soltanihossein / saman-payment example snippets
use SoltaniHossein\Saman\Saman;
try{
/**
* @param int $merchantId (equired) The amount that customer must pay
* @param string $callbackUrl ( *
* @method request Return array contain transaction `token` and you can save.
* $token = $response;
*
*/
$response = $saman->request($amount, $callbackUrl, $invoiceId);
/**
* Redirect user to payment gateway
*/
echo $saman->redirect();
}catch (\Throwable $exception){
echo $exception->getMessage();
}
use SoltaniHossein\Saman\Saman;
try{
/**
* @param int $merchantId (* @method $verify return array of transaction data.
*
*/
$response = $saman->verify($amount);
echo "Successful payment ...";
}catch (\Throwable $exception){
echo $exception->getMessage();
}