How do I know if a payment is successfull in stripe - node.js

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

Related

Getting Payments Alert from Stripe without Webhook

The default way for third party clients to be notified when a payment has happened on stripe is mostly via Webhooks. However, I do not want to stress my users by giving them a webhook url to paste in their stripe dashboard to be notified when payment has happened. I want to simplify the process for them. Is there an alternative flow?
I'm looking at something similar to Sign In With Google once they authenticate the app against their stripe dashboard, payment alerts can be seemlessly retrieved.
Going through the Stripe connect Docs and I'm not sure Connect can be used to achieve this. I stand to be corrected though.
I need to implement this in NodeJS.
Any insights would be really appreciated.
Thank you.
It's not entirely clear what you're trying to achieve, but it sounds like you're operating as a platform and want to send some message to your users (who are Stripe account holders) to notify about payments.
You can do this using Connect webhooks to listen for payments on those connected accounts, eg by listening for payment_intent.succeeded or what is relevant for your integration.
You, as the platform, would set up a webhook to listen for these events, then you can use whatever communication channels you prefer with your users to notify them (eg: email, SMS, in-app notification etc)

SaaS application using stripe - charge customers card before completing signup?

We are using Stripe subscriptions to handle payment for a SaaS application we are building
Currently, our development team has implemented the following logic:
User enters card details into Stripe elements UI as the final step of signup to our app.
If the credit card is deemed valid by Stripe Elements, the signup process to our app completes successfully.
A stripe customer & subscription is created.
Our server processes the webhook from stripe to confirm if the initial payment succeeds/fails
The problem we have is that the customers card isn't being charged until after the signup process to our app is complete. In some cases this results in a poor user experience, where the user is told by our signup process that they have signed up successfully, then they receive a 'payment failed' email from our software if the stripe charge doesn't succeed.
What is the best way to handle this signup flow? Since we are relying on the stripe webhook to tell us if the charge has succeeded - a suggestion has been made that we could monitor for the webhook response (eg. every 1 second, in a loop) and confirm payment has succeeded before completing the user signup for our app. The flow would then become:
User enters card details into Stripe elements UI as the final step of signup to our app.
If the credit card is deemed valid by Stripe Elements, we create the stripe customer / subscription
Monitor (in a loop) for a response from the Stripe webhook to confirm if payment was successful
The signup process to our app completes successfully (if charge is successful), or fails if the charge is unsuccessful.
This also seems like a bandaid solution - what is the best way to handle our issue?
I have noticed there is an option to use 'pre-authorisation' of a card, but I'd prefer not to go down this road if it leads to extra items on a customers bank statement.
This seems like something that would be very common - we would greatly appreciate any advice
Thanks
The most straightforward solution seems to be that your integration isn't waiting for the payment to complete.
With Subscription, you can wait synchronously on your backend for a status: active on your backend, before returning a response to your frontend. You don't even need to poll for the webhook response, cause your backend creates a Customer, creates a Subscription, and returns that response to your frontend, to show an error or success.
(waiting for webhooks is good but when your integration is manually starting the Subscription, you don't necessarily need webhooks)
From the frontend perspective, your user sees a loading spinner, until your backend is able to say "payment successful, you are signed up!"

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.

Paypal integration with Paypal IPN

Need some help for Paypal integration. I did all the configuration what is mentioned in the documentation like: Paypal gateway URL, Return URL (Success), and Notification url (~/CMSModules/Ecommerce/CMSPages/PayPalIPN.aspx). But my order status is not updating even after the successful payment.
Using sandbox account for testing
Able to redirect to Paypal page (Sandbox account) and on completion of payment, successfully redirected back to site (thank you page) configured as Return URL in settings
Below is the sample return URL from after succesfult payment
/ConfirmPaypalPayment.aspx?amt=5.00&cc=USD&cm=en-US&item_name=Order%20ID%3A%201177&st=Completed&tx=83L5281177755044V
How can I make sure PaypalIPN is executed properly,
what else I need to do/check other than what I mentioned above.
Can we debug the the code PaypalIPN.asps.cs
Is there any webpart I need to add on the thank you page(ConfirmPaypalPayment)
I am testing this in my local site with Sandbox account
Please suggest.
Thanks,
Sharath
Documentation says: The default Kentico PayPal provider does not utilize payment notifications – Webhooks or Instant Payment Notification (IPN). If you require payment notifications for any custom functionality or integrations, you need to configure the related options for your PayPal Business account and implement the required handlers (either within the Kentico web project or a custom project).
The return page(thank you page) must contain the PayPal payment execution web part, which processes the payment URL parameters provided by PayPal and completes transactions.
So there is no IPN in the default payment flow, if you want to use IPN take a look at Creating a custom payment gateway. There is there an explanation and a code sample.

Recurring payments IPN

Working on implementation of paypal's recurring payments, I've got encountered some problems. I have followed paypal's documentation from here:
PayPal Express Checkout: Recurring Payments Process Flow
It seems that everything works properly and I get ProfileID at the end (from result of CreateRecurringPaymentsProfile() query). Recurring profile is also being created.
The problem is there's no IPN confirmation after running CreateRecurringPaymentsProfile() , but according to:
PayPal Express Checkout: PayPal Notifications - it should be.
From my experience this happens only when IPN (Instant Payment Notifications) are not enabled in your merchant account. You can enable IPN in Profile > Instant Payment Notification Preferences.

Resources