What if connection is lost before "onApprove" ?

geemsolutions
Contributor
Contributor

Part of the code that I'm talking about:

 

Spoiler
onApprove: function(data, actions) {
      return actions.order.capture().then(function(details) {
        
// What if connection is lost right before executing the code below
return fetch('/paypal-transaction-complete', { method: 'post', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ orderID: data.orderID }) }); }); }

As everyone else here, I'm using the fetch path to execute the SDK and store some information in the database, said SDK takes the data.orderID

 

But what do I do if the customer loses connection before fetch is executed? In said case I would not retrive the data.orderID and therefore wouldn't be able to request the details, even though the payment was processed.

 

Any advice is welcome

 

Edit: Made a payment through sandbox and closed the tab right after paying, as expected the payment was processed but it wasn't saved on the database.

Login to Me Too
1 ACCEPTED SOLUTION

Accepted Solutions
Solved

geemsolutions
Contributor
Contributor

I saw your message too late.

 

What I did was:

 

1) Add a loading screen so the user doesn't click away during transaction

2) Before even processing the Paypal sale information I saved the checkout ID in a temporal table, in the database

 

So if something goes wrong when requesting the information, I still have the checkout id to process it again

View solution in original post

Login to Me Too
2 REPLIES 2

SirHaplo
New Community Member

I'm struggling in the same situation.

It could happen on mobile, switching trought apps, before the completition.

Or closing a tab on desktop.

 

What could i do to stop this or to recover lost confirmation ?

Login to Me Too
Solved

geemsolutions
Contributor
Contributor

I saw your message too late.

 

What I did was:

 

1) Add a loading screen so the user doesn't click away during transaction

2) Before even processing the Paypal sale information I saved the checkout ID in a temporal table, in the database

 

So if something goes wrong when requesting the information, I still have the checkout id to process it again

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.