我正在尝试使用 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 负载可以全额退款,但这不起作用。有人有想法吗?
最佳答案
您已经为此交易进行了部分退款。当您再次尝试为同一笔交易进行全额退款时,交易将被拒绝。
部分退款后不能做全额退款
关于 Paypal 全额退款无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38576975/