rn-ipay88-sdk
v1.0.14
Published
react-native ipay88
Downloads
2
Readme
react-native-i-pay88
Getting started
$ npm install rn-ipay88-sdk --save
Mostly automatic installation
$ react-native link rn-ipay88-sdk
Manual installation
iOS
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- Go to
node_modules
➜react-native-i-pay88
and addRNIPay88.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNIPay88.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainApplication.java
- Add
import tech.newtons.rnipay88module.RNIPay88Package;
to the imports at the top of the file - Add
new RNIPay88Package()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-i-pay88' project(':react-native-i-pay88').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i-pay88/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-i-pay88')
Usage
create data object and use Pay()
import { Pay } from 'rn-ipay88-sdk';
...
const data = {};
data.paymentId = '55';
data.merchantKey = YOUR_MECHANT_KEY;
data.merchantCode = YOUR_MECHANT_CODE;
data.referenceNo = ANY_UUID;
data.amount = AMOUNT;
data.currency = 'MYR';
data.productDescription = PRODUCT_DESCRIPTION;
data.userName = CUSTOMER_NAME;
data.userEmail = CUSTOMER_EMAIL;
data.userContact = CUSTOMER_CONTACT_NUMBER;
data.remark = ANY_EXTRA_REQUIREMENT;
data.utfLang = 'UTF-8';
data.country = YOUR_COUNTRY;
data.backendUrl = YOUR_SERVER_URL;
data.actionType = 'BT';
data.tokenId = '';
data.xfield1 = '';
const errs = Pay(data);
if (Object.keys(errs).length > 0) {
console.log(errs);
}
add listener to listen iPay88 return state
componentDidMount() {
if (Platform.OS === 'android') {
DeviceEventEmitter.addListener('ipay88:success', data => this.onSuccess(data));
DeviceEventEmitter.addListener('ipay88:failed', data => this.onFailed(data));
DeviceEventEmitter.addListener('ipay88:canceled', data => this.onCanceled(data));
}
}
onSuccess = (data) => {
console.log(data);
};
onCanceled = (data) => {
console.log(data);
};
onFailed = (data) => {
console.log(data);
};