Skip to content

feat(stripe/payments): take booking and catering payments through Stripe - #654

Open
MrYuion wants to merge 2 commits into
masterfrom
feat/stripe-payments
Open

MrYuion wants to merge 2 commits into
masterfrom
feat/stripe-payments

Conversation

@MrYuion

@MrYuion MrYuion commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

PlaceOS/user-interfaces#748 lets users pay for bookings and catering through a payment driver, but no driver implements its PaymentDriver contract. This adds one for Stripe: Stripe::Payments in drivers/stripe/payments.cr.

How it works

  • Users: the driver finds the user with invoked_by_user_id and StaffAPI. Staff methods need sys_admin or a group in privileged_groups. Users see only their own payments, invoices and cards, matched by PlaceOS user ID and not by email.
  • Prices: a room, desk or other resource takes its price from the Stripe Product that matches it most closely (resource, then zone). Catering takes its price from the CATERING:* assets in the zone. tax_rate is a percent that the prices already include. A quote fails when a price is in another currency, or when the account has more than 1000 Stripe products, so an item is never free by mistake.
  • Checkout: a new card opens a hosted Checkout Session. A saved card makes a PaymentIntent and can return a 3-D Secure link. Both only authorize the payment. capture_payment takes it, without the excluded rooms, when the booking saves.
  • Invoices: Stripe Invoices. A user requests an invoice for a payment, and staff send it. A staff invoice belongs to the PlaceOS user with its email. An invoice for a paid booking is marked paid out of band before Stripe emails it.
  • Retries: every Stripe POST has an idempotency key, as the transport sends a POST again after an IO error. Captures, cancels and refunds run one at a time. A retried capture or invoice send does not charge, refund or email twice. refund_payment also takes an optional request_id: a retry with the same ID returns the payment and does not refund again. The UI change for this is proposed on #748.
  • TLS: https_verify: "peer" is in the default settings, as the transport skips the certificate check without it.
  • API version: pinned to Stripe 2024-06-20. On this version a partial capture counts the released amount as refunded, so the driver subtracts it.

Known limits

  • Lists use the Stripe Search API, which can be up to a minute late. Open or expired Checkout Sessions are not listed.
  • Stripe sends an invoice only to its customer's email, so send_invoice refuses a different email.
  • When a driver method raises, the driver manager logs the call arguments, including billing details. This needs a fix in the driver framework: Driver manager logs all call arguments when a driver method raises driver#173.

payments_spec.cr has 18 examples and passes in the harness.

Created with Claude Opus 5.5 in Claude Code (T3 Code). The code was reviewed in 5 rounds by gpt-6.2-sol (Codex).

🤖 Generated with Claude Code

Implements the PaymentDriver contract from PlaceOS/user-interfaces#748:
checkout, manual capture, saved cards, refunds, products and invoices.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge; all four previous findings are addressed.

Summary

Adds a Stripe payment driver for bookings and catering.

  • Booking and catering requests now get Stripe prices and checkout.
  • Users can track cards and payments as bookings are captured or refunded.
  • Staff can manage Stripe invoices, refunds, and payment prices.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Quote booking and catering] --> B[Authorize through Stripe]
  B --> C[Save booking]
  C --> D[Capture kept items]
  D --> E[Request invoice]
  E --> F[Staff send paid invoice]
Loading

Reviews (2) · Last reviewed commit: "fix(stripe/payments): own invoices and c..." · Reviewed by Greptile

Comment thread drivers/stripe/payments.cr Resolved
Comment thread drivers/stripe/payments.cr Resolved
Comment thread drivers/stripe/payments.cr Resolved
Comment thread drivers/stripe/payments.cr Resolved
…artial prices

- Users see only invoices with their user ID. Staff invoices get the ID
  of the PlaceOS user with the email.
- Find a customer by user ID after an email change, then update its email.
- Fail a quote when the product list is incomplete, as missing products
  made items free.
- Refuse a product price in another currency. A new price is made when
  staff save it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant