← All guides

SaaS and stores using Stripe Checkout · ~12 min

Connect Stripe to RevFast

Paste your Stripe secret key, let RevFast register the webhook, and send ros_visitor_id on every Checkout Session so each payment matches the visit.

  1. 01

    Step 1 — Install tracking on your live site

    RevFast must see pageviews before checkout. The tracker sets a first-party cookie named ros_uid — that value is how we tie a sale to the last visit. 1. Sign in to RevFast → Settings → Site. 2. Copy the script tag and paste it just before </head> on every public page (homepage, pricing, blog, app shell — not only checkout). 3. Publish or deploy your site. 4. Open the homepage in a normal browser window (not a blocker that strips cookies). 5. In RevFast, wait until tracking shows at least one pageview (usually within a few seconds). If ros_uid never appears, fix tracking before connecting payments. A webhook alone cannot guess which visitor paid.

  2. 02

    Step 2 — Connect Stripe inside RevFast

    1. RevFast → Settings → Payments → Stripe → Connect (or open this guide from the Stripe card). 2. In Stripe Dashboard → Developers → API keys (https://dashboard.stripe.com/apikeys). 3. Copy the Secret key: • sk_test_… while testing • sk_live_… in production Never paste a publishable key (pk_). 4. Paste the secret in RevFast and click Connect. RevFast registers webhooks on your public HTTPS app URL (https://revfast.app or NEXT_PUBLIC_APP_URL on self-host). • Click Connect — we call the provider API and register the webhook when the URL is valid https. • If auto-registration fails, copy the Webhook URL from Settings → Payments and add it manually in the provider dashboard. After Connect, RevFast shows your unique Webhook URL. Copy it if you add the endpoint manually in Stripe.

  3. 03

    Step 3 — Webhook in Stripe (if RevFast did not register it)

    Stripe only delivers webhooks to public https URLs. Option A — Stripe Workbench (recommended): 1. Stripe Dashboard → Workbench → Webhooks. 2. Create event destination → Your account (not Connect accounts). 3. Select events RevFast handles: • checkout.session.completed • payment_intent.succeeded • invoice.paid (subscriptions) • charge.refunded 4. Endpoint URL → paste the Webhook URL from RevFast (includes ?site= and ?key=). 5. Create → Reveal signing secret (whsec_…) → paste into RevFast if the field is still empty. Option B — Developers → Webhooks → Add endpoint (same events and URL).

  4. 04

    Step 4 — Pass the visitor id when you create Checkout

    Create Checkout Sessions on your server (never expose the secret key in the browser). Stripe metadata does not copy automatically between objects. Set ros_visitor_id everywhere your flow needs it: • One-time payment (mode: payment): session metadata AND payment_intent_data.metadata. • Subscription (mode: subscription): session metadata AND subscription_data.metadata. checkout.session.completed uses session metadata. payment_intent.succeeded uses PaymentIntent metadata only.

    // Read the RevFast visitor cookie (set by tracker.js on your marketing site)
    const ros_visitor_id =
      document.cookie.match(/(?:^|; )ros_uid=([^;]*)/)?.[1]?.trim() || "";
    
    const ros_session_id =
      document.cookie.match(/(?:^|; )ros_sid=([^;]*)/)?.[1]?.trim() || "";
    
    // One-time payment
    await stripe.checkout.sessions.create({
      mode: "payment",
      success_url: "https://yoursite.com/thanks",
      cancel_url: "https://yoursite.com/pricing",
      line_items: [{ price: "price_…", quantity: 1 }],
      metadata: { ros_visitor_id, ros_session_id },
      payment_intent_data: {
        metadata: { ros_visitor_id, ros_session_id },
      },
    });
    
    // Subscription
    await stripe.checkout.sessions.create({
      mode: "subscription",
      success_url: "https://yoursite.com/welcome",
      line_items: [{ price: "price_…", quantity: 1 }],
      metadata: { ros_visitor_id, ros_session_id },
      subscription_data: {
        metadata: { ros_visitor_id, ros_session_id },
      },
    });
  5. 05

    Step 5 — Run a test payment and check Revenue

    1. Use the provider's test mode (Stripe test cards, Polar sandbox, Razorpay test keys, etc.). 2. Complete a real checkout flow on your site — the same path a customer uses. 3. In RevFast, open Revenue (or Customers). Within a minute you should see the order amount next to the pages that visitor viewed. Still empty? • Open Settings → Payments and confirm the integration shows Connected. • In the provider dashboard, open Webhooks → recent deliveries. Look for HTTP 200 from RevFast, not 401/404/500. • Confirm checkout sent metadata.ros_visitor_id (or the provider-specific field in this guide) and that the buyer had ros_uid set before paying. • Ad blockers and cross-domain checkout (pay on another domain without the snippet) break attribution — keep checkout on the same site that runs the tracker, or pass the id explicitly.

  6. 06

    Common mistakes

    • Snippet only on the marketing site but checkout on another domain without passing ros_visitor_id. • Using publishable keys (Stripe pk_) instead of secret keys / API tokens. • Fulfilling on the browser "success" page instead of waiting for the webhook (always trust the webhook). • Polar / Lemon webhooks set to Slack or Discord format instead of Raw JSON. • Paytm webhook not on https port 443. • Stripe subscriptions missing subscription_data.metadata (only session metadata was set).

Install with AI

Paste into Cursor or Copilot — swap in your real Site ID first.

Connect Stripe Checkout to RevFast for last-touch revenue attribution.

1. Install RevFast tracker.js on every page; ros_uid cookie must exist before checkout.
2. RevFast Settings → Payments → Stripe: paste sk_test_ or sk_live_ secret key.
3. Webhook URL from RevFast → Stripe Workbench events: checkout.session.completed, payment_intent.succeeded, invoice.paid, charge.refunded. Signing secret whsec_ in RevFast.
4. On stripe.checkout.sessions.create, set metadata.ros_visitor_id and payment_intent_data.metadata.ros_visitor_id (plus subscription_data.metadata for subscriptions) from document.cookie ros_uid.

Related

Stuck? Email hello@revfast.app or open onboarding → Need help?