Skip to content

Stripe Elements and mobile apps

View as Markdown

Credit PaymentIntents from Stripe Elements, the Payment Element and Stripe's mobile SDKs to their visit through PaymentIntent metadata.

On this page

With Stripe Elements, the Payment Element, Express Checkout or Stripe's iOS, Android and React Native SDKs, your server creates a PaymentIntent and the client confirms it. Put the Reveata ids in the PaymentIntent's metadata when you create it, and Reveata reads them when the payment succeeds. Connect Stripe first with a restricted key or Connect with Stripe.

Add the ids

Send the ids from the page to the endpoint that creates the PaymentIntent, then store them as metadata:

js
// browser
const res = await fetch('/api/payment-intent', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ cart, ...window.reveata.metadata() }),
});
const { clientSecret } = await res.json();
// …mount the Payment Element with clientSecret and confirm as usual
js
// server (Node.js)
const paymentIntent = await stripe.paymentIntents.create({
  amount: 4900,
  currency: 'usd',
  automatic_payment_methods: { enabled: true },
  metadata: {
    reveata_visitor_id: body.reveata_visitor_id,
    reveata_session_id: body.reveata_session_id,
  },
});

Your server can also read the ids from the _dt_v and _dt_s cookies instead of the request body; Stripe Checkout shows the parser for Node.js, PHP, Python, Ruby and Go. reveata_user_id (the userId you pass to identify) works as a third key.

Mobile apps

A React Native or Expo app with the Reveata SDK has its own visitor id: send Reveata.metadata() from the app to the endpoint that creates the PaymentIntent and put it in the metadata, as on the web. Apps without the SDK don't have a visitor id; two ways still link their payments:

  • Identify the buyer. If people sign in on your website before installing the app, identify them there with the same userId or email they use in the app (Identify visitors). Put reveata_user_id in the PaymentIntent metadata, or make sure the Stripe customer has the same email. Reveata then credits the payment to that person's website visits.
  • A web checkout. If the app opens a checkout page on your website, that page runs the script and can pass window.reveata.metadata() as above.

Without any of these, app payments still count in revenue, as unattributed.

How Reveata counts PaymentIntents

  • A succeeded PaymentIntent is one payment, under its pi_… id. Its email comes from the receipt email, the customer or the billing details.
  • A PaymentIntent that pays an invoice (a subscription) is counted once, through the invoice. Put the ids on the subscription's first payment through Stripe Checkout, or in the subscription's metadata.
  • Refunds and lost disputes are booked against the original payment, as negative revenue on the day they happen, with the same source.
  • The webhook payment_intent.succeeded and the scheduled imports read the same PaymentIntent, and a payment is stored once per Stripe id. See Why payments are never counted twice.

Check it works

  1. Open your site in a private window from a link ending in ?ref=test.
  2. Pay with a Stripe test card, with a test key connected to a test website.
  3. In Stripe, the PaymentIntent's metadata shows reveata_visitor_id.
  4. In Reveata, the payment appears under Revenue with the source test.

Was this helpful?