Skip to content

payzeio/payze-react-native-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License


Logo

Payze React Native SDK

About The Project

Payze is the best software platform for running an internet business. We handle money movement flow for our customers by giving them tools they need.

Installation

Install the package in your project

npm install @payze/payze-rn

Installing dependencies

Payze SKD uses react-native-webview , so you need to install it in your project too

If you are using Expo, run:
expo install react-native-webview

and you should be good to go.

If you are running bare React Native project, run:
npm i react-native-webview

From react-native 0.60 autolinking will take care of the link step but don't forget to run pod install.

NOTE: If you ever need to uninstall React Native react-native-webview , run react-native unlink react-native-webview to unlink it.

iOS & macOS:

If using CocoaPods, in the ios/ or macos/ directory run:

$ pod install

Basic Usage

import React, { useRef } from 'react';
import  Payze  from  "@payze/payze-rn";

// Transaction id given by Payze
const  TRANSACTION_ID = "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";
const info = {
	cardNumber:  "123456789101",
	cardHolder:  "NAME SURNAME",
	expirationDate:  "01/22",
	securityNumber:  "000",
	billingAddress:  "Address",
};

export  default  function  App() {
	const payMethod = useRef();

	const  setPayMethod = (pay) => (payMethod.current = pay);

	const  onSuccess = () => alert("SUCCESS!");
	const  onError = (errorCode) => alert(`ERROR! ${errorCode}`);

	const pay = () => {
		payMethod.current(
			info.cardNumber,
			info.cardHolder,
			info.expirationDate,
			info.securityNumber,
			TRANSACTION_ID,
			info.billingAddress,
			onSuccess,
			onError
		);
	}

	return (
		...
		...
		<Payze  setPay={setPayMethod}  />
	)
}

For complete example, please visit Payze example project

Props

Prop Type Default Note
setPay Method, Required Method that takes single argument - Pay() method (see the signature, below).
closeButtonTitle String close Title of the modal's close button
closeButtonTextStyle Object Object to stylise close button

Pay() method arguments

Argument Type Default Note
cardNumber String, Required Number of the card.
cardHolder String, Required Holder of the card.
expirationDate String, Required Expiration date of the card.
securityNumber String, Required CVC/CVV of the card.
transactionId String, Required Transaction id given by Payze.
billingAddress String, Required Billing address of user (can be an empty string).
onSuccess Method, Required Method to be called after a successful transaction.
onError Method, Required Method to be called after an error while trying to process transaction, that takes errorCode as an argument.

Types

type errorCode {
	BAD_REQUEST:  1002,
	CARD_VERIFICATION_CANCELLED:  1003,
	TRANSACTION_FAILURE:  1004,
	UNKNOWN_ERROR:  1005,
}

License

Distributed under the MIT License. See LICENSE.txt for more information.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published