How to get details of an express checkout - PayPal / Postman - node.js

I'm trying to get the details of payment after test an express checkout.
When I go to
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-0CS36485JR5738828
It shows the checkout and I click on confirm.
After that, I'm being redirected to http://return.url/?paymentId=PAYID-MHKJM6A3W026542BR076654N&token=EC-0CS36485JR5738828&PayerID=HUGNJ49ZGF8CU
Here I have the paymentID, but I can't find an endpoint to see the details of that payment.
And I have a Webhook too with the event Checkout checkout buyer-approved, if I simulate an event, the webhook responds and sends the data to my backend, but it doesn't do it when I do an express checkout.
Now I'm trying almost everything with Servistate (Postman-like), but the idea is to make an express checkout, and confirm that payment on the backend.
Note: On my backend, I'm using paypal-rest-sdk package to generate the payment and with that, the checkout url

The PAYID token was created using the v1/payments API.
Use that API to get the status of the payment.
Note that the v1/payments API is deprecated, you should use the v2/checkout/orders API for payment processing instead. See the current PayPal Checkout documentation, and be sure to read through the 5th bullet in 'Add and modify the code' which discusses a server integration.

Related

How do I know if a payment is successfull in stripe

I have integrated the stripe Api in my website to process payments and It is working fine. The only problem is that after the a successfull payment, i don't get any response or an object to know if the payment is successful or not.
Stripe does process the payment and everything is fine but the question is how would I know that it is successful after stripe redirects the client to the success url ?
You can implement webhook in your application. After a payment is completed stripe will call webhook/callback of your application with the payment_status and other details. Have a look at documentation here Triggering actions with webhooks
Using webhooks and events is definitely the right way to go. You can listen for successful payments, failed payments, and other event types, then add some server code to take some action based on those events.
There's a mention of webhooks in Stripe's custom payments quickstart guide: https://stripe.com/docs/payments/quickstart#use-webhook
They also have a standalone webhooks guide: https://stripe.com/docs/webhooks/quickstart

How to process payment on the backend side using Stripe?

I am new to Stripe and payments in general. I've found few articles on the internet with the examples and guidelines eg. this one. As i noticed the algorithm for creating the payment looks like this:
Client app fetches the publishable Stripe key from the server
Server application creates the checkout session, client app fetches the checkout session id using retrieved publishable key
Client app redirects to checkout
User finishes the payment and being redirect back to client app
Please correct me if i'm wrong. In general i don't understand one thing - how the server application knows that the payment is completed successfully or not? Should i redirect the flow from stripe checkout to backend first, process the result and the from the backend call the frontend again? Or should i somehow use the checkout session to check has it been completed? Shall i use some kind of cron then to process pending checkout sessions? Thanks in advance for any help. Regards
Basically, what you lay out is viable. You can check the Session status when the client is directed back to your server, but you will want to check this status at least one other way, either via a webhook or the cron job you mention.
Should i redirect the flow from stripe checkout to backend first, process the result and the from the backend call the frontend again?
This is possible. Stripe allows you to add the {CHECKOUT_SESSION_ID} template parameter to your Checkout's success URL, when the user is redirected after their checkout, that template will be replaced with the actual Checkout Session ID which you can use to retrieve the Session and its status.
That being said, it is possible for a Customer to make a payment but have their connection cut out before navigating back to your page. So, if you rely on that redirect the customer will be charged but you will never know to fulfill their order. That leads to unhappy customers so Stripe typically recommends setting up a webhook endpoint on your server[2] so that they can send you a checkout.session.completed event to notify you that the customer has finished their Checkout Session. That way, even if a customer never gets to your success page, you will know to fulfill their order.
[1] https://stripe.com/docs/payments/checkout/custom-success-page#modify-success-url
[2] https://stripe.com/docs/payments/checkout/fulfill-orders

How do i make payment paytm using react js i have already build api in spring boot

I am trying to integrate paytm payment in my web app. i am following Paytm payment gateway
Till step two it's working fine. but at step three i am not able to post request with paytm URL by using react js --"Customer fills payment details and completes the payment authentication. Once the payment is complete, response is posted as HTML form POST on your app/website's callback URL"
How do i do this in react js only.
You should handle the call back response through backend as checksum need to verify. Also do the status query from backend before showing the success response to user

How to integrate Paypal with node js into REST way

I need to integrate paypal with node js ( first time ). But node js working as REST server with frontend built on mobile ( Android and iOS ). I think purpose of using return url and cancel url for web based frontend not for mobile.
Previously I implemented Stripe payment gateway which have simple system which generate a auth token on mobile and mobile sent this token to Node Js Rest API. So not node js application have buyer auth token and it process the required payment.
But I am very much confused how Paypal achieve same scenario.
UPDATE : I am using paypal official node js package https://github.com/paypal/PayPal-node-SDK
UPDATE : After more search, I see some steps in payment flow
User paypal payment create API into my REST API to get "payment id" and links.
Hit on approval_url link which used for fullfill buyer information on paypal site. After completion, Paypal hit automatically described return url in first API, along with payment id and payer id params.
In Return API, use payment id and payer id params to paypal payment execute API.
If all above is actual process to generate payment, Then I am assuming that Backend API only needed third Step which API url could be shared with mobile developer in their integration of paypal.
So Mobile will
create payment
Fill Buyer information
While Paypal automatically hit return url where backend API will execute payment.
If this is the recommended ( or only ) way to paypal integration with mobile and rest apis ?
The purpose of return and cancel url is to notify the client(mobile or web) for potential user action, if user completes payment then via return url and if user cancels payments via cancel Url
You can use rest or nvp PayPal will support both, they have rest endpoints which you can use to complete the transaction.
https://github.com/santhoshlfms/Android_PayPal_EC_NodeJs_Server_Sample (Node server)
https://github.com/santhoshlfms/Android_PayPal_EC_CustomTab_Demo (Mobile Front end)
you can follow these repo to figure out how to proceed.

Stripe and validate payments synchronously

I am integrating Stripe in my site and I have the following question. I have read in the official documentation that is needed to use Payment Intents / Checkout to accomplish with 3d secure payments but my doubt is: How can I validate a payment made through this methods in a synchronous way to allow customers to instant download a product without waiting to the webhook call?
I am using Symfony to build the front and the back of the system.
thanks
You don't need to wait for a webhook to get confirmation that a payment was successful. stripe.handleCardPayment will immediately tell you if the payment was successful or not. See the then promise fulfillment here.
If you're using new Checkouts, users will be directed to your payment success page on completion of payment. A webhook is sent to inform you of the payment completion in case the user closes the browser or tab before the redirect can happen.

Resources