2016-07-25 96 views
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有效载荷,但这种不工作。任何人有想法?

回答

1

您已经为此交易完成了部分退款。当您尝试再次为同一交易完成全额退款时,交易将被拒绝。

Can not do a full refund after a partial refund

+0

谢谢,这是解决方案! – Richard