简体   繁体   中英

Update paypal billing plan (payment_definitions)

I want to change amount of a Billing Plan but I'm getting an error when trying to do that. It's possible to change the terms of the Plan (payment_definitions) if the Plan has already Agreements associated with it?

Request:

curl -v -k -X PATCH 'https://api.sandbox.paypal.com/v1/payments/billing-plans/[plan id]' \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-d '[
    {
        "path": "/payment_definitions/[payment_definitions_id]/amount",
        "value": {
            "currency": "EUR",
            "value" : "10"
        },
        "op": "replace"
    }
]'

Response:

{
   "name":"BUSINESS_VALIDATION_ERROR",
   "details":[
      {
         "field":"validation_error",
         "issue":"Invalid Path provided."
      }
   ],
   "message":"Validation Error.",
   "information_link":"https://developer.paypal.com/webapps/developer/docs/api/#BUSINESS_VALIDATION_ERROR",
   "debug_id":"183e87c07085e"
}

I have been through the same situation right now!

So far i researched, it is not possible to alter the amount and amount related constraints for a billing plan, because the service may not be provided by the paypal.

For instance, let's say, there is a plan P1 which is in active state. So, there may be some agreements , lets say A1, which are subscribed to P1.

So, problem is clear, if A1 is subscribed to P1 plan with some amount, lets say USD 200, the subscriber is charged 200 in each payments, but in case, if you alter it to USD 210, You simply cannot charge the subscriber with USD 210. :)

But in your case, i think the path is invalid, and the response clearly indicates the error.

You may try to use create_agreement_request approach . There is override_charge_models object within the request. And you may find amount field in that object. To achieve this you have to know Agreement Id (which looks like "I-XXXXXXXXX") and transaction id (sometimes it calls sale_id or capture_id).

I have to say that I haven't tried it yet but it's kind of new feature. I suppose it should update the amount of recurring payment without cancelling the subscription.

You cannot update or patch billing plan. You can only change billing agreements of each customer.

There are two APIs provided by PayPal.

Recently PayPal opened new API for subscription payment. Previous APIs for billing plan and billing agreement is deprecated now as you can see the notice in this page:

https://developer.paypal.com/docs/api/payments.billing-agreements/v1/

This new API supports upgrading and downgrading of user plans or change (for example) the license quantity.

https://developer.paypal.com/docs/subscriptions/

Hope this helps.

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