Seamless fiat on-ramp integration for purchasing cryptocurrency with credit cards and Apple Pay
The MoonPay module provides seamless cryptocurrency purchasing capabilities directly within your app. Users can buy crypto using credit cards, debit cards, Apple Pay, and other payment methods through MoonPay’s trusted platform.
Purchase cryptocurrencies directly using various payment methods with automatic wallet integration
Automatically populates the user’s connected wallet address as the destination for purchases
Configurable MoonPay widget supporting both sandbox and production environments
View wallet balances and seamlessly navigate to purchase flows when funds are needed
Install MoonPay SDK
The module uses the official MoonPay React Native SDK:
Configure API Key
Add your MoonPay API key to .env.local
:
Import Components
Import the components you need:
API Keys: Use pk_test_
prefixed keys for testing and pk_live_
for production. The module automatically detects the environment.
MoonPayWidget
- Core component that embeds MoonPay’s purchase flow
Props:
apiKey
- Your MoonPay API keyenvironment
- ‘sandbox’ or ‘production’height
- Widget height in pixelsonOpen
- Callback when widget loadsonError
- Error handling callbackonRetry
- Retry mechanism callbackMoonPayWidget
- Core component that embeds MoonPay’s purchase flow
Props:
apiKey
- Your MoonPay API keyenvironment
- ‘sandbox’ or ‘production’height
- Widget height in pixelsonOpen
- Callback when widget loadsonError
- Error handling callbackonRetry
- Retry mechanism callbackOnrampScreen
- Complete purchase screen with navigation and wallet integration
Features:
WalletScreen
- Wallet balance display with on-ramp entry point
Features:
The moonpayService.ts
provides configuration and validation utilities:
Automatic wallet address detection and integration
Real-time balance updates and transaction history
Purchase crypto then immediately swap to desired tokens
Share purchase milestones and achievements
API Key Security: Never expose production API keys in client-side code. Consider using a backend proxy for additional security.
User Verification: MoonPay handles KYC/AML compliance, but ensure your app provides clear information about verification requirements.
For detailed API documentation, see:
The MoonPay module provides a seamless bridge between traditional finance and crypto, enabling users to easily onboard into the Solana ecosystem with familiar payment methods.