Posts tagged with stripe-payments

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])

I have a Ghost newsletter that has a premium subscription set up with Stripe.

Basically, people go to the /subscribe page, choose a price, get redirected to Stripe, and then upon success, get redirected to the main page /, where the url will now have this appended:

?stripe_portal=success

I want to track Google Adwords conversions when the purchase is made.

I don't know how to do that, as conversion code on the main page would also count normal visits.