Skip to content

4 min read

Payments for streaming sites: access on confirmation

How a streaming site can sell passes and events by card or crypto, and grant access the moment a payment is final, never before.

A screen with a green play button over a track, its paid stretch solidA screen with a green play button over a track, its paid stretch solid
On this page

A streaming site sells access. A viewer pays for a day pass, a month of the catalog, or a ticket to one live event, and expects to be watching a moment later. The payment side has one job: tell your server, reliably and quickly, that the money is final, so it can open the door.

This post walks through how to build that with 402pay: one payment for each purchase, access granted on a signed webhook once the payment confirms, and a clear rule for every payment that doesn't arrive cleanly. The same design works whether the viewer pays by card, Apple Pay, Google Pay, or crypto.

What you're selling is a period of access

Most streaming products fit one of three shapes: a pass for a fixed period, a single live event, or a one-off unlock of a title or a collection. Each has a price and a clear start, which makes each a single payment.

402pay doesn't charge a card or a wallet on a schedule. A crypto payment is pushed by the customer, so nothing can be pulled from their wallet next month, and card payments here are taken one at a time as well. A renewal is therefore a new payment: your server creates it when the current pass is about to end and sends the viewer its link. Viewers renew on purpose, which also keeps you clear of subscriptions that are hard to cancel.

Fixed prices can be a link

If your passes have fixed prices and you don't need your own order ids, a payment link per pass works without code. The API is the better fit once access has to be tied to an account on your site, which is the case the rest of this post covers.

One payment per purchase

When a viewer chooses a pass, your server creates a payment for it and redirects them to the payment's url, the hosted checkout. Give it your own id as the reference, and anything you'll need to grant access in metadata.

Create a payment for a pass
curl -X POST "https://dash.402pay.co/api/v1/payments" \  -H "Authorization: Bearer $PAY402_SECRET_KEY" \  -H "Idempotency-Key: $(uuidgen)" \  -H "Content-Type: application/json" \  -d '{    "amount": "9.99",    "currency": "USD",    "reference": "pass_8812",    "description": "30-day pass",    "customer_email": "[email protected]",    "success_url": "https://example.com/passes/pass_8812",    "metadata": { "viewer_id": "v_2041", "plan": "30d" }  }'

A reference names one live payment, so creating the same one twice, after a timeout or a double click, returns the existing payment rather than a second one. If the viewer closes the tab and comes back, opening the same url resumes the same payment. An API payment stays open until its expires_at, 24 hours unless you set it, so a pass ordered today can't be paid next week at today's price.

Grant access on the webhook

After paying, the viewer is sent to your success_url. It's tempting to unlock the pass on that page. Don't: anyone can open the URL, and a viewer can reach it before their payment is final. The success page should show the pass as confirming and read its state from your own database.

The signal to act on is the payment.succeeded webhook. It arrives once the payment has confirmed on its network, signed so your server can verify it came from 402pay (our post on webhook signatures shows how). Answer within 15 seconds and do slow work afterward; a delivery that fails is tried 8 times over about 28 hours, so the same event can reach you more than once.

Activate a pass on payment.succeededNode.js
import { Webhook } from "standardwebhooks"; const webhook = new Webhook(process.env.PAY402_WEBHOOK_SECRET); app.post("/webhooks/402pay", express.raw({ type: "application/json" }), async (req, res) => {  let event;  try {    event = webhook.verify(req.body, req.headers);  } catch {    return res.status(400).end();  }  if (event.test || (await seen(req.headers["webhook-id"]))) return res.status(204).end();   if (event.type === "payment.succeeded") {    // The pass starts when the money is final, not when the order was placed.    await activatePass(event.data.reference, event.data.confirmed_at);  }  res.status(204).end();});

Two details in that handler matter for access. The payment's confirmed_at is when the money became final, so a 30-day pass counted from it gives the viewer their full 30 days however long their network took. And deliveries you've already handled, by their webhook-id, are skipped, so a retry never stacks a second month on the first.

A timeline from the viewer ordering a pass and paying, to the network confirming the payment and the pass ending, with the pass period highlighted from confirmation to its end.A timeline from the viewer ordering a pass and paying, to the network confirming the payment and the pass ending, with the pass period highlighted from confirmation to its end.
The pass starts when the payment confirms, not when the viewer pays. A slow network costs the viewer nothing.
Open the door on the confirmation, and start the clock there too.

How long viewers wait

A payment confirms once its network has added enough blocks on top of the transfer that it can't be undone. Checkout shows the transfer as soon as it's seen and counts the confirmations for the viewer. Typical times, for the counts checkout runs on:

Solana2 confirmations, usually about 10 seconds.
Base6 confirmations, usually about 12 seconds.
Ethereum2 confirmations, usually about 24 seconds.
Tron1 confirmation, usually about a minute.
Litecoin2 confirmations, usually about 5 minutes.
Bitcoin1 confirmation, usually about 10 minutes.

For a viewer who wants to watch something tonight, stablecoins on Solana or Base feel close to instant. Bitcoin is slower by design, and a transfer sent with a low fee can wait longer still. You choose which coins and networks checkout offers in Settings, so if your audience mostly buys short passes, it's reasonable to lead with the fast ones.

Card payments follow the same path. Once the card is approved, the payment is delivered to your wallet as crypto, and payment.succeeded fires when that deposit confirms, so a single handler covers every way a viewer can pay.

When a payment isn't clean

Every payment ends in a status, and each status maps to one decision about access:

payment.succeededPaid in full, or accepted by you. Activate the pass.
payment.underpaidShort by more than your tolerance (0.5% by default). Keep the pass locked; checkout asks the viewer for the rest.
payment.overpaidArrives alongside payment.succeeded. Activate on succeeded only, and return the extra if you choose.
payment.needs_reviewA transfer that arrived after the quote expired, or on another network. Hold the pass until you accept or return it.
payment.expired or payment.failedNothing arrived, or the payment was canceled. Release the order and let the viewer start again.

Accepting an underpaid or late payment, in the dashboard or through the API, fires payment.succeeded, so your handler activates the pass without a second code path.

Renewals, refunds, and the viewer's account

A few practices keep access clean over months rather than one purchase:

  • Create the renewal payment a few days before a pass ends and email its link from your own system. 402pay doesn't email your customers, so the reminder is yours to send.
  • Pass the viewer's email as customer_email. Checkout then doesn't ask for it, and every payment from the same viewer is grouped under one customer in your dashboard.
  • Refunds are a send from your wallet, in the coin and amount you choose. End the pass on your side when you send one.
  • Describe each pass clearly in its description. It's what the viewer sees at checkout and on their receipt, and it's the best defense against card disputes.

The streaming solution page summarizes what 402pay offers streaming sites, and the accept a payment guide covers the full API flow.

Common questions

  • On the payment.succeeded webhook, which arrives once the payment has confirmed on its network. The success URL a viewer is redirected to isn't proof of payment, since anyone can open it.
  • No. Each pass is its own payment. Your server creates a renewal payment when a pass is about to end and sends the viewer its link.
  • It depends on the network: about 10 seconds on Solana, about 12 seconds on Base, about 24 seconds on Ethereum, about a minute on Tron, about 5 minutes on Litecoin, and about 10 minutes on Bitcoin. Card payments are delivered as crypto and confirm the same way.
  • A shortfall within your underpayment tolerance, 0.5% by default, counts as paid in full. A larger one marks the payment underpaid, and checkout asks the viewer for the rest before access is granted.

See what 402pay can do for you.

Discover how 402pay helps your business accept any card and get paid in crypto, straight to a wallet you control.