我正在尝试使用PayPal API提供全额退款:
$header = Array(
"Content-Type: application/json",
"Authorization: Bearer $token",
);
$ch = curl_init($aurl . "/v1/payments/sale/{$params['transid']}/refund");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{}');
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$res = json_decode(curl_exec($ch));
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
我收到状态代码400,并收到此消息:
["name"]=> string(19) "TRANSACTION_REFUSED"
["message"]=> string(23) "Request was refused.{0}"
["information_link"]=> string(76) "https://developer.paypal.com/webapps/developer/docs/api/#TRANSACTION_REFUSED" ["debug_id"]=> string(13) "e1df77fc1910c"
部分退款正在使用此代码:
$header = Array(
"Content-Type: application/json",
"Authorization: Bearer $token",
);
$ch = curl_init($aurl . "/v1/payments/sale/{$params['transid']}/refund");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(Array("amount" => Array("total" => $_POST['amount'], "currency" => $params['currency']))));
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
$res = json_decode(curl_exec($ch));
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
PayPal says,使用空的JSON有效负载可以完全退款,但这不起作用。有人有想法吗?
答案 0 :(得分:1)
您已完成此交易的部分退款。当您尝试再次对同一笔交易进行全额退款时,交易将被拒绝。
Can not do a full refund after a partial refund