1.0.3 • Published 3 months ago

react-native-ozow v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

React Native Ozow

React Native Ozow is a React Native library for integrating Ozow payment gateway into your React Native app. It supports both In-App and Link payments.

This is not an official Ozow library.

npm npm GitHub issues [GitHub stars] [GitHub license] Twitter [GitHub contributors] [GitHub last commit] [GitHub pull requests] [GitHub pull requests] [GitHub forks] [GitHub stars] [GitHub watchers]

Check out my other libraries

Table of contents

Getting started

npm install react-native-ozow

Expo?

npx expo install react-native-ozow

Documentation

  • For more information, please visit Ozow API

Usage

Demos

In-App Payments Link Payments

In-App Payments

import { Ozow } from "react-native-ozow";

const MyPaymemt = () =>{
    return(
        <Ozow
            data={{
                SiteCode: "RPI-RPI-300",
                Amount: 1000, // in rands
                TransactionReference: "1234567",
                BankReference: "123456",
                CancelUrl: "https://ozow.com",
                ErrorUrl: "https://ozow.com",
                SuccessUrl: "https://ozow.com",
                NotifyUrl: "https://ozow.com",
                }}
            privateKey="f276b028..."
            onErrorMessage={...}
            onPaymentCancel={(data) => {...}}
            onPaymentSuccess={(data) => {...}}
      />
    )
}

export default MyPaymemt;

Props

PropTypeDescriptionRequired
dataobjectData to be sent to Ozow APIYes
privateKeystringPrivate key generated from OzowYes
onErrorMessagefunctionCallback function to handle error messageNo
onPaymentCancelfunctionCallback function to handle payment cancellationNo
onPaymentSuccessfunctionCallback function to handle payment successNo
onPaymentErrorfunctionCallback function to handle payment errorNo

Data

PropTypeDescriptionRequired
SiteCodestringSite code generated from OzowYes
AmountnumberAmount to be paid in randsYes
TransactionReferencestringTransaction reference to be sent to OzowYes
BankReferencestringBank reference to be sent to OzowYes
CancelUrlstringUrl to be redirected to when payment is cancelledYes
ErrorUrlstringUrl to be redirected to when payment has an errorYes
SuccessUrlstringUrl to be redirected to when payment is successfulYes
NotifyUrlstringUrl to be redirected to when payment is successfulYes
Customerstring or numberThe customer’s name or identifier.No
IsTestbooleanRun on test mode when trueNo (default false)
styleobjectStyle passed to the WebView componentNo

In-App Payments Response example

{
  "Amount": "1.00",
  "BankName": "Capitec+Pay",
  "CurrencyCode": "ZAR",
  "Hash": "e2a02f05650f7468963776e8d6...73baf3835",
  "IsTest": "true",
  "Optional1": "",
  "Optional2": "",
  "Optional3": "",
  "Optional4": "",
  "Optional5": "",
  "SiteCode": "IPR-IPR-003",
  "Status": "Complete", // or "Cancelled" or "Error"
  "StatusMessage": "Test+transaction+completed",
  "TransactionId": "e315bf89-...-9823ef5d3d41",
  "TransactionReference": "12345671"
}

Link Payments

import { PaymentLink } from "react-native-ozow";

const myLink = new PaymentLink("9219...[API_KEY]", "f276...[PRIVATE_KEY]");

...
        <Button
          title="Get Payment Link"
          onPress={async () => {
            const results = await myLink.generateLink({
              SiteCode: "IPR...[SITE_CODE]]",
              CountryCode: "ZA",
              CurrencyCode: "ZAR",
              Amount: 10,
              TransactionReference: "1234567",
              BankReference: "123456",
              CancelUrl: "https://ozow.com",
              ErrorUrl: "https://ozow.com",
              SuccessUrl: "https://ozow.com",
              NotifyUrl: "https://ozow.com",
              IsTest: false,
              Customer: "John Doe",
            }, false);

            setLink(results.url);

            console.log(myLink.getPaymentLink()); //Get last generated link
          }}
        />
...

PaymentLink Params

ParamTypeDescriptionRequired
API_KEYstringAPI key generated from OzowYes
PRIVATE_KEYstringPrivate key generated from OzowYes

PaymentLink Methods

MethodParamsDescriptionRequired
generateLinkdata: object, isTest: booleanData to be sent to Ozow APIYes
getPaymentLinknoneGet last generated linkNo

PaymentLink Data

See In-App Payments Data

PaymentLink Response example

{
  "errorMessage": null,
  "paymentRequestId": "77cc0a3f-c4cc-40fd-9048-de78d9a03ce0",
  "url": "https://pay.ozow.com/77cc0a3f-c4cc-40fd-9048-de78d9a03ce0/Secure"
}

Author

Author

  • Axole Maranjana Twitter Follow GitHub followers Instagram LinkedIn

Help wanted!

Credits

Support

  • If you need help with this project or you want to report a bug, please open an issue on GitHub

Donate