官方文件说,使用curl进行退款程序。如何在php中实现呢?
curl https://api.razorpay.com/v1/payments/pay_6ydSup2U7aFMsA/refund \
-u {KEY}:{SECRET} \
-d 'amount=15000' \
-d 'reverse_all=1'
输出:
{
"id": "rfnd_6ye1vPrRFo6TdA",
"entity": "refund",
"amount": 15000,
"currency": "INR",
"payment_id": "pay_6ydSup2U7aFMsA",
"notes": {},
"created_at": 1482998305
}
我尝试这样的事情:-
<?php
$url="https://api.razorpay.com/v1/payments/pay_jhjhdfsjfhsdjf/refund";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'user: rzp_test_key',
'pass: rzp_test_pass'
));
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($output);
curl_close($ch);
?>
但什么也没发生
答案 0 :(得分:3)
我不建议使用curl与Saas API进行交互,为此,最好使用PHP库razorpay has one。 那么退款很简单:
$refund = $api->refund->create(array('payment_id' => $id)); // Creates refund for a payment
$refund = $api->refund->create(array('payment_id' => $id, 'amount'=>$refundAmount)); // Creates partial refund for a payment
$refund = $api->refund->fetch($refundId); // Returns a particular refund
答案 1 :(得分:0)
添加此代码,然后尝试我认为是由于ssl
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);