The club's treasurer collects the 40 dollar yearly dues by bank transfer and in cash, and she keeps a spreadsheet of who has paid. Every spring she spends two evenings matching payments to names, and this year eleven members who say they paid are still marked unpaid. She asks you whether members could pay on the site, and whether the club's T-shirts and caps could be sold there too. You want to say yes, but you do not want a site you built with an AI tool to hold your members' card numbers.
Your site never has to hold a card number. A payment company is a business that takes card payments for you. The buyer types their card number into a page that belongs to the payment company, the payment company charges the card, and it pays the money into your bank account after keeping a fee. This course uses Stripe. In this chapter you connect a payment company to the site, charge the yearly membership and sell two shop items, test all of it without real money, and make sure that only members who have paid get access.
Who does what when a member pays
A payment involves three parties: the member, your site, and the payment company. These are the steps, in order.
Your site gives access at step 4, when the payment company’s message arrives, and not at step 5.
- The member clicks Join on your site.
- Your site sends the member to the checkout page. A checkout page is a page run by the payment company where the buyer enters their card details. It shows your club's name and the price, but it is the payment company's page, so the card number never reaches your site.
- The member pays. The payment company charges the card.
- The payment company sends your site a message that the payment succeeded. This kind of message, sent from one service to another when something happens, is a webhook. When the message arrives, your site marks that member as paid in the database, and the member-only pages from Add accounts and member-only pages open for them.
- The payment company sends the member back to your site, to a page that thanks them.
Steps 4 and 5 look as if they do the same job, and they do not. Your site gives access at step 4, when the message arrives. It does not give access at step 5, for two reasons. A member can pay and then lose their internet connection before the thank-you page loads, and they would have paid without getting access. And a thank-you page has an address like any other page, so a person who has not paid can open that address directly.
Your site gives a member access when the payment company's message says the payment succeeded, and not when the member arrives back at your site. The message is sent for every payment, and only the payment company can send a real one.
Check that each message really came from the payment company
The address on your site that receives these messages is public, so anyone can send a message to it, including a fake one that says "this member paid". The payment company gives you a way to tell a real message from a fake one. It gives you a secret, called a signing secret, and it signs every real message with it. Your site uses the same secret to check the signature on each message and ignores any message that fails the check.
To make the check work:
- Keep the signing secret where your other secrets are, in the
.envfile on your laptop and on the Environment Variables screen at your host. - Tell the agent to check the signature first. Use these words: "Verify the signature on every webhook before doing anything with it, and show me the line where that happens."
- Expect the same message more than once. If your site does not answer, the payment company sends the message again, so a message can arrive twice. Ask the agent to make the site record each message it has handled and skip any repeat.
Set up a yearly membership and one-time purchases
The club sells two kinds of thing, and the payment company handles them differently.
- The membership is a subscription. A subscription is a payment that repeats on a schedule until someone cancels it. The membership charges 40 dollars once a year. Each year the payment company charges the card again and sends your site a message saying whether that payment succeeded or failed, and your site extends the member's access or ends it.
- The T-shirt and the cap are one-time payments. The buyer pays 25 dollars for a shirt or 18 dollars for a cap, once. The club hands these out at the weekly run, so the shop does not need delivery addresses or shipping.
In the payment company's dashboard you add each thing you sell, with its price and whether it repeats. The checkout page then shows the right amount for each one.
Members also need a way to cancel. The payment company provides a page where each member can see their subscription, change their card, and cancel, and you link to it from the member's account page. When a member cancels, the payment company sends your site a message, and your site ends their access when the year they paid for runs out. What the law requires of a sign-up and a cancellation is covered in The law of what you sell: accessibility, subscriptions, and the app stores.
Test every payment without real money
Test mode is a practice copy of your account at the payment company, in which no real money moves. Stripe calls it a sandbox. In test mode you pay with a card number the payment company publishes for testing, 4242 4242 4242 4242, with any expiry date in the future and any three-digit security code.
The two modes have separate keys and separate records, so a payment made in test mode never charges a real card.
Test mode and live mode each have their own keys. Your site uses the test keys on your laptop and in the preview copies your host makes, and it uses the live keys only on the live site, the split you learned in Environments: why it works on your machine and breaks online. You can create the account and test before you give the payment company your business and bank details. It asks for those when you switch to live mode.
Run these tests in test mode before you switch:
- Join as a new member. Pay with the test card, and check that the member is marked as paid and the member-only pages open.
- Pay, then close the tab at once. Close the browser tab as soon as the payment goes through, before the thank-you page loads. The member should still be marked as paid, because your site marks them as paid when the message arrives.
- Open the thank-you page without paying. Sign in as a member who has not paid and paste the address of the thank-you page. That member should get no access.
- Cancel. Cancel the test membership, and check that the site records the date on which access ends.
- Buy a shirt and refund it. Check that the order appears, then refund it from the payment company's dashboard and check that your site shows the refund.
In test mode you can run every payment, cancellation, and refund with a test card, and no real money moves. Switch to live mode only after all five tests pass.
What the payment company keeps, and what a refund costs
The payment company keeps a fee from every payment. For a card payment in the United States, Stripe keeps about 3 percent plus 30 cents, and a little under 1 percent more when the payment is a subscription. On a 40 dollar membership that comes to a little under two dollars.
A refund gives a buyer their money back. You start it from the payment company's dashboard, and the money goes back to the card the buyer paid with. The fee from the original payment is not returned to you, so a refund costs you that fee.
A dispute is different. It happens when a buyer tells their bank that they did not make a payment or did not get what they paid for. The payment company takes the disputed amount out of your balance and holds it until the bank decides, and it charges you a fee for each dispute. You can avoid many disputes by using a name on the card statement that members will recognize, and by replying quickly when a member writes to help@runclub.example.
One more thing to settle before you switch to live mode is sales tax. Whether you have to collect it on a membership or on a shirt depends on where you and your buyers are. The payment company has a tool that works out the amount, but deciding whether you owe it is your job, and it is worth one conversation with an accountant.
The obvious objection: a payment link and a spreadsheet would be simpler
They would be, and for a club with a dozen members that is a fine way to start. The payment company can give you a link to a ready-made checkout page, with no code at all. You send the link to members, and you tick each one off by hand when the payment appears in the dashboard.
That stops working for the same reason the treasurer's spreadsheet did. Someone has to match every payment to a member, do it again at every renewal, and remove access by hand when someone cancels. When that work takes hours or starts producing mistakes, let the site do it, using the steps in this chapter.
What happened when shops' software skipped the check
In September 2026 a security flaw was published in a plugin that online shops use to take card payments through Stripe on WordPress sites. The plugin was supposed to check the signature on every message from the payment company. On a new installation the shop owner had not yet saved the signing secret, and in that state the plugin skipped the check and accepted any message. A stranger could send the shop a fake message saying that an order had been paid, and the shop would mark the unpaid order as paid. Every version of the plugin up to 5.0.8 had the flaw.
What you can do now
You can explain who does what when a member pays, and why your site never sees a card number. You can set up a yearly subscription and one-time purchases, test them without real money, and check that access depends on the payment company's message and on nothing else. You also know what a payment costs you, what a refund costs you, and what to settle before you take real money.
Try it now
This drill takes about twenty minutes, and you spend nothing on either path. An account at the payment company is free to create, and test mode uses no real money.
No setup: Start to buy something small from a small online shop, and stop at the page where you would type your card number. Read the address bar on that page and note whose page it is. Many small shops send you to a page run by a payment company. Then find the receipt for a subscription you already pay for, in your email, and look for the way to cancel it. Write down who took the payment, and whether you can cancel on a page yourself or have to write to someone.
With your tools: Create an account at the payment company and stay in test mode. Then open Claude Code in the running-club folder, or in your own project, and type: "Add Stripe payments in test mode, using Stripe's own checkout page. Sell a yearly membership at 40 dollars as a subscription and a T-shirt at 25 dollars as a one-time payment. Mark a member as paid only when a webhook with a verified signature says the payment succeeded, and end their access when the subscription ends. Show me the line where the signature is checked." Then run the five tests from this chapter with the test card. Codex and Cursor accept the same request in their chat panels. If nothing is installed yet, The Setup Clinic covers the install.
Either way, finish by adding these lines to the idea file. If you took the first path, write them for the shop and the subscription you looked at.
Payments: taken on the payment company's checkout
page; the site never sees a card number
Sells: membership, 40 dollars a year, repeating;
shirt 25 and cap 18 dollars, one-time
Access: given when a verified message says paid;
ended when the subscription ends
Tested: in test mode, five tests, none with real money
To do: settle sales tax before live mode
Chapter Summary
- A payment company takes card payments for you. The buyer types their card number on the payment company's checkout page, so your site never sees or stores it.
- When a payment succeeds, the payment company sends your site a message, called a webhook. Your site gives access when that message arrives, and not when the member arrives back at your site.
- Anyone can send a fake message to your site, so your site checks the signature on every message with the signing secret and ignores any message that fails.
- A subscription is a payment that repeats until someone cancels it. The membership is a subscription, and the shirt and the cap are one-time payments.
- Members cancel on a page the payment company provides, and your site ends their access when the year they paid for runs out.
- Test mode is a practice copy of your account in which no real money moves. It has its own keys and a published test card, and you run every test there first.
- The payment company keeps a fee from each payment, about 3 percent plus 30 cents for a card payment in the United States, and it does not return that fee when you refund a payment.
- In a dispute, a buyer asks their bank to take a payment back, and the payment company charges you a fee. Replying quickly to members avoids many disputes.
- Settle sales tax before you take real money.
- Your artifact is the idea file, which now has five lines about payments: where the payment is taken, what you sell, when access is given and ended, how you tested, and what you still have to settle before live mode.
- The next chapter is Turn your site into a phone app, and decide about the app stores, where you make the site work like an app on a phone.
Sources
- Stripe documentation on fulfilling orders from Checkout, on webhooks and checking their signatures, on subscription events, on the customer portal, on testing and test cards, on sandboxes and live mode, on API keys, on refunds, on disputes and how to prevent them, on Payment Links, and on activating an account (last verified November 2026).
- Stripe pricing page, for the fees on card payments, subscriptions, and disputes (last verified November 2026).
- National Vulnerability Database, CVE-2026-9832, on the Payment Gateway of Stripe for WooCommerce plugin, published September 19, 2026 (last verified November 2026).