my-appengineer Courses

Assignment: run a full test subscription

Subscriptions with StripeAssignment90 min14 / 20

In this assignment you prove that billing works from the first click to the cancellation, entirely in Stripe test mode. Plan about an hour and a half. Nothing here costs real money.

Step 1: Stripe setup

In Stripe, in test mode:

  1. Create your product and at least two prices (for example monthly and yearly).
  2. Configure the customer portal (update payment method, invoices, switch plan, cancel at period end).
  3. Set your business details and invoice settings.
  4. Add the webhook endpoint for your app and copy its signing secret.

Step 2: keys in the right place

Put the secret key, webhook secret and price ids in your app's server-side settings (Apps → App hub → the app's card → Integrations). Then let Claude confirm nothing leaked into the code:

Ask Claude
Use my my-app.engineer workspace. Do not change anything. Search the code of [app name] for anything that looks like a Stripe key (sk_test_, sk_live_, whsec_, rk_) or a hard-coded price id. List file and line for every hit, and tell me which values should move to environment variables.

Step 3: run the test table

Run all seven tests from the lesson Adding Stripe to your app and fill in this table in your change log:

TestExpectedResultNotes
New subscriptionactive
3-D Secure cardactive after authentication
Declined cardno access change
Failed renewalpast_due + banner
Plan switchnew price stored
Cancelaccess until period end
Fake webhook400

Use Stripe's testing docs for the current test cards and for test clocks to simulate a renewal.

Step 4: check the logs

Ask Claude
Call get_app_health and get_app_logs for [app name]. Summarise every Stripe webhook the app received in the last hour, whether it was processed or rejected, and any errors. Change nothing.

Every event in your Stripe dashboard's webhook log should show a 2xx response. A 4xx or 5xx means your endpoint rejected or crashed on it; the app logs tell you why.

Step 5: write your billing runbook

One page, for future you:

  • where the keys live and how to roll them;
  • how to give a customer a manual refund or credit (in the Stripe dashboard);
  • what each status means for access in your app;
  • what to do when webhooks fail (check the Stripe webhook log, then app logs, then health).

Bookwise

All seven tests passed after one fix: the declined-card test showed a generic error page. The founder asked for a friendly message ("Your card was declined. Please try another card or contact your bank.") and re-ran the test. The billing runbook is half a page.

Your task

Complete all five steps and tick off the checklist. Do not switch to live mode yet; that happens in the launch checklist of module 4.

Checklist

  • I have a product and at least two prices in Stripe test mode
  • A test customer can subscribe through Stripe Checkout and lands back in the app with access
  • My webhook endpoint verifies the Stripe signature and is idempotent
  • A failed payment moves the account to past_due and the app shows a clear message
  • Cancelling in the customer portal removes access at the end of the period
  • No Stripe secret key appears in my code, repo or chat history

This course is general information, not personal legal, tax or financial advice. Rules, amounts and dates change: check the official source for your country before you act.