paypal更新结算方案金额不起作用

时间:2018-01-09 05:28:04

标签: php paypal paypal-sandbox paypal-rest-sdk paypal-subscriptions

我正在研究paypal更新结算计划金额,但它没有得到更新,我已经通过一些paypal文件,但它仍然没有帮助我,这是我的代码

代码

/************************** Update Billing Plan *****************/

            $jsonString = '[{
                "op": "replace",
                "path": "/payment_definitions/'.$payment_defination_id.'/amount",
                "value": {
                                    "value": "0",
                                    "currency": "USD"
                        }
            }]';

            $ch = curl_init();
            curl_setopt($ch, CURLOPT_VERBOSE, true);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
            curl_setopt($ch, CURLOPT_URL,$paypal_update_plan_url.$paypal_plan_id.'/');
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json', 'Authorization: Bearer '.$access_token));
            curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonString);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $response = curl_exec($ch);
            curl_close($ch);
            $response = json_decode($response);
            echo "<pre>"; 
            print_r($response);
            die;

回应:

<pre>stdClass Object
(
    [name] => BUSINESS_VALIDATION_ERROR
    [details] => Array
        (
            [0] => stdClass Object
                (
                    [field] => validation_error
                    [issue] => Invalid Path provided.
                )

        )

    [message] => Validation Error.
    [information_link] => https://developer.paypal.com/docs/api/payments.billing-plans#errors
    [debug_id] => afb847748b312
)

有谁可以帮助我如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我能够使用该debug_id查看我们的日志,并显示这是在您的补丁中:

"amount":
{
  "value": "0",
  "currency": "USD"
},

您收到错误是因为我们不允许零美元的结算方案。 &#34;值&#34;必须是正数才有效。