0
我試圖發起全額退款貝寶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有效載荷,但這種不工作。任何人有想法?
謝謝,這是解決方案! – Richard