Dynamically Return Stripe Order Amount
I'm attempting to retrieve the total order amount on a Stripe charge. It's different for every order. I need this value for Google Ads Dynamic conversions. My Question: How to I retrieve/return the order value after a payment?
//Stripe Payment Backend app.post('/create-checkout-session', async (req, res) => { const session = await stripe.checkout.sessions.create({ line_items: [ { // Provide the exact Price ID (for example, pr_1234) of the product you want to sell price: 'price_mypriceID', quantity: 1, }, ], mode: 'payment', success_url: `${YOUR_DOMAIN}/dashboard?success=true`, cancel_url: `${YOUR_DOMAIN}/dashboard?canceled=true`, }); res.json({url: session.url}) });
This code runs on a successful payment, triggering a Google Ads Conversion.
if (location == "?success=true"){ window.gtag('config', 'AW-myaccount'); window.gtag('event', 'conversion', {'send_to': 'AW-myaccount', 'value': {needToReturnDynamicValueHere}, <--------- This 'currency': 'USD' }); }, [location])