Revenue (Stripe)
Connect
Section titled “Connect”- In Stripe, create a restricted key with read access to Charges, Payment Intents, Invoices, Balance
transactions and Disputes. Secret keys (
sk_…) are refused: they can do far more than read. - In Settings → Revenue (Stripe), paste the key and a webhook signing secret; add the webhook URL shown there to Stripe.
- The last 90 days are imported in the background; new payments arrive by webhook.
Keys are sealed with AES-256-GCM and bound to your site.
Attribute payments to visits
Section titled “Attribute payments to visits”Put the visit id into the payment’s metadata under the key px_visit_id. Stripe does not copy a Checkout
Session’s own metadata onto the payment, so use payment_intent_data for one-off payments and
subscription_data for subscriptions:
const visit = px('visitId') // send it to your backend with the checkout request// One-off paymentawait stripe.checkout.sessions.create({ mode: 'payment', // … payment_intent_data: { metadata: { px_visit_id: visit } },})
// Subscriptionawait stripe.checkout.sessions.create({ mode: 'subscription', // … subscription_data: { metadata: { px_visit_id: visit } },})With the Payment Intents API directly, set metadata: { px_visit_id: visit } on the Payment Intent.
px('visitId') returns the id only once the script has loaded (the inline stub returns undefined); read it
when the visitor starts checkout, not at page load.
The value is signed, so a forged id cannot claim revenue. A payment is credited to its visit if the visit began at most two days before (90 days for a subscription’s first payment); renewals follow the first attributed payment.
Reading it
Section titled “Reading it”Revenue, refunds, disputes, fees and net per settlement currency, net by channel and by day, in minor units.
API: GET /v1/sites/{id}/stats/revenue.