سلام دوستان من تو یه پروژه تستی php میخام تست درگاه بگیرم با زرین پال
کدهامو میزارم و همینطور خطا لطفا راهنمایی کنید خیلی ضررویه
ممنونم
صفحه payment.php
<?php
$data = array("merchant_id" => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"amount" => 1000,
"callback_url" => "http://localhost/verify.php",
"description" => "خرید تست",
"metadata" => [ "email" => "[email protected]","mobile"=>"09121234567"],
);
$jsonData = json_encode($data);
$ch = curl_init('https://sandbox.zarinpal.com/pg/v4/payment/request.json');
curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v1');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData)
));
$result = curl_exec($ch);
$err = curl_error($ch);
$result = json_decode($result, true, JSON_PRETTY_PRINT);
curl_close($ch);
if ($err) {
echo "cURL Error #:" . $err;
} else {
if (empty($result['errors'])) {
if ($result['data']['code'] == 100) {
header('Location: https://sandbox.zarinpal.com/pg/StartPay/' . $result['data']["authority"]);
}
} else {
echo'Error Code: ' . $result['errors']['code'];
echo'message: ' . $result['errors']['message'];
}
}
?>
verify.php
<?php
$Authority = $_GET['Authority'];
$data = array("merchant_id" => "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "authority" => $Authority, "amount" => 1000);
$jsonData = json_encode($data);
$ch = curl_init('https://sandbox.zarinpal.com/pg/v4/payment/verify.json');
curl_setopt($ch, CURLOPT_USERAGENT, 'ZarinPal Rest Api v4');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($jsonData)
));
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result, true);
if ($err) {
echo "cURL Error #:" . $err;
} else {
if ($result['data']['code'] == 100) {
echo 'Transation success. RefID:' . $result['data']['ref_id'];
} else {
echo'code: ' . $result['errors']['code'];
echo'message: ' . $result['errors']['message'];
}
}
?>
وقتی روی پرداخت میزنم خطای
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\shoptest\payment.php on line 31
Warning: Trying to access array offset on value of type null in C:\xampp\htdocs\shoptest\payment.php on line 31
دوستان لطفا راهنمایی کنید مشکل کجاست و چیکار باید کرد؟
من کدی که واسه تست نوشته بودم چندین سال باهاش کار میکردم که متوجه شدم به مشکل خورده، آخرین تیکتی که واسه زرین پال ارسال کردم گفتن که درگاه تست رو برداشتن و در دسترس نیست
آیا مایل به ارسال نوتیفیکیشن و اخبار از طرف راکت هستید ؟