payumoney在PHP中退款api

时间:2017-12-23 09:54:55

标签: php payumoney

在我的移动应用程序中,我已经完美配置了payumoney并且工作得很好。它只是一个退款的情况。下面是我从应用程序调用的php文件中的代码:

include('../connection.php');

$orderid="AMD197";   

$view_rs =$conn->prepare("SELECT * from tbl_payumoney_order WHERE orderid=:orderid");       

$view_rs->execute(array(':orderid'=>$orderid));                 
$vfetch=$view_rs->fetch();

$merchantId="393463"; 
$paymentId= $vfetch['paymentId'];
$refundAmount= $vfetch['amount'];
$merchantAmount= $vfetch['amount'];
$aggregatorAmount= "0";
$refundType="1";

$data_string="paymentId=".$paymentId."&refundAmount=".$refundAmount."&refundType=".$refundType."&merchantId=".$merchantId."&merchantAmount=".$merchantAmount."&aggregatorAmount=".$aggregatorAmount; 

//paymentId=123456&refundAmount=56&refundType=1&merchantId=765433&merchantAmount=6&aggregatorAmount=50 


$ch = curl_init();      
$url = "https://test.payumoney.com/payment/refund/refundPayment";   

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true);  /* tell curl you want to post something*/
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string); /* define what you want to post*/
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); /* return the output in string format*/
$headers = array();

$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$output = curl_exec ($ch); 
$info = curl_getinfo($ch);

$data = json_decode($output, true); 

print_r($data);

$status= $data['status']; 
$message= $data['message'];
$result= $data['result'];

我收到了这个回复:

  

数组([状态] => -1 [行] => 0 [消息] =>出错了   guid 3k4pcbv6kdqf405g0lut7id32m sessionId null [result] => [guid] =>   3k4pcbv6kdqf405g0lut7id32m [sessionId] => null [errorCode] => )

有人可以建议我在这里做错什么吗?

2 个答案:

答案 0 :(得分:1)

退款API在测试/沙盒环境中不起作用。

请在下面的实时环境中找到退款API:

https://www.payumoney.com/treasury/merchant/refundPayment?merchantKey=merchantkeyvalue&paymentId=1234&refundAmount=10

请在参数中传递商户密钥,付款ID和金额,在标头中传递授权标头。

答案 1 :(得分:0)

出现问题...... 由于500,502,503或504因PayUmoney结束而出现错误 根据{{​​3}},您的应用或网站中出现服务器错误。

要了解有关这些HTTP响应代码的更多信息,您需要按照以下链接进行操作:

PayUmoney API Documentation

如果发生以下故障,请更新您的Curl以获取更多信息:

$output = curl_exec($ch);

if ($output === false){
    // throw new Exception('Curl error: ' . curl_error($output));
    print_r('Curl error: ' . curl_error($output));
}

如果您仍然不确定自己的问题,最好联系https://en.wikipedia.org/wiki/List_of_HTTP_status_codes