(Unfortunately, after a long research I could not find the answer for my question in stackoverflow).
I am currently integrating the PAYPAL REST API V2 in an e-commerce application and in principle it works fine, but not the way it is supposed to.
According to the documentation I am using the following steps:
Create order with user data and purchase details in the backend (nodejs)
Upon successful order creation, the front-end receives the approve_url and capture_url
The user is redirected to the approve_url and login with its credentials, and in case it is successful, the user is redirected to the predefined return_url (which is defined in the step 1)
If the user agrees with the order, the capture_url is manually called at the end of the checkout and the corresponding amount is transferred.
Since the data returned by the order is not persistent (url is being redirected), I am saving the order id and the capture_link in the local storage, which I don't think it is correct. Therefore, I have two questions:
Upon successful approval of the purchase, is it possible to redirect the user directly to capture?
If not, how can I get the order_id details in the return_url?
Thanks in advance
I figured out that the order Id was being appended to the return_url automatically. The misleading thing was that it was named token instead of order. With the order already approved by the user, I was able to complete the transaction without having to redirect the user again to the front-end.