Mike
Mike

Reputation: 381

Stripe Elements - Payment Updates Database

I am currently integrating Stripe Elements into my ReactJS app. What I am developing is a system in which my users can upload an image to display as an advertisement on my web app for 30 days. This means that a payment needs to update a row in my database with a new expiration date. We are also having the users manually renew each expiration period so we are not using subscriptions.

From what I understand, the flow is as follows for a first time customer:

  1. User goes to the advertisement upload page

  2. The user submits the advertisement form. Client sends POST request to my API server and creates payment intent with NodeJS Stripe SDK

    • Advertisement is saved into DB with an expiration date of null.
    • Payment Intent ID is saved to relationship table associating it with the banner advertisement
    • Payment Intent secret is sent to client with status OK
  3. Client Secret is given to Elements to show and handle the payment form

  4. Stripe sends the event to my webhook endpoint with Payment Intent ID.

    • Use Payment Intent ID to find which banner advertisement should be updated with new expiration date

From what I've read on the docs, this flow should work. If anyone notices issues, please let me know!

My question is: can I show the user their next advertisement expiration date right after their purchase? Or do I need to show them "Pending" until my webhook receives the event?

Thanks in advance for any answers or advice!

Upvotes: 0

Views: 478

Answers (1)

toby
toby

Reputation: 622

You can, but whether or not you should is primarily a business decision for you to make based on the customer experience you're hoping to achieve.

It will likely be influence by the exact integration path and payment method options that you're offering. If you're going to use the Payment Element with delayed notification payment methods, then you may want to wait for confirmation that the payment was successful.
https://stripe.com/docs/payments/payment-methods#payment-notification

But if you're using the Card Element(s) and only accepting cards, then part of the response from confirmCardPayment is the Payment Intent if the payment was successful so you have a more immediate indicator of success. https://stripe.com/docs/js/payment_intents/confirm_card_payment

Upvotes: 1

Related Questions