mq-apple-pay-checkout
Apple Pay checkout for top-level pages on a domain verified with Apple. Supports Safari native sheets and QR checkout on other desktop browsers via the Apple Pay JS SDK.
<mq-apple-pay-checkout> handles Apple Pay on top-level pages (not inside WKWebView or iframes). The host page must load the pinned Apple Pay JS SDK before mounting the element. The component renders Apple's official <apple-pay-button>, validates the merchant with the backend, authorizes the payment token, and emits the same outcome events as <mq-checkout>.
On Chrome, Edge, and Firefox (desktop), Apple Pay uses a QR modal — the user scans with an iPhone running iOS 18+ to complete payment. On Safari, the native Apple Pay sheet is used.
Use it from the checkout shell at /apple-pay, or mount it directly in your own top-level page on a domain verified with Apple.
How it works
- The host loads the Apple Pay JS SDK (
script-src+ CSP must allowapplepay.cdn-apple.com). - You pass
merchant-id,session-id(backendorder_id), and payment request metadata (amount,currency,country,label). <mq-apple-pay-checkout>authenticates (api-key+token).- After
applePayCapabilities(merchant-id)(orcanMakePaymentsfallback), it renders the Apple Pay button and optional QR helper copy. - On click (user gesture):
ApplePaySession→validate-merchant→authorize→ outcome events.
POST /payments/v1/apple-pay/validate-merchant returns Apple's merchant session JSON at the HTTP body root (not MediQuo's { data: … } envelope). The component passes that object to completeMerchantValidation. POST /payments/v1/apple-pay/authorize uses the usual { data: { status, consultation_id } } shape; only status: "paid" is treated as success.
Dependencies
Does not require <mq-theme-provider> — the button uses Apple's SDK styling.
Does not require <mq-query-client-provider> or <mq-socket-provider>.
Does require the host to load the Apple Pay JS SDK. The component never injects third-party scripts.
Installation
npm install @mediquo/web-componentsimport "@mediquo/web-components/mq-apple-pay-checkout";Usage
<script
src="https://applepay.cdn-apple.com/jsapi/v1.3.8/apple-pay-sdk.js"
integrity="sha384-u/9mOkmShCO0v+dqCAZFhiutJuORfzvuyM5i+676iy7mLSWS6rlllHrIt15f/mqH"
crossorigin="anonymous"
></script>
<mq-apple-pay-checkout
env="production"
api-key="<your-api-key>"
token="<your-token>"
locale="es_ES"
merchant-id="merchant.com.example"
session-id="<order-id>"
amount="29.99"
currency="EUR"
country="ES"
label="Consulta"
></mq-apple-pay-checkout>
<script type="module">
const checkout = document.querySelector("mq-apple-pay-checkout");
checkout.addEventListener("payment-success", (e) => {
console.log("paid", e.detail.sessionId, e.detail.reference);
});
</script>Attributes
| Name | Type | Required | Description |
|---|---|---|---|
env | string | No | "development" or "production". Default "production". |
api-key | string | Yes | MediQuo API key. |
token | string | Yes | MediQuo user token. |
locale | string | No | es_ES, en_US, pt_PT, de_DE, ca_ES. Default es_ES. |
merchant-id | string | Yes | Apple Pay merchant identifier (merchant.com…). |
session-id | string | Yes | Backend order id (order_id). |
amount | string | Yes | Decimal string for the Apple Pay total. |
currency | string | Yes | ISO 4217 code (e.g. EUR). |
country | string | Yes | ISO 3166-1 alpha-2 code (e.g. ES). |
label | string | Yes | Line item label in the Apple Pay sheet. |
Events
| Event | Detail | Description |
|---|---|---|
payment-success | { sessionId: string; reference: string } | Payment authorized. reference is the consultation_id. |
payment-denied | { sessionId: string } | Backend rejected the payment. |
payment-error | { reason: "auth" | "unsupported" | "merchant" | "authorize" | "cancelled" } | Auth failure, unsupported device, SDK not loaded, merchant validation failure, authorization failure, or user cancelled. |
Platform requirements
- Top-level only — not inside WKWebView or iframes.
- The page must be served from a domain registered with Apple Pay (
checkout.mediquo.com). - Host must load the Apple Pay JS SDK and configure CSP (
script-src,frame-src,connect-srcfor Apple hosts). - Chrome / Edge / Firefox (desktop): QR flow requires an iPhone with iOS 18+.
- Safari: native Apple Pay sheet (SDK may also be loaded; session API is unchanged).
Native apps (recommended integration)
Mobile apps that schedule on-device and only need MediQuo for payment should not
use <mq-schedule>. Open the hosted checkout directly:
| Method | How to open | URL |
|---|---|---|
| Card | WKWebView / Android WebView (as today) | https://checkout.mediquo.com/?api_key=…&session_id=…&payment_url=…#token=… |
| Apple Pay | Safari, SFSafariViewController, or desktop Chrome (QR + iPhone) | https://checkout.mediquo.com/apple-pay?api_key=…&session_id=…&amount=…¤cy=…&country=…&label=…#token=… |
The method selector belongs in the native UI. Apple Pay Web will fail inside a normal in-app WebView; only a Safari-class browser or desktop QR flow on the verified domain works.
Outcomes are relayed the same way as the card checkout (payment-success /
payment-denied / payment-error → native bridge). If you open Safari externally,
complete the return path with a deep / universal link.
mq-immediate-videocall-checkout
Immediate-videocall checkout. Creates a payment session for a paid immediate videocall, then delegates the full payment UX to mq-checkout.
mq-google-pay-checkout
Google Pay checkout for top-level pages on checkout.mediquo.com. Uses the Google Pay JS SDK with Global Payments gateway tokenization.