Source: https://usedataowl.com/docs/stripe-payment-intent-api
Markdown source: https://usedataowl.com/docs/stripe-payment-intent-api.md
Description: Attribute custom checkout payments built with Stripe Elements or mobile SDKs back to the original marketing channel using PaymentIntent metadata.

# Attribute Custom Checkout Revenue with Stripe PaymentIntent API

> Make sure you've [connected your Stripe account](/docs/connect-payment-provider) first.

With Stripe Elements or the mobile SDKs, pass the visit as `metadata` when you create the PaymentIntent on your server:

```js title="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.**
