I'm finding the PayPal dev docs confusing, to say the least. Express Checkout has 3 different actions:
Authorization
Order
Sale
Using the client-side api, I've set up a simple sale
of a single item. Now I want to verify, server-side, that this sale has fully completed; the Express Checkout docs say I should use an API call to payment
to do so (https://developer.paypal.com/docs/integration/direct/express-checkout/show-payment-details/)
Why would I not use an API call to sale
, or is that an option too? What is the difference between a sale
and a payment
in this example? When a buyer purchases my single item, is there both a sale
and a payment
that I can query?
https://developer.paypal.com/docs/api/payments/#sale_get
Thanks in advance.
payment
is the parent object of sale
, authorization
and order
, which means whenever you create a payment intent (either it's a sale
, authorization
or order
), you can get the details via the parent payment_id
.
That said, the reason why in this step Show payment details to buyer you would rather call /v1/payments/payment/{payment_id}
instead of /v1/payments/sale/{sale_id}
is that, at this point you've not executed the payment and you won't see a sale_id
until then in the API response.
(so this step is just for showing the payment details in the page before your buyer clicking Place Order and you executing the payment).
In other cases, say if you have already executed the payment and have a sale_id
from the response, you can definitely verify that by making a GET call to /v1/payments/sale/{sale_id}
, though there're other ways for you to get the payment details async from PayPal via webhooks or IPN.