Skip to main content
<MoonPayApplePayButton> renders an Apple Pay button inline in your layout. It is the declarative alternative to client.setupApplePay().
Apple Pay availability inside a WebView depends on iOS WebKit support. The component emits "unsupported" when Apple Pay isn’t available — surface a fallback payment method.
ApplePaySection.tsx
import React from "react";
import {
  MoonPayApplePayButton,
  MoonPayChallenge,
  type ApplePayEvent,
} from "@moonpay/platform-sdk-react-native";

export function ApplePaySection({
  quoteSignature,
}: {
  quoteSignature: string;
}) {
  const [challengeUrl, setChallengeUrl] = React.useState<string | null>(null);

  const handleEvent = (event: ApplePayEvent) => {
    switch (event.kind) {
      case "ready":
        break;
      case "complete":
        console.log(event.payload.transaction);
        break;
      case "quoteExpired":
        // Fetch a new quote and update the prop, or call setQuote directly:
        // event.payload.setQuote(newQuote.signature);
        break;
      case "challenge":
        setChallengeUrl(event.payload.url);
        break;
      case "error":
        console.error(event.payload.kind, event.payload.message);
        break;
      case "unsupported":
        // Apple Pay isn't available — fall back to another method.
        break;
    }
  };

  return (
    <>
      <MoonPayApplePayButton quote={quoteSignature} onEvent={handleEvent} />
      {challengeUrl && (
        <MoonPayChallenge
          url={challengeUrl}
          onEvent={(e) => {
            if (e.kind === "complete" || e.kind === "cancelled") {
              setChallengeUrl(null);
            }
          }}
        />
      )}
    </>
  );
}

Props

PropTypeRequiredDefaultDescription
quotestringQuote signature from getQuote(). Reactive — updating this prop pushes the new signature into the frame without a remount.
onEvent(event: ApplePayEvent) => voidCallback for Apple Pay lifecycle events. See ApplePayEvent.
styleViewStyleheight: 48Container style.

ApplePayEvent

Use event.kind to handle each event.
kindPayloadWhen you receive it
"ready"The Apple Pay UI is rendered and ready.
"complete"{ transaction: FrameTransaction }The payment finished. Inspect FrameTransaction for the outcome.
"challenge"{ kind: "frame"; url: string }Verification required. Render <MoonPayChallenge> with the provided URL.
"quoteExpired"{ setQuote: (signature: string) => void }The quote expired. Fetch a new quote and update the quote prop, or call payload.setQuote(...) directly.
"error"{ kind: string; message: string }The flow encountered an error. See error kinds below.
"unsupported"Apple Pay isn’t available in the user’s environment.
"error" kinds: "configurationError" | "invalidQuote" | "quoteExpired" | "oneTapApplePaySecondFactorRequired" | "genericError" "oneTapApplePaySecondFactorRequired" occurs during the 1TAP Apple Pay flow when MoonPay needs a second authentication factor. Hand off to client.connect() or render <MoonPayConnect>, then retry.