Matching CHECKOUT.ORDER.APPROVED with PAYMENT.CAPTURE.COMPLETED

djslim
Contributor
Contributor

Hi,

 

I'm completely new to the PayPal API.

I'm using the smart button with a web hook to capture the payment & shipping information.

 

I thought I'd get the shipping info with the event CHECKOUT.ORDER.APPROVED then when I get the PAYMENT.CAPTURE.COMPLETED event I'll be sure the payment is fully processed.

 

I noticed that the transaction ID for both are different. so I have no way of matching the two.

Is there a way to match the two that I'm missing?

 

Or can I just assume CHECKOUT.ORDER.APPROVED is enough to trust that everything is good and ignore PAYMENT.CAPTURE.COMPLETED?

Login to Me Too
3 REPLIES 3

MTS-Aaron
PayPal Employee
PayPal Employee

Hi @djslim 

 

We would always recommend waiting for the "Payment.Capture.Completed" webhook for each transaction. The webhook for "Checkout.Order.Approved" was actually intended to be used to notify your system to attempt Payment Capture. In other words, some capture immediately and really don't need the Approved webhook since just the Completed one would suffice. But some choose to authorize, then capture later, checking to make sure they got an Approved webhook before initiating the capture. That's just a glimpse into the original intent.

 

I believe you can add your own order id called an "invoice_id". You can pass this in the "purchase_units" object when creating the transaction. Then, when you receive the checkout.order.approved webhook, you can look at the details of the transaction to find the invoice_id. Then, when capturing the transaction, that same invoice ID will be attributed to the captured ID as well.

 

I hope that helps!

-Aaron 

Login to Me Too

This is the reality of PayPal in 2021. You cant pass data to PAYMENT.CAPTURE.COMPLETED for whatever reason and you can't match CHECKOUT.ORDER.APPROVED that contains the relevant data to the right COMPLETED.

 

Using PayPal feels like fighting against PayPal not like using it

Login to Me Too

MarcoT999
Contributor
Contributor

This is a serious problem for us. There is no way to attribute `CHECKOUT.ORDER.APPROVED` with a `PAYMENT.CAPTURE.COMPLETED` since anything within the purchase_units don't show up in the latter webhook.

 

Aaron... help us out man.


Edit: I did find a way by analyzing the JSON payload in the webhook. I was able to match the checkout with the successful payment using:

 

req.body.resource.supplementary_data.related_ids.order_id

 

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.