Connect a customer’s MoonPay account so you can list payment methods, get executable quotes, and execute transactions. Before you start, review the requirements.Documentation Index
Fetch the complete documentation index at: https://dev.moonpay.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- A server that can create session tokens with your secret key.
- A client that can render frames (SDK or manual integration).
- If the customer has never connected, render the co-branded connect frame.
- If the customer has connected before, first check whether their connection is still valid. You only need to render UI again if the connection has expired.
Create a session
To initiate a session on your server, provide:- A unique identifier from your system for the customer (
externalCustomerId). - The IP address of the customer’s device. This is used across frames to ensure the integrity of the session.
sessionToken to send to your frontend.
Check the API reference
for detailed usage.
Check connection
Using thesessionToken, check if the customer already has an active connection. No UI appears in this step, but it runs in a frame. You can check the session using the SDK or manually.
The check frame always returns encrypted credentials. Hold them in memory only and do not persist them, regardless of the status returned. For an active connection these are authenticated credentials. For connectionRequired, these are anonymous credentials whose clientToken you pass into the connect flow.
postMessage events.
Low-friction authentication
You can simplify login for returning customers by passing the optionalemail and phoneNumber parameters when you create a session.
If these values match an existing MoonPay account, the connect frame skips the full login and prompts the customer to enter an OTP code sent to their phone.
Connect flow
If you need to create or revalidate a connection, initialize the connect flow with theclientToken from the anonymous credentials returned by the check frame. The SDK provides hooks to coordinate rendering the connect UI (for example, to animate a modal or sheet). You can also do this manually.
When the connect flow completes, replace the anonymous credentials from the check step with the authenticated credentials from the complete event.
The resulting connection has one of the following statuses: active, pending, unavailable, or failed.
In mobile apps, present the connect flow as a full sheet. See presentation
and appearance for UI guidance.
complete event, the payload includes authenticated client
credentials and a customer object identifying the connected MoonPay customer.
Discard any anonymous credentials from the check step and use the new ones instead.
Use them to make scoped API calls from your frontend (for example, listing
payment methods and getting quotes). See Pay with Apple
Pay for a complete example flow.
Capabilities
Thecomplete event also includes a capabilities object that describes regulatory requirements for the connected customer. You can use this to customize your UI before initiating a transaction; for example, determining whether a payment disclosure is required.
capabilities.ramps.requirements.paymentDisclosures is present, you must display the required disclosure to the customer before they can complete a transaction. See Going Live for the exact text to render and presentation requirements.
Connection statuses
Active
Anactive status means the connection is valid and can be used. Active connections typically remain live for 180 days without revalidation. If the connection expires, refresh it via the connect flow.
Unavailable
Anunavailable status means the connection cannot be used at the current time. This typically occurs when a KYC-verified customer is using a device or application from a restricted location.
Pending
Apending status typically occurs for customers whose KYC decisions are delayed. Often these cases are resolved out of band and the customer can connect on a subsequent visit to your app.
Failed
Afailed status is a terminal state. This usually happens if the customer fails KYC or cannot be onboarded to MoonPay. It can also happen if the customer rejects the connection. In these cases, direct the customer to an alternate flow in your app.
Connection required
TheconnectionRequired status is returned from the check frame as a signal to guide the customer through the full connect flow. This status is returned for new customers who have not connected to your app, or returning customers whose connections have expired. The response also includes anonymous credentials — keep them only in memory and use the clientToken to initialize the connect flow.