Attribute Custom Checkout Revenue with Stripe PaymentIntent API
Attribute custom checkout payments built with Stripe Elements or mobile SDKs back to the original marketing channel using PaymentIntent metadata.
Make sure you've connected your Stripe account first.
With Stripe Elements or the mobile SDKs, pass the visit as metadata when you create the PaymentIntent on your server:
app/api/create-payment-intent/route.js
import { cookies } from "next/headers"
export async function POST() {
const cookieStore = await cookies()
const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: "usd",
metadata: {
datasense_visitor_id: cookieStore.get("datasense_vid")?.value,
datasense_session_id: cookieStore.get("datasense_sid")?.value,
},
})
return Response.json({ clientSecret: paymentIntent.client_secret })
}DataOwl attributes it when Stripe sends payment_intent.succeeded to the webhook it added. No other setup needed.