# Apple Pay and Google Pay

## Recommended: through Stripe Checkout (no extra setup)

Install `stripe-payments`. Stripe's hosted Checkout page shows **Apple Pay** on Safari and Apple devices and
**Google Pay** on Chrome and Android automatically, as long as the wallets are enabled in the Stripe Dashboard
(Settings, Payment methods; they are on by default). Stripe verifies its own domain, so nothing has to be verified
for the website, and this works on `runalio.ai` addresses and custom domains alike.

## Optional: wallet buttons on the website's own page

Showing Apple Pay or Google Pay buttons directly on a page uses Stripe's Express Checkout Element and Payment
Intents. Requirements:

- The website must be on the customer's **own domain** (connected in Runalio, Domains & SSL). Apple Pay cannot be
  registered for the shared `runalio.ai` domain.
- The customer adds that domain in Stripe, Settings, Payment method domains. Stripe hosts the Apple Pay domain
  association file for registered domains.
- `STRIPE_PUBLISHABLE_KEY` set in Settings → Website modules → Stripe, plus everything `stripe-payments` needs.

Build it on top of `stripe-payments`: add an endpoint in a new feature file that creates a PaymentIntent for a
server-priced item (use `priceFor` from `lib/payments.js` and the `stripe()` helper exported by
`features/stripe-payments.js`), record the payment from the `payment_intent.succeeded` webhook with `recordPayment`,
and load `https://js.stripe.com/v3/` on the page to mount `elements.create('expressCheckout')`. Add
`payment_intent.succeeded` to the webhook's events.

## What the customer needs to do

- For the hosted page: nothing beyond `stripe-payments`.
- For on-page buttons: connect a custom domain, register it in Stripe (Payment method domains), add
  `STRIPE_PUBLISHABLE_KEY`, and add `payment_intent.succeeded` to the Stripe webhook.
