Skip to main content

Who is this for?

Mobile developers using React Native or Flutter who want to accept payments, create payment links, or manage wallets with Monieswitch APIs.

Overview

This guide covers:
  • Setting up secure API integration architecture
  • Creating a backend proxy for Monieswitch APIs
  • Building mobile app clients that communicate with your backend
  • Creating payment links and handling responses
  • Security best practices for mobile payments
  • Error handling and user experience considerations

Prerequisites

1

Create Monieswitch Account

A Monieswitch account. Register at Monieswitch Dashboard.
2

Get API Key

API Key from your Monieswitch dashboard.
3

Set Up Development Environment

React Native or Flutter development environment set up.
4

Backend Service

A backend service (Node.js, Python, etc.) to securely handle Monieswitch API calls.

Architecture Overview

Mobile apps should never communicate directly with Monieswitch APIs. Always use a secure backend to proxy requests and protect your API keys.

1. Backend Setup (Required)

First, set up your backend to handle Monieswitch API calls:

Environment Configuration

Add these to your backend .env file:

Backend Implementation

server.js

2. Mobile App Setup

Install HTTP Request Libraries

Configure API Client

Create an API service file:
services/api.js

3. Using the API in Your App

Fetching Merchant Details

components/MerchantInfo.js
components/PaymentLinkForm.js

4. Error Handling Best Practices

Common Error Scenarios

  1. Network connectivity issues
  2. Invalid API responses
  3. Authentication failures
  4. Validation errors
  5. Server timeouts

Implementation Examples

utils/errorHandler.js

5. Security Best Practices

  • Never store API keys in mobile app code
  • Always use HTTPS for all communications
  • Implement proper input validation
  • Use certificate pinning for production apps
  • Implement request signing for sensitive operations

Additional Security Measures

  1. Input Validation: Always validate user input before sending to your backend
  2. Rate Limiting: Implement rate limiting on your backend API endpoints
  3. Authentication: Use proper authentication mechanisms between your app and backend
  4. Logging: Log API requests and responses for debugging (exclude sensitive data)
  5. Error Messages: Don’t expose internal system details in error messages

6. Testing Your Integration

Backend Testing


Next Steps

  • Explore more endpoints in the API Reference
  • Implement webhooks on your backend for real-time payment updates

Troubleshooting

Common Issues

  1. CORS errors: Ensure your backend properly handles CORS if testing from web
  2. Network timeouts: Implement proper timeout handling and retry logic
  3. Environment variables not loading: Double-check your .env file location and format
  4. API key authentication failures: Verify your API key is correct and has proper permissions

Debug Tips

  • Enable detailed logging in both mobile app and backend
  • Use network debugging tools (React Native Debugger, Flutter Inspector)
  • Test API endpoints independently before integrating with mobile app
  • Monitor backend logs for detailed error informati