iframe
within your site. Within the new page/iframe
, your user will complete their purchase flow and any required identity verification steps.fundWallet
method to our frontend that collects information about our user and our desired on-ramp flow, and sends it to our backend.
In this example app, users login with their email address and create a Privy embedded wallet upon logging in. Thus, we can get the user’s email and wallet address from their user
object and include it in this request. This ensures the user doesn’t have to enter this manually when completing the on-ramp flow later.
iframe
. Thus, we can get the URL of the current page (window.location.href
) and include it in this request. This allows the on-ramp provider to redirect the user back to this page once they have completed their purchase.
fundWallet
method to send this data to our backend, authorizing the request with the user’s Privy auth token.
fundWallet
parses the response returned by the server (we’ll implement this below) and returns the fiat on-ramp URL as a string.
POST /api/onramp
handler that receives the request from step (1) and responds with the on-ramp URL.
In our handler, we’ll start by parsing the request body for the user’s wallet address
, email
, and redirectUrl
. If you included additional information in your request (e.g. asset type, amount), you should parse the request body for those values as well.
fundWallet
method in our front-end should now return a configured, authorized on-ramp URL where our user can complete their purchase.
redirectUrl
we configured in steps (1) and (2). On this redirect, Moonpay will also append a transactionId
that we can optionally use to monitor the status of the user’s transaction.
iframe
embedded within your site: