I have a React application where the client fills out a form to be saved to my database. The client then proceeds to make a Stripe based payment. Only after receiving the payment confirmation should the data be uploaded.
The form data includes multiple attributes such as follows
data = {
name: "Mike",
summary: "some long text",
...
}
The workflow would similar to the following:
Client fills out form -> Payment -> Payment confirmation -> Post-payment action (uploading the data from step 1)
I am aware of Stripe's webhooks as well as the line_items, but I was wondering if using the latter would be best practice as some of the attribute values in data can be quite long. Is there a more common approach to this case?
as some of the attribute values in data can be quite long.
What problem are you trying to solve? Prevent database overflow? Avoid sending large amounts of data in API requests? For both cases, it is suitable to create a temporary record in the database, which will be deleted when your webhook will catch the checkout.session.expired event (for example).
Stripe recommends that you handle any post-payment actions/fulfilment using their events with a webhook. In this case you'd listen for the payment_intent.succeeded event and create a webhook handler that saves the required fields/information fro the Payment Intent object to your database.