PHP code example of shopid / zarinpal
1. Go to this page and download the library: Download shopid/zarinpal 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/ */
shopid / zarinpal example snippets
//make zarinpal object
$zarinpal = new zarinPal([
"callBackUrl" => "https://www.mywebsice.com/zarinpalverify",
"merchantId" => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
]);
//make a request
try {
$request = $zarinpal->apiRequest([
"amount" => "1000",
"description" => "payment #999",
"email" => "[email protected]",
"mobile" => "09120000000",
]);
var_dump(json_decode($request));
} catch (Exception $error) {
var_dump(json_decode($error->getMessage()));
}
//verify peyment
try {
$verify = $zarinpal->verify(
[
"authority" => "A00000000000000000000000000000000000",
"amount" => "1000"
]
);
var_dump(json_decode($verify));
} catch (Exception $error) {
var_dump(json_decode($error->getMessage()));
}