1.0.5 • Published 2 years ago

@payze/payze-rn v1.0.5

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

comment: <> (Stargazers)

MIT License

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

PropTypeDefaultNote
setPayMethod, RequiredMethod that takes single argument - Pay() method (see the signature, below).
closeButtonTitleStringcloseTitle of the modal's close button
closeButtonTextStyleObjectObject to stylise close button

Pay() method arguments

ArgumentTypeDefaultNote
cardNumberString, RequiredNumber of the card.
cardHolderString, RequiredHolder of the card.
expirationDateString, RequiredExpiration date of the card.
securityNumberString, RequiredCVC/CVV of the card.
transactionIdString, RequiredTransaction id given by Payze.
billingAddressString, RequiredBilling address of user (can be an empty string).
onSuccessMethod, RequiredMethod to be called after a successful transaction.
onErrorMethod, RequiredMethod 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.

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago