porton
porton

Reputation: 5805

How to cancel buyer's agreement programmatically? (PayPal)

I want to cancel a buyer's recurring transaction entirely automatically (without manual logging into PayPal account neither for us nor for the customer) by our software.

https://developer.paypal.com/docs/api/ and https://developer.paypal.com/docs/api/payments.billing-agreements say that we can use /v1/payments/billing-agreements/<agreement_id>/cancel.

But it requires authorization. We do not want to ask the customer to authorize on his own. We want to do it from our side entirely automatically.

Is it possible to obtain an authorization token for this situation without customer's intervention? If yes, how?

Upvotes: 2

Views: 641

Answers (1)

Luke
Luke

Reputation: 23680

The authorization is not required by the user in order for you to cancel the agreement, it is API authorization that you need to interact with your billing agreements programatically.

I would have thought that if you have access to the details of their billing agreement in your business Paypal account, you should have access to this information once you are authorized to communicate with the API and thus authorization to cancel any agreements that are active in your account.

The PayPal API credentials that you use to communicate with the API should be one associated with the PayPal account that has access to the agreement details.

Once you're there, you can retrieve the PayPal agreement by the Agreement ID and call Cancel on it using the SDK.

  1. Find the SDK for the language that you wish to use (you didn't specify a language in your question) and follow the quick start guide. The quick start guides contain details on how to create API keys to access your account programatically.

  2. Load the agreement details using the Agreement ID, examples for each are linked here. It is possible to load all agreements for your account using the api too, so you can get all of the Agreement IDs and loop through them if you wish.

  3. Call the cancel method on an agreement to cancel it

I hope this helps!

Upvotes: 2

Related Questions