Trying to work with @paypal/react-paypal-js and I can't quite wrap my head around the documentation. I followed this tutorial:
https://github.com/paypaldev/PayPal-React-FullStack-Standard-Checkout-Sample/ using an express backend and made one-time purchases work on my website.
Then I've followed this guide for createSubscription: https://developer.paypal.com/docs/subscriptions/integrate/#3-create-payment-button
And seems like there's no need to capture the transaction as opposed to createOrder, does "onApprove" do it automatically?
Once I made the first subscription I tried the /v1/billing/subscriptions/ endpoint and got some useful links for devs in the reponse.
One of them being:
href: 'https://api.sandbox.paypal.com/v1/billing/subscriptions/I-CN85GKVK2872/capture',
rel: 'capture',
method: 'POST'
Is onApprove enough on its own? Is there any error handling I should be doing?
And seems like there's no need to capture the transaction as opposed to createOrder, does "onApprove" do it automatically?
There is no capture step for subscriptions. They will start after the user agrees (approves) them, without further action from you. The client-side onApprove callback occurs after this agreement.
If what you are searching for is how to have a reliable and timely server-side notification that a subscription has started, I recommend the dual process in this answer.