Soni
Soni

Reputation: 11

Implement payment flow using stripe in js

I'm new to working with stripe. I have a couple of questions.

I am working on implementing the payment flow on the website using Stripe. Here are the steps of my flow:

  1. When a customer lands on the login page, they provide their details and password and then click on the submit button.
  2. As soon as the customer submits the form, I create an account for that customer using their name and email, and then create a PaymentIntent for the customer in the background.
  3. Once the PaymentIntent is created, I show the payment page to the customer. This page contains information about the number of users, the Stripe payment element, and the amount. The user can change the number of users here, and the amount will be adjusted accordingly. At each instance when the number of users changes, I update the PaymentIntent object. Then, the user can enter their card details and click on Pay. 4.Upon clicking the Pay button, I confirm the PaymentIntent and save the current card information in Stripe so that I can use it for future transactions.
  4. After confirming paymentIntent I saved status of payment into database with customer.

Now, regarding handling payment failure cases, such as when a customer's payment fails or if a customer closes the window without completing the payment and then tries to log in again to our website, I have a question. Should I create a new PaymentIntent for the customer in these cases, or should I use the existing PaymentIntent? How to handle other cases if customer wants to add other card then want to retry?

Upvotes: 0

Views: 59

Answers (0)

Related Questions