Quickstart: Swap API-driven flow
Prerequisites
Integration acceptance criteria
How to integrate Swap
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <script src="https://static.moonpay.com/web-sdk/v1/moonpay-web-sdk.min.js"></script> </head> <body> <script type="application/javascript"> const moonpaySdk = window.MoonPayWebSdk.init({ flow: 'swapsCustomerSetup', environment: 'sandbox', variant: 'overlay', params: { apiKey: '_your_api_key_', amount: '300', amountCurrencyCode: 'usd', }, handlers: { async onAuthToken({ token }) { // Once the customer has logged in in the widget, we share their // swaps-scoped authentication token with your app so you can // perform Swaps requests on behalf of the customer. // The token needs to be passed as an Authorization header in the format // "Authorization: Bearer {token}" console.log('onAuthToken event received with customer authentication token:', token); }, async onSwapsCustomerSetupComplete() { // When this is received, we can close the widget and resume the // partner's swaps flow console.log('onSwapsCustomerSetupComplete received'); }, } }); moonpaySdk.show(); </script> </body> </html>
Refunding unsuccessful deposits
Last updated