Payments with Stripe

Play this lesson

No store, so who takes the money?

When Hyper Shards is sold on Steam, Steam handles the payment. But our main home is our own website, where players install Hyper Shards as a PWA. No store is there to take the payment.

So the studio uses a payment provider: a company that safely takes card payments for websites and pays the money to the business. Ours is Stripe.

One card payment, step by step

Quick check

Which step checks that the card is real and has enough money?

  1. Our website's Buy button
  2. The player's bank, through the card network
  3. The studio's business bank account
Show the answer

The player's bank, through the card network

The bank that issued the card approves or declines the payment. Stripe passes the request along through the card network and reports back.

Why we never touch card numbers

Card numbers are a favorite target for criminals. Anyone who stores or handles them must follow strict security rules called PCI DSS.

Stripe Checkout is a hosted page: the player types their card details on Stripe's page, not ours. The numbers never reach our servers or our Firebase database. Even if our site were attacked, there would be no card numbers to steal. Stripe does the hard security work, which is a big reason studios use it.

Card details

Kai is building the Buy button for Hyper Shards. Where should players type their card number?

  1. A form on our own page that saves card numbers in Firebase
  2. Stripe Checkout, Stripe's hosted payment page
  3. An email to the studio with the card number in it
Show the answer

Stripe Checkout, Stripe's hosted payment page

On Stripe Checkout, card numbers go straight to Stripe and never touch our systems. Saving them ourselves, or emailing them, would put players' money at risk.

Two keys and a Checkout Session

Stripe gives us two kinds of API key, secret codes that prove a request comes from our studio:

When a player clicks Buy, our server uses the secret key to create a Checkout Session: the item, the price and the player's Firebase user id. Stripe replies with a link to its payment page. In test mode, the test card 4242 4242 4242 4242 runs on pretend money.

Spot the leak

shop.js
// shop.js runs in every player's browserconst PUBLIC_KEY = 'pk_live_51Hx9aQ...';const SECRET_KEY = 'sk_live_51Hx9aQ...';buyButton.onclick = () => {  location.href = '/api/checkout?item=hyper-shards';};

Kai wrote this browser code for the Hyper Shards Buy button. Which line must never ship?

  1. Line 2
  2. Line 3
  3. Line 5
Show the answer

Line 3

Anyone can read browser code with the developer tools, and the secret key can move money. It belongs only on the server, and a leaked key must be replaced (rolled) in the Stripe dashboard. The publishable key on line 2 is meant to be public.

Fees and payouts

At the time of writing, Stripe's standard fee for US cards is about 2.9% + 30 cents per payment. Fees vary by country, so check the latest.

The 30 cents is fixed, so small payments lose a bigger share. On a $1 sale the fee is about 33 cents, a third of the price. On $10 it is 59 cents.

Stripe pays the rest into our business bank account. The very first payout can take one to two weeks while Stripe checks the new account. After that, payouts arrive on a regular schedule, usually a few days after each payment.

Fee maths

stripe-fee.txt
Sale price               $10.00Stripe fee     2.9% + $0.30Fee                         ???Studio receives             ???

How much does the studio receive from this $10.00 sale?

  1. $9.71
  2. $9.41
  3. $9.70
  4. $7.00
Show the answer

$9.41

2.9% of $10.00 is $0.29. Add the fixed $0.30 and the fee is $0.59. $10.00 minus $0.59 leaves $9.41.

Who opens it, and where it works

A Stripe account is a legal contract, and laws require Stripe to check the identity of everyone it pays, to stop fraud and money laundering. So an adult opens it: you and a parent set it up together, connected to the company's tax number and business bank account.

Stripe is for our website. Most phone games use the store's own payment window for digital items. In some places, like the US and Europe, apps may now also link to a web shop, but the rules are still changing, so check the latest.

Bolt says: Next lesson: webhooks, how our server knows for certain that a player paid.

Fact-checked 9 October 2026