PayPal Rest API - Update Billing Plan Return URL

2020-06-07 05:17发布

问题:

I have been using the PayPal Rest API and have successfully created and activated a BillingPlan but I'm having trouble updating said plan's return_url. I think it's something to do with the JSON path I'm using although I'm not sure why!?

Anyway, I am calling the update plan method: https://developer.paypal.com/docs/api/#update-a-plan

A BillingPlan follows the format:

{
  "id": "P-94458432VR012762KRWBZEUA",
  "state": "ACTIVE",
  "name": "T-Shirt of the Month Club Plan",
  "description": "Template creation.",
  "type": "FIXED",
  ...
  "merchant_preferences": {
    "setup_fee": {
      "currency": "USD",
      "value": "1"
    },
    "max_fail_attempts": "0",
    "return_url": "http://example.com",
    "cancel_url": "http://example.com",
    "auto_bill_amount": "YES",
    "initial_fail_amount_action": "CONTINUE"
  },
  ...
}

I'm using the C# SDK but my request JSON should look very much like:

{
    "path": "merchant_preferences",
    "value": {
        "return_url": "http://example.com/payment/return"
    },
    "op": "replace"
}

I keep getting responses along the line's of:

{"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":"2ae68f9f0aa72"}

To sum up - I want to change the billing plan return_url from http://example.com to http://example.com/payment/return.

I've changed the path to various things to no avail. Can anyone help??

回答1:

You cannot update the plan, once it is set to active. The reason for that restriction is that because there could be possible agreements based on that plan, modifying it would affect the already agreed billing agreements.

However, I agree with your problem statement, that changing the Return URL should not be an issue as this is not a part of agreement, but more of a configuration change. It would be nice to somehow allow updating similar settings in Plan, even after active. I will let the API team know about that.

however, in the mean time, there is no way you would be able to do that. Alternatively, you could possibly create a new plan, and use that instead. Not the answer you are looking for, but a probable solution.