# Shopify

> What is and isn't possible with Shopify today, and the recommended pattern.

There is **no OTP.ps Shopify app yet**. Shopify controls its checkout, so a third party can't add a required code step before "Place order" on most plans. What works today:

## Easiest: verification links, no app needed

1. In **Shopify Flow**, trigger **Order created**. Add a condition: the payment gateway is cash on delivery.
2. Add the action **Send HTTP request**: `POST https://otp.ps/api/v1/verify/links` with the header `Authorization: Bearer <a key with only the send scope>` and the body:

   ```json
   { "phone": "{{order.shippingAddress.phone}}", "purpose": "order", "reference": "{{order.name}}", "delivery": "sms" }
   ```

   Pick the fields with Flow's variable picker (the phone may be on the shipping address or the customer). Also tag the order `awaiting-phone-confirmation` in Flow.
3. OTP.ps texts the customer a link; they press Confirm.
4. In Zapier, Make or n8n, the OTP.ps trigger **Link approved** starts a step that replaces the tag with `phone-confirmed` (Shopify's "Update order" or "Add tag" action, matching `reference` to the order name).

Your team ships only orders tagged `phone-confirmed`.

## With your own backend: confirm after the order is placed

1. A small backend of yours subscribes to Shopify's `orders/create` webhook.
2. For cash-on-delivery orders, it tags the order `awaiting-phone-confirmation` and sends a code with `purpose: "order"` and `Idempotency-Key: shopify-<order id>-otp-1` to the order's phone.
3. The customer types the code on a page of yours, linked from the order confirmation email or shown on the thank-you page (where your Shopify app or theme allows it).
4. On `valid: true`, your backend replaces the tag with `phone-confirmed`. Your team ships only confirmed orders, and calls or cancels the rest after a few hours.

This uses Shopify's Admin API (order tags) and webhooks from your own backend. The OTP.ps key stays on that backend, never in the theme.

## Not possible / not recommended

- Calling OTP.ps from theme JavaScript: the key would be public.
- Blocking checkout before payment: only possible with checkout extensions on plans that allow them; not covered by this guide.

A ready-made Shopify app is on the roadmap.
