react-native-paymob-accept
Getting started
$ npm install react-native-paymob-accept --save
Mostly automatic installation
$ react-native link react-native-paymob-accept
$ cd ios && pod install
for older versions
Add the below line at the top of your PodFile, if using Pod
use_modular_headers!
Update your PodFile React dependency to look like this
pod 'React', :path => '../node_modules/react-native', :modular_headers => true
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec', :modular_headers => false
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec', :modular_headers => false
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-paymob-accept
and addRNPaymobAccept.xcodeproj
- In XCode, in the project navigator, select your project. Add
libRNPaymobAccept.a
to your project'sBuild Phases
➜Link Binary With Libraries
- Run your project (
Cmd+R
)<
Android
- Open up
android/app/src/main/java/[...]/MainActivity.java
- Add
import com.breadfast.reactnative.RNPaymobAcceptPackage;
to the imports at the top of the file - Add
new RNPaymobAcceptPackage()
to the list returned by thegetPackages()
method
- Append the following lines to
android/settings.gradle
:include ':react-native-paymob-accept' project(':react-native-paymob-accept').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-paymob-accept/android')
- Insert the following lines inside the dependencies block in
android/app/build.gradle
:compile project(':react-native-paymob-accept')
- add repository as below
allprojects { repositories { google() ... maven { url "https://dl.bintray.com/paymobsolutions/paymob_accept_sdk" } } }
- Add to your AndroidManifest.xml
xmlns:tools="http://schemas.android.com/tools"
and
android:allowBackup="false"
android:supportsRtl="true"
tools:replace="android:supportsRtl, android:allowBackup"
to look like this
- add action bar styles to styles.xml
<!-- Customize your theme here. --> <!-- <item name="android:windowNoTitle">true</item> --> @android:color/transparent #030 #543 #909
- (OPTIONAL) You can control the wording anf styles by adding the below resources to your styles.xml or values.xml resources
<!-- Paymob SDK params--> #CC0bd796 #CC0bd796 #96b1bc @color/colorPrimaryDark @color/colorPrimaryDark #4F7283 20dp 15sp 15dp 14sp 10dp 5dp Card Number must be 16 digits! CVV must be 3 digits! Invalid Date! Name can not be empty Expiry Date Powered by app_id AcceptSDK Card Holder Name Card Information Card Number CVV --> TEST <!-- <string name="pref_file_name">shared_pref</string> <string name="processing">Processing payment...</string> <string name="save_card"> This Card will be saved for future use </string> <string name="wait">Please wait...</string>
Usage
Payment with Token
; RNPaymobAccept;
Prop | Description | Type | Default |
---|---|---|---|
paymentKey |
Generated one-time payment key | String | Required |
token |
user token | String | Required |
maskedPanNumber |
last four digits | String | Required |
activityTitle |
title for the 3d secure Screen | String | Optional |
firstName |
TODO | String | Optional |
lastName |
TODO | String | Optional |
building |
TODO | String | Optional |
floor |
TODO | String | Optional |
apartment |
TODO | String | Optional |
city |
TODO | String | Optional |
state |
TODO | String | Optional |
country |
TODO | String | Optional |
email |
TODO | String | Optional |
phoneNumber |
TODO | String | Optional |
postalCode |
TODO | String | Optional |
Payment with No Token
; RNPaymobAccept;
Prop | Description | Type | Default |
---|---|---|---|
paymentKey |
Generated one-time payment key | String | Required |
showSaveCard |
show save card checkbox | Boolean | Required |
saveCardDefault |
default boolean for saving card | Boolean | Required |
showAlerts |
show popup alerts | Boolean | Required |
isEnglish |
Language English or Arabic | Boolean | |
Required | |||
hideActionBar |
hide action bar (Android Only) | Boolean | Optional |
isEnglish |
Language English or Arabic | Boolean | Optional |
activityTitle |
title for the 3d secure Screen (Android Only) | String | Optional |
firstName |
TODO | String | Optional |
lastName |
TODO | String | Optional |
building |
TODO | String | Optional |
floor |
TODO | String | Optional |
apartment |
TODO | String | Optional |
city |
TODO | String | Optional |
state |
TODO | String | Optional |
country |
TODO | String | Optional |
email |
TODO | String | Optional |
phoneNumber |
TODO | String | Optional |
postalCode |
TODO | String | Optional |
Callbacks functions
onSuccess function
Prop | Description | Type | Default |
---|---|---|---|
status |
boolean to determine whether transaction was done successfully or not | Boolean | Optional |
code |
result code generated by SDK | String | Optional |
message |
error message mapped from result code | String | Optional |
(status: boolean, code: number, message)=>{
... add your success code block here
}