简体   繁体   中英

paypal update billing plan amount is not working

I am working on paypal update billing plan amount, but it is not getting update, i have go through some paypal document as well but still it doesn't help me, this is my code

Code

/************************** 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;

Response :

<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
)

Can anyone please help how can i resolve this issue ?

I was able to review our logs with that debug_id and it shows that this was in your patch:

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

You are receiving the error because we do not allow zero dollar Billing Plans. The "value" has to be a positive amount to be valid.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM