1
votes

Not sure if what I am trying is possible or not, so asking here.

I have a monthly recurring service that will be launched within 1 - 2 months. I would like users to register for the service and connect their PayPal account, so we know they are serious about getting the service once launched.

I am trying to use the REST API to create a billing agreement and, once we launch the service, add the subscription to the billing agreement. So far I managed to create a billing agreement and charge $0.01 one time when created.

What I can't seem to do is to add a subscription plan later to this agreement, or manually collect payments.

When trying to add a subscription, I call

PATCH /v1/payments/billing-agreements/I-HD5N7C15L8E0

with this payload:

{
    "path": "/",
    "value": {
        "plan": {
            "id": "P-70R54842DB762764NJEVCS7Y"
        },
    },
    "op": "replace"
}

and receive

Incoming JSON request does not map to API request","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#MALFORMED_REQUEST

When trying to collect the amount, I call

POST /v1/payments/billing-agreements/I-HD5N7C15L8E0/set-balance

with this payload

{
    "value": "50",
    "currency": "USD"
}

and receive

Outstanding balance must be > 0","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#RP_INVALID_OUTSTANDING_BALANCE

At this point, I am about to give up using the REST API and use instead Express Checkout and Reference Transactions, which I understand is an alternative method to collect these payments.

Do you know if what I am trying to achieve works with the REST API?

Thanks

1

1 Answers

1
votes

For your first question, you cannot change the plan on an agreement after it has been created. To create an agreement with a new billing plan, you need to create a new billing agreement with the plan P-70R54842DB762764NJEVCS7Y and get user's consent. For your second question, set balance is a way to reset the unpaid balance on an agreement, which you can collect by using bill-balance. It seems that there was no outstanding balance remaining on that account, hence the API threw an error.