Skip to content
React Native logo
Mobile SDKv1.0.0

React Native Moolre

Accept Moolre payments in a React Native app with a secure, customisable checkout button.

  • Secure WebView checkout
  • iOS and Android
  • Custom callbacks
  • Customisable button
  • Native device testing
  • Production-ready flow

How the SDK works

MoolrePayButton opens the Moolre checkout inside your app’s WebView. Its callback gives your app a payment reference; use that reference to update the screen, then verify the payment from your server before delivering goods, crediting a wallet, or marking an order as paid.

  1. Configure

    Pass the amount and merchant details to the button.

  2. Collect payment

    The customer completes checkout in the in-app WebView.

  3. Verify on your server

    Confirm the returned reference with the Moolre API before fulfilment.

Version, platform, and testing support

EnvironmentSupportNotes
SDK releasev1.0.0Install react-native-moolre with react-native-webview.
React Native on iOS and AndroidSupportedTest checkout in a native app build or on a physical device.
Expo Go on iOS and AndroidNative-device testingUse it only for native device testing; do not use Expo web as a checkout test environment.
Expo webNot supportedThe SDK uses a native WebView. For browser checkout, use the JavaScript Inline SDK instead.

Installation

Install the package via yarn or npm. This plugin requires react-native-webview as a peer dependency.

yarn add react-native-moolre react-native-webview# ornpm install react-native-moolre react-native-webview
info

Expo Go is for native iOS and Android testing. Do not use npx expo start --web to test this SDK; Expo web is not supported. Use a native device or app build for checkout testing.

Quick Start

Import the button and drop it into your component.

import { MoolrePayButton } from 'react-native-moolre';​// Inside your component<MoolrePayButton  amount={50}  publicKey="your_public_key"  accountNumber="your_account_number"  email="user@example.com"  onSuccess={(reference) => {    console.log("Payment successful. Ref:", reference);  }}  onError={({ code, message }) => {    console.error(`Payment error [${code}]: ${message}`);  }}  buttonStyle={{ padding: 12, borderRadius: 8 }}  textStyle={{ fontSize: 16 }}/>

Example Checkout UI

A complete example of a checkout screen with a product list and the Moolre Pay button.

import React from 'react';import {  View,  Text,  FlatList,  SafeAreaView,  StyleSheet,  Alert,} from 'react-native';import { MoolrePayButton } from 'react-native-moolre';​const products = [  { id: '1', name: 'Premium Sneakers', price: 120 },  { id: '2', name: 'T-Shirt', price: 40 },  { id: '3', name: 'Cap', price: 25 },];​export default function App() {  const total = products.reduce((sum, item) => sum + item.price, 0);​  return (    <SafeAreaView style={styles.container}>      <Text style={styles.heading}>Checkout</Text>​      <FlatList        data={products}        keyExtractor={(item) => item.id}        renderItem={({ item }) => (          <View style={styles.product}>            <Text style={styles.name}>{item.name}</Text>            <Text style={styles.price}>GHS {item.price.toFixed(2)}</Text>          </View>        )}        contentContainerStyle={{ paddingBottom: 20 }}      />​      <Text style={styles.total}>Total: GHS {total.toFixed(2)}</Text>​      <MoolrePayButton        amount={total}        publicKey="your_public_key"        accountNumber="your_account_number"        email="user@example.com"        onSuccess={(ref) => Alert.alert('Success', `Payment ref: ${ref}`)}        onError={({ code, message }) =>          Alert.alert(`Error [${code}]`, message)        }        buttonStyle={styles.button}        textStyle={styles.buttonText}      />    </SafeAreaView>  );}​const styles = StyleSheet.create({  container: { flex: 1, padding: 20, justifyContent: 'center' },  heading: { fontSize: 28, fontWeight: 'bold', marginBottom: 20 },  product: {    flexDirection: 'row',    justifyContent: 'space-between',    marginBottom: 10,  },  name: { fontSize: 18 },  price: { fontSize: 18, fontWeight: '600' },  total: {    fontSize: 20,    fontWeight: 'bold',    marginTop: 20,    marginBottom: 10,  },  button: {    backgroundColor: '#fff',    padding: 15,    borderRadius: 10,    borderColor: '#FF9900',    borderWidth: 1.5,    flexDirection: 'row',    alignItems: 'center',    justifyContent: 'center',  },  buttonText: {    color: '#111',    fontWeight: 'bold',    fontSize: 16,  },});

Props Reference

PropTypeRequiredDescription
amountnumberYesPayment amount in Ghana cedis
publicKeystringYesYour Moolre public API key
accountNumberstringYesYour Moolre merchant account number
currencystringNoDefaults to "GHS"
emailstringNoCustomer email address
callbackUrlstringNoOptional custom payment redirect callback URL
onSuccess(ref: string) => voidYesTriggered on successful payment
onError({ code, message }) => voidYesTriggered on failure or cancellation
buttonStyleViewStyleNoCustom styles for the button
textStyleTextStyleNoCustom styles for the button text