Dimitri
Dimitri

Reputation: 8290

How to cancel a paypal payment through API

I am using a PaypalPayment Pro to make some direct payments with the paypal API in Java and I am using the DoDirectPayment class for this purpose. Now I am searching a way to cancel a payment but it seems that the API does not offer this possibility. I searched through the documentation but I did not see anything convincing. I saw the class DoVoid which may correspond to what I am searching but I am not totally sure. What is the current class / or method for cancelling a payment with the Paypal API?

Thanks for your suggestions !!

Upvotes: 0

Views: 971

Answers (1)

Matt Cole
Matt Cole

Reputation: 2562

It depends on what you mean by "cancel".

If you ran an authorization (e.g., if you set PaymentAction=Authorization in your DoDirectPayment call), the payment is on hold until you capture it, void it, or 29 days have passed. If you don't need the authorization, you can either let it expire on its own, or you can call DoVoid to void it. If you call DoVoid, set AuthorizationID to the transaction ID you received from the DoDirectPayment call.

If you ran a sale (e.g., if you set PaymentAction=Sale, or if you didn't set it at all), or if you captured the transaction (either through the PayPal account or by calling DoCapture), the payment has been completed. To "cancel" a completed transaction, you'll need to refund it. To do this, call RefundTransaction, and set TransactionID to the transaction ID you received from the DoDirectPayment call.

Upvotes: 2

Related Questions