• Stars
    star
    153
  • Rank 243,368 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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="[email protected]"
        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="[email protected]"
        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={["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

πŸ›

Fuad Olatunji

πŸ“–

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

Roadmap

we have a lot to get done before we hit stable, here's a list;

  • Make the reference usage more user friendly
  • Since you want it to conform to InlineJS, let the variable names also match
  • Let the parameter types also conform to InlineJS parameter types
  • Paystack is a word, hence when used as a package name/class name, let it use PascalCase (Paystack) and when used as a variable, camelCase (paystack)

More Repositories

1

expo-push-notification-helper

πŸ’¬πŸ”₯This package helps you make expo push notification for React Native easy to use.
JavaScript
32
star
2

React-Native-Okra-Webview

πŸ₯¬πŸ’³ Official Okra SDK for React Native/Expo applications. Don't forget to star.
TypeScript
23
star
3

HostOnHeroku

πŸ₯³πŸš’Laravel application being hosted on heroku.
PHP
8
star
4

object-to-array-convert

πŸ β„ΉοΈ This package making it very easy to convert object to array and manipulate it
JavaScript
5
star
5

HostNextjsOnHeroku

JavaScript
4
star
6

iOS-Okra-WebView

πŸ₯¬πŸ’³ Official Okra SDK for iOS applications. Don't forget to star.
Swift
4
star
7

WebSocket-server-client-setup

minimal ExpressJS webscoket setup.
JavaScript
3
star
8

uuid-baker

Generate UUID on the go.
3
star
9

react-native-header-types

πŸ“±πŸ˜ŠFully customizable Header View for React Native.
JavaScript
2
star
10

Just1and0-portfolio

My personal site
HTML
2
star
11

React-native-evnProject

Learn how to use .env files in react native.
Objective-C
2
star
12

CaraCare

CaraCare code challenge.
TypeScript
2
star
13

where2get

πŸ’» :octocat: LocalHackDay team project. Where2get for mlh
PHP
1
star
14

just1and0

1
star
15

monee

ensembles lab project. digital bank
JavaScript
1
star
16

nacosssu

PHP
1
star
17

redux-setup-tutorial-session

A basic app setup of redux in a react native application.
JavaScript
1
star
18

bc_json_test

1
star
19

react-native-alert-modal

JavaScript
1
star
20

100daystorelearn-mobile1

100daystorelearn is a weekly challenge i started to probe me to relearn all i know from web to mobile and this repo i'd be trying to build a mobile app(UI) for renting car. UI by Shahin Srowar, link => https://dribbble.com/shots/6224543-Rent-A-Car-App-Exploration
1
star
21

HostNextjsOnNetlify

JavaScript
1
star
22

Fishery-ReactNative

Example of using Fishery in your React native project.
1
star
23

Fishery-ReactNative-example

Example of using Fishery in your React native project.
TypeScript
1
star
24

HostingOnHeroku

PHP
1
star
25

React-Native-Sum-Number

This package sums up two numbers.
JavaScript
1
star
26

gatsby-starter-netlify-cms

JavaScript
1
star
27

share-sdk

1
star
28

react-native-analytics-setup

a simple template for setting up Firebase Analytics in expo applications
1
star
29

KudaBankCodeChallenge

JavaScript
1
star
30

expo-travis-ci-cd-setup

An Expo CI setup template.
JavaScript
1
star
31

HealthApp

🩺πŸ₯ HealthApp using HealthKit and Swift to access health data.
TypeScript
1
star
32

getprospa.com-code-challange

JavaScript
1
star
33

react-native-add-number

React Native package to sum two numbers.
JavaScript
1
star
34

HostRNOnHeroku

An example of how to host your react native web application on heroku.
JavaScript
1
star
35

100daystorelearn-web1

1
star
36

React-Native-Fitbit-Webview

☘️πŸ₯This package allows you to authenticate users and get health vitals on Fitbit.
1
star
37

Google-Map-Helpers

πŸ—ΊοΈπŸ“To integrate Google-Maps easily with Javascript Libraries and Frameworks. (calculate distance between two points, convert lat and long to address etc)
1
star
38

Font-End-developers-Dos-and-donts

βŽπŸ‘¨β€πŸ’»βœ…Font-End developers Do's and don'ts with respect to javascript frameworks
1
star
39

react-localstorage-handler

πŸ“βš›οΈThis package helps handle localstorage data. get, set, delete item from local storage. It can even check if a key in localstorage
JavaScript
1
star