Skip to main content
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.

Core Functionalities

Crypto On-Ramp

Purchase cryptocurrencies directly using various payment methods with automatic wallet integration

Wallet Integration

Automatically populates the user’s connected wallet address as the destination for purchases

Customizable Widget

Configurable MoonPay widget supporting both sandbox and production environments

Balance Management

View wallet balances and seamlessly navigate to purchase flows when funds are needed

Installation & Setup

1

Install MoonPay SDK

The module uses the official MoonPay React Native SDK:
2

Configure API Key

Add your MoonPay API key to .env.local:
3

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.

Module Architecture

Core Components

MoonPayWidget - Core component that embeds MoonPay’s purchase flow
Props:
  • apiKey - Your MoonPay API key
  • environment - ‘sandbox’ or ‘production’
  • height - Widget height in pixels
  • onOpen - Callback when widget loads
  • onError - Error handling callback
  • onRetry - Retry mechanism callback

Quick Start Example

MoonPay Service Configuration

The moonpayService.ts provides configuration and validation utilities:

Utility Functions

object
object
object

Advanced Usage Patterns

Custom Purchase Flow

Transaction Status Tracking

Balance-Based Recommendations

Integration with Other Modules

Embedded Wallets

Automatic wallet address detection and integration

Data Module

Real-time balance updates and transaction history

Swap Module

Purchase crypto then immediately swap to desired tokens

Thread Module

Share purchase milestones and achievements

Combined Workflow Example

Environment Configuration

  • Uses sandbox environment automatically
  • Test transactions don’t involve real money
  • Full widget functionality for testing

Error Handling & Troubleshooting

object

Security Considerations

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.

API Reference

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.