如何在php中处理razorpay退款

the official doc says by using curl the refund process will takesplace. How to implement this in php?

curl https://api.razorpay.com/v1/payments/pay_6ydSup2U7aFMsA/refund \
   -u {KEY}:{SECRET} \
   -d 'amount=15000' \
   -d 'reverse_all=1'

output:

{
  "id": "rfnd_6ye1vPrRFo6TdA",
  "entity": "refund",
  "amount": 15000,
  "currency": "INR",
  "payment_id": "pay_6ydSup2U7aFMsA",
  "notes": {},
  "created_at": 1482998305
}

I tries something like this:-

<?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);
?>

but nothing happens

I do not recommend interacting with a Saas API using curl, it is better to use a PHP library for that, razorpay has one. Then refunding is this simple:

$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

add this code and try i think it is because of ssl

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

请教一下 怎么发起付款 我按着官方文档走 报错了