Setting up Stripe (card payments)
Customers pay by card with Stripe's PaymentSheet: cards, Google Pay and Apple Pay. Money goes to your platform's Stripe account. Providers get their share through Stripe Connect; see stripe-connect.md for that part.
Use test mode (sk_test_…, pk_test_…) while developing. Never put live keys in the repository, CI or a demo.
Without Stripe keys, only cash bookings are offered (config.features.card_payment is false).
1. Keys
- In the Stripe Dashboard, switch to Test mode.
- Go to Developers → API keys and copy the Publishable key and Secret key.
- In Admin → Settings → Integrations → Stripe, paste both. Test connection checks the secret key.
- Check the currency (Settings → Business → Currency) and country (Settings → Business → Country). Stripe must support that currency for your account.
2. Webhook endpoint
The API learns that a payment succeeded from Stripe's webhook. The app also asks the API to check with Stripe right after paying, so bookings update even if the webhook is late.
- Go to Developers → Webhooks → Add endpoint.
- URL:
https://YOUR-API-DOMAIN/api/v1/webhooks/stripe - Listen to Events on your account, and select these events:
payment_intent.succeededpayment_intent.payment_failedpayment_intent.processingcharge.refundedtransfer.reversed
- Copy the Signing secret (
whsec_…) into Admin → Settings → Integrations → Stripe → Webhook signing secret.
Each event is handled once. Stripe may send an event again, and the API stores processed event ids and skips repeats.
To test locally with the Stripe CLI:
stripe listen --forward-to localhost:8000/api/v1/webhooks/stripe
Put the whsec_… it prints into the setting.
3. How money moves
The platform uses Stripe's "separate charges and transfers" model. Every charge, refund and transfer uses the booking code as its transfer_group.
| When | What happens |
|---|---|
| Customer books with a deposit or full payment | The booking holds the time slot. The app opens the PaymentSheet for the amount due now. The pro sees the request only after the payment succeeds. Unpaid bookings are released after 30 minutes. |
| Pro marks a deposit job completed | The rest is charged off-session to the card saved with the deposit. If the bank asks for 3-D Secure or declines, the customer gets a notification and pays the rest in the app ("Pay the rest of the price"). |
| Booking cancelled, declined or expired | The refund follows the cancellation rules (free window, fee). It is sent back to the card, never more than was paid. |
| Dispute settled | The admin refunds all, part or nothing. Admin → Bookings → Refund also refunds by hand. |
Booking confirmed_complete (customer confirmed or auto-confirmed; no open dispute) |
The hourly payouts:release job transfers the pro's share to their Connect account. |
| Refund after the pro was paid | The same amount is reversed from the pro's transfer. |
The pro's share is subtotal minus commission. It is reduced if more was refunded than the platform keeps. Tax stays with the platform. Cash bookings are never charged or paid out.
Admin → Payments lists charges, refunds and payouts, each with its Stripe id.
4. Scheduler
php artisan schedule:run must run every minute (cron) in production. It runs these jobs:
bookings:processevery 5 minutes: frees unpaid slots, expires unanswered requests, and auto-confirms jobs.payouts:releasehourly: sends transfers to providers.
5. Google Pay and Apple Pay
Google Pay works in test mode on Android without extra setup. For live payments:
- Enable Google Pay in Stripe Dashboard → Settings → Payment methods.
- Follow Google's Android integration checklist and request production access in the Google Pay & Wallet Console.
Apple Pay (iOS):
- In Apple Developer, create a Merchant ID, e.g.
merchant.com.yourcompany.app. - In Stripe Dashboard → Settings → Payment methods → Apple Pay, add an iOS certificate. Upload the CSR from Stripe to Apple for that Merchant ID, then upload Apple's certificate back to Stripe.
- In Xcode, add the Apple Pay capability to the Runner target and tick your Merchant ID.
- Give the app the same Merchant ID: add
apple_merchant_id: merchant.com.yourcompany.apptorebrand.yamland run the rebrand script, or build with--dart-define=APPLE_MERCHANT_ID=merchant.com.yourcompany.app. Without a Merchant ID, the iPhone payment sheet shows cards only.
The PaymentSheet shows Apple Pay or Google Pay only when the device and account support it. Otherwise it shows cards only.
6. Test cards
| Card | Result |
|---|---|
4242 4242 4242 4242 |
Succeeds |
4000 0025 0000 3155 |
Asks for 3-D Secure, then succeeds |
4000 0000 0000 9995 |
Declined: insufficient funds |
4000 0000 0000 0002 |
Declined: generic |
4000 0027 6000 3184 |
3-D Secure on every charge. Use it to see the off-session balance fail and the "pay the rest" screen. |
Use any future expiry date, any CVC and any postcode. The full list is in Stripe's testing docs.
Errors the app may see
| Code | Meaning |
|---|---|
PAYMENT_NOT_DUE (409) |
Nothing to pay for this booking right now. |
PAYMENT_PROVIDER_ERROR (502) |
Stripe refused the request or didn't answer. Details are in the API log. |