EdinyangaOttoho / React-Native-Paystack-WebView

πŸ’ΈπŸ’³The package allows you accept payment using paystack and guess what , it doesn't require any form of linking, just install and begin to use .

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React-Native-Paystack-WebView

All Contributors PRs Welcome

The package allows you accept payment using paystack, install, add keys and use. No stress :)

Installation

Add React-Native-Paystack-WebView to your project by running;

npm install react-native-paystack-webview

or

yarn add react-native-paystack-webview

One more thing

To frontload the installation work, let's also install and configure dependencies used by this project, being react-native-webview

run

yarn add react-native-webview

for iOS: cd iOS && pod install && cd ..

for expo applications run;

expo install react-native-webview

and that's it, you're all good to go!

Screenshot of library in action

Usage 1

import React from 'react';
import  { Paystack }  from 'react-native-paystack-webview';
import { View } from 'react-native';

function Pay() {
  return (
    <View style={{ flex: 1 }}>
      <Paystack  
        paystackKey="your-public-key-here"
        amount={'25000.00'}
        billingEmail="paystackwebview@something.com"
        activityIndicatorColor="green"
        onCancel={(e) => {
          // handle response here
        }}
        onSuccess={(res) => {
          // handle response here
        }}
        autoStart={true}
      />
    </View>
  );
}

Usage 2 - Using Refs

Make use of a ref to start transaction. See example below;

import React, { useRef } from 'react';
import  { Paystack , paystackProps}  from 'react-native-paystack-webview';
import { View, TouchableOpacity,Text } from 'react-native';

function Pay(){
  const paystackWebViewRef = useRef<paystackProps.PayStackRef>(); 

  return (
    <View style={{flex: 1}}>
      <Paystack
        paystackKey="your-public-key-here"
        billingEmail="paystackwebview@something.com"
        amount={'25000.00'}
        onCancel={(e) => {
          // handle response here
        }}
        onSuccess={(res) => {
          // handle response here
        }}
        ref={paystackWebViewRef}
      />

        <TouchableOpacity onPress={()=> paystackWebViewRef.current.startTransaction()}>
          <Text>Pay Now</Text>
        </TouchableOpacity>
      </View>
  );
}

API's

all React-Native-Paystack-WebView API

Name use/description extra
paystackKey Public or Private paystack key(visit paystack.com to get yours) nill
amount Amount to be paid nill
activityIndicatorColor color of loader default: green
billingEmail(required by paystack) Billers email default: nill
billingMobile Billers mobile default: nill
billingName Billers Name default: nill
channels Specify payment options available to users. Available channel options are: ["card", "bank", "ussd", "qr", "mobile_money"]. Here's an example of usage: channels={JSON.stringify(["card","ussd"])} default: "card"
onCancel callback function if user cancels or payment transaction could not be verified. In a case of not being verified, transactionRef number is also returned in the callback default: nill
onSuccess callback function if transaction was successful and verified (it will also return the transactionRef number in the callback ) default: nill
autoStart Auto start payment once page is opened default: false
refNumber Reference number, if you have already generated one default: ''+Math.floor((Math.random() * 1000000000) + 1)
handleWebViewMessage Will be called when a WebView receives a message default: true

Contributions

Want to help make this package even more awesome? Read how to contribute and feel free to send in your PR!

Licensing

This project is licensed under MIT license.

Related Projects

Video Tutorial

Don't forget to star, like and share :)

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Oluwatobi Shokunbi

πŸ’» πŸ“–

Akinyemi Mosolasi

πŸ“– πŸ’»

okechukwu0127

πŸ’»

Johney

πŸ’»

sammy

πŸ’»

Jimoh Jamiu

πŸ› πŸ“– πŸ’»

Cahak George

πŸ’»

John Ayeni

πŸ“–

majirieyowel

πŸ’»

David Erinayo Obidu

πŸ›

surafelbm

πŸ›

Rex Omiv

πŸ›

Osagie Osaigbovo Charles

πŸ›

Ujjalcha1

πŸ›

Oyefeso Oluwatunmise

πŸ›

This project follows the all-contributors specification. Contributions of any kind welcome!

About

πŸ’ΈπŸ’³The package allows you accept payment using paystack and guess what , it doesn't require any form of linking, just install and begin to use .

License:MIT License


Languages

Language:JavaScript 47.9%Language:TypeScript 23.7%Language:Kotlin 16.2%Language:Swift 5.6%Language:Ruby 3.3%Language:Starlark 1.6%Language:Objective-C 1.6%Language:Shell 0.2%