在PHP中使用Instamojo的集成支付网关

时间:2018-08-07 10:42:50

标签: php mysql instamojo

我正在尝试使用php集成instamojo。金额记入借方,但付款完成后状态显示支付失败。即使我从instamojo付款获得电子邮件也很成功。但是在使用实时集成时,网页状态显示为失败。实时集成需要做哪些更改这是代码。

<?php
include_once "db.php";


$pay_id=$_REQUEST['payment_id'];
$req=$_REQUEST['payment_request_id'];
//print_r($_REQUEST);
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://www.instamojo.com/api/1.1/payment-requests/'.$pay_id.'/');
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER,
            array("X-Api-Key:0128f53142e657df0ca45173383915d7",
                  "X-Auth-Token:60bd8d30734fcbf3a930be406c418c21"));

$response = curl_exec($ch);
curl_close($ch); 

$json=json_decode($response,TRUE);
if($json['success']==true){
 echo "payment done";
 $status=$json['payment'];
 $up=mysql_query("UPDATE `payment` SET `status`='".$status['status']."' WHERE id='".$req."'");
}
else{
 echo "payment failed";
}
?>

0 个答案:

没有答案