نمونه کد اتصال شامل دو فایل به نام های send.php و verify.php است که شما محتوای این دو فایل را در ادامه می بینید.
send.php
function send($merchant,$amount,$callback,$description=null,$orderId=null){
$parameters = array(
"merchant"=>$merchant,
"amount"=>$amount,
"callback"=>$callback,
"description"=>$description,
"orderId"=>$orderId
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sepordeh.com/merchant/invoices/add");
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if(!!curl_errno($ch)){
die("CURL ERROR:".curl_error($ch));
}else{
$result = json_decode($result);
if($result->status==200)
header('Location: https://sepordeh.com/merchant/invoices/pay/automatic:true/id:'.$result->information->invoice_id, true, 302);
else
die("WEBSERVICE ERROR:".$result->message);
}
curl_close($ch);
}
verify.php
function verify($merchant){
GLOBAL $_GET;
$orderId = $_GET["orderId"];
if(isset($_GET["authority"])){
$parameters = array(
"merchant"=>$merchant,
"authority"=>$_GET["authority"],
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://sepordeh.com/merchant/invoices/verify");
curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
if(!!curl_errno($ch)){
die("CURL ERROR:".curl_error($ch));
}else{
$result = json_decode($result);
if($result->status==200){
//paid successful
}else{
die("WEBSERVICE ERROR:".$result->message);
}
}
curl_close($ch);
}else{
die("ERROR:invalid request");
}
}