Add live Stripe card charges (PaymentIntent + Elements + webhook) #28
Reference in New Issue
Block a user
Delete Branch "feature/payments-stripe"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Completes the deferred second half of payment processing: live credit-card charging via Stripe, on top of the existing ledger / e-transfer / comp foundation.
What changed
stripe/stripe-php: creates idempotent PaymentIntents (amount in cents, registration ids in metadata) and verifies webhook signatures. The Stripe calls sit behind protected seams so they're unit-testable without the SDK's magic-property graph or the network.payment_intent.succeededfinalises the matching payment exactly once (mark paid → confirm lesson → email receipt, reusingfinalizePaid); onpayment_intent.payment_failedmarks itfailed. Returns false only on bad signatures.POST /payments/intent(book_lesson) and public, signature-verifiedPOST /payments/webhook.setStripeIntentId/findByStripeIntentIdfor webhook reconciliation.us_stripe_webhook_secretoption; the settings page shows the exact webhook URL and the events to subscribe to.payment.jsmounts Stripe's Payment Element and confirms the card (redirect: 'if_required') or shows e-transfer instructions; Stripe.js is enqueued only when configured. Wired into both the booking and group-class flows.Operational note
Card payments flip to paid only when Stripe calls the webhook, so the studio must register the endpoint in the Stripe Dashboard and paste its
whsec_…signing secret into Studio Settings (URL + events are spelled out on the settings page).Build / install
No CI change required: the
buildjob'scomposer buildregeneratesvendor/fromcomposer.json, so the Stripe SDK is bundled automatically. Verified the built zip is self-contained — a single top-levelunsupervised-schedular/folder includingvendor/stripe/stripe-php/and a regenerated autoloader — so it installs directly in WordPress.Checks
composer test(180 tests),composer lint(PHPStan L6),composer cs(PHPCS) all green. NewStripeGatewayTest;PaymentServicegains card-intent + webhook coverage; repository coverage added.🤖 Generated with Claude Code