25
votes

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
I'm not entirely sure what your question is, can you be more specific? - Pseudonym
Try prefixing the "path" with a "/", i.e. "path": "/merchant_preferences". - dbc
Also, apparently you can't update this once the plan is active, see github.com/paypal/PayPal-Python-SDK/issues/73 - dbc
@dbc tried "/" prefix to no avail but you're point about the plan being active could be a very good point. I will investigate over the next few days. Maybe I can deactivate, update and re-activate. - scgough

1 Answers

11
votes

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.