McTaba Labs logo
Software EngineeringThe WhiteboardProjectsEventsMasterclassesWebinarsLearn
Book Call

500+ developers already in the community

Get answers, find accountability partners, and stay ahead

Join Discord →
McTaba Labs logo

Educating 1 million students in tech by 2030.

Programs

  • HighSchool Graduates Launchpad
  • AI & Business Automation
  • Corporate Training
  • McTaba Story & Mission
  • Full-Stack Curriculum
  • Course Pricing & Plans
  • Frequently Asked Questions

Resources

  • Join Discord Community
  • Tech Events in Nairobi
  • Masterclasses
  • Free Resources
  • Learn
  • Campus
  • Africa Tech Talent Report
  • Partner With Us
  • Start a Project
  • Our Work

Contact Us

  • 124 Manyani East Road, Lavington, Nairobi
  • +254727795603
  • Book a Discovery Call

Office Hours:

Mon-Fri: 9am - 2pm EAT

Sat: 10am - 12pm EAT

© 2027 McTaba Labs - A product of Edtech Industries. All rights reserved.

Privacy PolicyTerms of ServiceRefund Policy
  1. Learn
  2. Paystack for African Developers
  3. Accept Payments with Paystack in React Native
Bonaventure OgetoBy Bonaventure Ogeto|Updated July 22, 2026

Accept Payments with Paystack in React Native

React Native apps cannot call the Paystack API with a secret key. Your backend initializes the transaction and returns the authorization_url. Open this URL with react-native-paystack-webview or a custom react-native-webview. Detect the callback URL redirect, extract the reference, and verify the transaction on your backend.

In this article

  1. 1. Install react-native-paystack-webview
  2. 2. Backend: Initialize Transaction
  3. 3. React Native: Paystack WebView Checkout
  4. 4. Expo: WebBrowser Alternative
  5. 5. Learn More

Install react-native-paystack-webview

npm install react-native-paystack-webview react-native-webview
# or
yarn add react-native-paystack-webview react-native-webview

# iOS
cd ios && pod install

For Expo managed workflow, use Expo WebBrowser instead:

npx expo install expo-web-browser

Backend: Initialize Transaction

// Node.js backend
app.post('/api/pay/initialize', async (req, res) => {
  var { email, amount } = req.body;
  var reference = 'rn_' + Date.now() + '_' + Math.random().toString(36).slice(2, 6);

  var response = await fetch('https://api.paystack.co/transaction/initialize', {
    method: 'POST',
    headers: {
      Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      email,
      amount: Math.round(amount * 100), // kobo
      reference,
      callback_url: 'https://yourapp.com/payment/callback',
    }),
  });

  var data = await response.json();
  if (!data.status) return res.status(400).json({ error: data.message });

  res.json({
    authorization_url: data.data.authorization_url,
    access_code: data.data.access_code,
    reference: data.data.reference,
  });
});

Get weekly developer tips

Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.

No spam. Unsubscribe anytime.

React Native: Paystack WebView Checkout

// PaymentScreen.tsx
import React, { useState } from 'react';
import { View, ActivityIndicator, Alert } from 'react-native';
import PaystackWebView from 'react-native-paystack-webview';

interface PaymentScreenProps {
  route: {
    params: {
      email: string;
      amount: number; // in display units (e.g. NGN 5000)
    };
  };
  navigation: any;
}

export function PaymentScreen({ route, navigation }: PaymentScreenProps) {
  var { email, amount } = route.params;
  var [loading, setLoading] = useState(true);

  return (
    <View style={{ flex: 1 }}>
      <PaystackWebView
        paystackKey="pk_test_xxxxxxxxxxxx"  // Your PUBLIC key
        amount={amount}
        billingEmail={email}
        activityIndicatorColor="green"
        onCancel={() => {
          navigation.goBack();
        }}
        onSuccess={async (response) => {
          // response contains transactionRef
          var reference = response.transactionRef?.reference || response.transactionRef;

          // Verify on your backend
          try {
            var verifyRes = await fetch(
              'https://your-backend.com/api/pay/verify?reference=' + reference
            );
            var result = await verifyRes.json();

            if (result.verified) {
              navigation.navigate('PaymentSuccess', { reference });
            } else {
              Alert.alert('Payment issue', 'Please contact support');
              navigation.goBack();
            }
          } catch (e) {
            Alert.alert('Error', 'Could not verify payment');
            navigation.goBack();
          }
        }}
        autoStart={true}
      />
    </View>
  );
}

Note: paystackKey takes your public key, not the secret key. react-native-paystack-webview loads Paystack's hosted checkout and handles the WebView internally.

Expo: WebBrowser Alternative

For Expo managed workflow, use expo-web-browser to open the authorization URL:

import * as WebBrowser from 'expo-web-browser';

async function startPayment(email: string, amount: number) {
  // Get authorization URL from your backend
  var response = await fetch('https://your-backend.com/api/pay/initialize', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email, amount }),
  });
  var data = await response.json();

  if (!data.authorization_url) {
    Alert.alert('Error', 'Could not initialize payment');
    return;
  }

  // Open in WebBrowser
  var result = await WebBrowser.openAuthSessionAsync(
    data.authorization_url,
    'yourapp://payment/callback'  // Deep link callback
  );

  if (result.type === 'success') {
    var url = new URL(result.url);
    var reference = url.searchParams.get('reference') || url.searchParams.get('trxref');
    if (reference) {
      await verifyPayment(reference);
    }
  }
}

Deep link handling requires configuring the scheme in your app.json and setting up deep link routing.

Learn More

This guide is part of the Paystack integration guides by language and framework series.

Next: Verify Paystack Payments in React Native

Sign up for the McTaba newsletter

Key Takeaways

  • ✓Never put your Paystack secret key in React Native code. Initialize transactions from your backend.
  • ✓react-native-paystack-webview is the most popular library for Paystack checkout in React Native.
  • ✓Both Expo and bare React Native workflows support the WebView approach.
  • ✓After checkout, the library provides the transaction reference in the onSuccess callback.
  • ✓Always verify the transaction on your backend before granting access or fulfilling orders.
  • ✓Add INTERNET permission on Android and ATS configuration on iOS for WebView to load Paystack pages.

Frequently Asked Questions

Can I use Paystack in Expo without ejecting?
Yes. Use expo-web-browser to open the Paystack authorization URL. This opens the checkout in a system browser or in-app browser. After payment, handle the deep link callback. You do not need react-native-paystack-webview, which requires native modules.
Where do I put the Paystack public key in React Native?
The public key (pk_test_ or pk_live_) can go in your React Native code — it is safe to expose. Store it in your .env file as EXPO_PUBLIC_PAYSTACK_KEY for Expo, or in a config file. Never put the secret key (sk_test_ or sk_live_) in your React Native code.
Does react-native-paystack-webview work on both iOS and Android?
Yes. The library wraps react-native-webview, which supports both platforms. Ensure you install pods for iOS (cd ios && pod install) and have INTERNET permission in AndroidManifest.xml.
What is the difference between access_code and authorization_url for React Native?
Both can be used to launch checkout. The authorization_url is a full URL you can open in a WebView or browser. The access_code is a shorter token used with react-native-paystack-webview's accessCode prop for inline checkout on the hosted Paystack page.

Learn Paystack Integration

KES 2,999

The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.

Start Paystack Course

Not ready? Create Free Account

Keep reading

Paystack Integration Guides by Language and Framework

A complete directory of Paystack integration guides organized by programming language and framework. Each guide covers accepting payments, verifying transactions, handling webhooks, and building subscriptions in your specific stack.

Read more

Verify Paystack Payments in React Native

After Paystack checkout in React Native, send the transaction reference to your backend to verify. This guide covers the full verification flow from the WebView callback to updating your UI.

Read more

Handle Paystack Webhooks in React Native

Paystack webhooks are server-to-server — your React Native app cannot receive them directly. This guide explains building the backend webhook handler and notifying the React Native app via push notifications, polling, or deep links.

Read more

Build Paystack Subscriptions in React Native

Add Paystack subscription billing to a React Native app. This guide covers initializing a subscription transaction from your backend, the checkout WebView flow, checking subscription status, and building subscription management UI.

Read more

Paystack Redirect Checkout vs Inline Checkout: Choosing Correctly

Paystack gives you two ways to present the checkout page: a full-page redirect to checkout.paystack.com, or an inline popup that overlays your site. Both collect payment identically. The difference is user experience, implementation complexity, and how you handle the post-payment flow.

Read more

Understanding Kobo, Pesewa and Cents: Paystack Amount Handling

Paystack expects amounts in the smallest currency unit: kobo for Naira, pesewas for Cedis, cents for Rand, Shillings, and Dollars. This guide covers the conversion rules, the floating-point traps that cause wrong charges, and the helper functions that keep your amounts correct.

Read more

Explore related topics

M-Pesa & African Stack

M-Pesa Daraja API tutorials, USSD development, and WhatsApp Business API guides. The African Stack that global bootcamps do not teach.

Learn to Code in Kenya

Everything a Kenyan needs to know before writing their first line of code. Career paths, real costs, hardware requirements, and honest answers about what it takes.

Learning to Code

Roadmaps, language guides, and practical advice for learning to code and launching a programming career.

Breaking Into Tech

Practical, no-nonsense guides for anyone looking to start or change their career in tech. From choosing your first language to acing interviews.

The African Stack: Skills for This Market

The skills that make Kenyan developers hard to replace: M-Pesa, USSD, WhatsApp, fintech, and building for the African market.

Bonaventure Ogeto

Bonaventure Ogeto

Founder, McTaba Labs

Bonaventure is the founder of McTaba Labs, a coding bootcamp in Nairobi, Kenya. He has spent years building products for the African market and mentoring the next generation of developers across the continent.