I have setup a front end using react that takes some data and will, with graphql, create objects in a aws dynamo database using amplify. I now have had to include stripe payments into the application. Once a user enters data I would like to charge them using stripe, then once a successful payment has been made I would like to use the data they provided on the react inputs to create a corresponding item in the dynamo database (only if the payment was successful).
I have setup a stripe webhook to hit a lambda function which has access to the graphql api so can create an object in the DB I just cant think how to get the object built from the react front end to be included so it can be used to build the object in the Dynamo DB?
What would be the best way to go about this? Thanks :)
The way I see it, you have two options depending on the type of data provided via the React inputs (I believe the second option will work better to keep you flexible):
From the documentation:
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
const stripe = require('stripe')('sk_test_CGGvfNiIPwLXiDwaOfZ3oX6Y');
const intent = await stripe.paymentIntents.retrieve('{{PAYMENT_INTENT_ID}}');
const latest_charge = intent.latest_charge;
The main limitation is, per the documentation,
You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long
And most importantly, do not store sensitive or PII data here.
fulfilled
and set it to false
.