I was using the react-paypal-button-v2 for quite some time just fine, but as of about a few days ago, I tested my store making a test purchase and it no longer worked. I learned that the functions actions.order.create and actions.order.capture() had been deprecated so maybe this implementation is just no longer working now as I did see its using v1.
I have spent the last 2-3 days implementing @paypal/react-paypal-js.
I am able to create an order hitting my backend server from createOrder callback in the PayPalButtons component to /api/order where I make the request on the server to the API at /v2/checkout/orders.
I get a response with two links one is where you are to redirect the user to approve their payment (payer-action). I go to that link in a new tab, login to a sandbox account and proceed to complete payment. It redirects to the redirect url.
I take the created orderID and past in in the JSON body in postman it hits another server endpoint I called /api/capture.
onApprove callback calls my server at /api/capture where I make a request to /v2/checkout/orders/{id}/capture where that orderID is put in the path.
The documentation says no request body is required, however doing so results in an error, so putting a request body works and I supply the same request body that is shown as required in the create orders documentation.
The result of submitting this request is PAYER_ACTION_REQUIRED status.
But I thought redirecting to the payment link, where the payer “approves” of payment is where the payer action takes place, so why am I being asked this again? I am expecting a status of COMPLETED.
I tried reading many stack overflow questions and answers as well as the PayPal community questions and answers revolving around this issue. Nothing helped.