1.0.16 • Published 4 years ago

@logisticinfotech/react-native-payfort-sdk v1.0.16

Weekly downloads
18
License
MIT
Repository
github
Last release
4 years ago

@logisticinfotech/react-native-payfort-sdk

Getting started

$ npm install @logisticinfotech/react-native-payfort-sdk --save

Mostly automatic installation

$ react-native link @logisticinfotech/react-native-payfort-sdk

Manual installation

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modules@logisticinfotech/react-native-payfort-sdk and add PayFort.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libPayFort.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Android

  1. Open up android/app/src/main/java/[...]/MainActivity.java
  • Add import com.RNPayfortSdk.RNPayfortSdkPackage; to the imports at the top of the file
  • Add new RNPayfortSdkPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:

    include ':@logisticinfotech/react-native-payfort-sdk'
    project(':@logisticinfotech/react-native-payfort-sdk').projectDir = new File(rootProject.projectDir,     '../node_modules/@logisticinfotech/react-native-payfort-sdk/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle:

      compile project(':@logisticinfotech/react-native-payfort-sdk')

Steps to follow before use

Android

  1. Download PayFort module file from here.
  2. Extract FORTSDKv1.5.zip.
  3. Open directory of android of your react native project in Android Studio.
  4. Click on File → New → New Module→ Select "Import .JAR/.AAR Packages" → Click on Next → Select FORTSDKv1.5.aar in File name → Click on Finish.

iOS

  1. Download PayFort SDK Module file from here.
  2. Extract PayFortSDK1.9.zip and open & copy PayFortSDK.bundle & PayFortSDK.framework to iOS directory of your project.
  3. Replace #import <PayFortSDK/PayFortView.h> to #import "PayFortView.h" and replace #import <PayFortSDK/PayFortController.h> to #import "PayFortController.h" in PayFortSDK.framework → Headers → PayFortSDK.h
  4. Copy path of PayFortSDK.h file from PayFortSDK.framework → Headers and add that path in Pods → Development Pods → react-native-payfort-sdk → PayFort.h as shown in screenshot npm.io
  5. Add pod 'JVFloatLabeledTextField' in the pod file.
  6. open iOS folder in terminal and run command "pod install" .

Usage

import { RNPayFort } from "@logisticinfotech/react-native-payfort-sdk/PayFortSDK/PayFortSDK";

onPay = async () => {
  await RNPayFort({
    command: "PURCHASE",
    access_code: "xxxxxxxxxxxxxxxxxx",
    merchant_identifier: "xxxxxxxxxx",
    sha_request_phrase: "xxxxxxxxxxxxxxxxxx",
    amount: 100,
    currencyType: "SAR",
    language: "en",
    email: "naishadh@logisticinfotech.co.in",
    testing: true,
  })
    .then((response) => {
      console.log(response);
    })
    .catch((error) => {
      console.log(error);
    });
};
Usage with sdk_token provided
import {
  getPayFortDeviceId,
  RNPayFort,
} from "@logisticinfotech/react-native-payfort-sdk/PayFortSDK/PayFortSDK";

getDeviceToken = async () => {
  getPayFortDeviceId().then(async (deviceId) => {
    await Axios.post("YOUR_WEB_URL_FOR_SDK_TOKEN_GENERATION", {
      deviceId: deviceId,
    })
      .then((response) => {
        this.setState({ sdk_token: response.data.sdk_token }, () => {
          this.onPay();
        });
      })
      .catch((error) => {
        console.log(error);
      });
  });
};

onPay = async () => {
  await RNPayFort({
    command: "PURCHASE",
    access_code: "xxxxxxxxxxxxxxxxxx",
    merchant_identifier: "xxxxxxxxxx",
    sha_request_phrase: "xxxxxxxxxxxxxxxxxx",
    amount: 100,
    currencyType: "SAR",
    language: "en",
    email: "naishadh@logisticinfotech.co.in",
    testing: true,
    sdk_token: this.state.sdk_token,
  })
    .then((response) => {
      console.log(response);
    })
    .catch((error) => {
      console.log(error);
    });
};
Note

There is no any difference between sdk_token provided and without provided.

  1. In case if you are not providing sdk_token then it will call payfort sdk_token generation api automatically without any worries.

  2. In case if you want to provide sdk_token manually then you have to first get deviceId from getPayFortDeviceId() method and pass deviceId as parameter to payfort sdk_token generation api, response of that api will give you sdk_token. Provide that sdk_token to parameters as above example.

npm.io

Note

  1. Before sending the amount value of any transaction, you have to multiply the value with the currency decimal code according to ISO code 3. For example: If the amount value was 500 AED; according to ISO code 3, you should multiply the value with 100 (2 decimal points); so it will be sent in the request as 50000. Another example: If the amount value was 100 JOD; according to ISO code 3, you should multiply the value with 1000 (3 decimal points); so it will be sent in the request as 100000.

  2. If you have unique merchant_reference then you can add to parameter, else system will generate unique merchant_reference by its own.

Basic properties

Parameter NameTypeMandatoryDescriptionLengthSpecial CharactersPossible/ Expected ValuesExample
commandAlphaCommand20"AUTHORIZATION" or "PURCHASE"
access_codeAlphanumericThis will be your unique access_code provided by payfort console.
merchant_identifierAlphanumericThis will be your unique merchant_identifier provided by payfort console.
sha_request_phraseAlphanumericThis will be your unique sha_request_phrase provided by payfort console.
amountNumericThe transaction's amount. *Each currency has predefined allowed decimal points that should be taken into consideration when sending the amount.1010000
currencyAlphaThe currency of the transaction’s amount in ISO code 3.3AED
languageAlphaThe checkout page and messages language.2"en" or "ar"
customer_emailAlphanumericThe customer's email.254_ - . @customer@domain.com
testingBooleanTesting or Production"true" or "false"
merchant_referenceAlphanumericThe Merchant’s unique order number.40_ - .XYZ9239-yu898
token_nameAlphanumericThe Token received from the Tokenization process.100_ - . @Op9Vmp
sdk_tokenAlphanumericYou can provide if you have sdk_token already generated from payfort api from your server side. Note: For this you will have to first generate deviceID from given method getPayFortDeviceId(), then provide deviceId as parameter for payfort sdk_token generation api.
payment_optionAlphaPayment option.10"MASTERCARD" or "VISA" or "AMEX" or "MADA (for Purchase operations and eci Ecommerce only)" or "MEEZA (for Purchase operations and ECOMMERCE eci only)"
eciAlphaE-commerce indicator.16ECOMMERCE
order_descriptionAlphanumericA description of the order.150# ' / . _ - : \$ SpaceiPhone 6-S
customer_ipAlphanumericIt holds the customer's IP address. *It's Mandatory, if the fraud service is active.45.192.178.1.10
customer_nameAlphaThe customer's name.40_ \ / - . ,John Smith
phone_numberAlphanumericThe customer’s phone number.19+ - ( ) Space0096279 7219966
settlement_referenceAlphanumericThe Merchant submits this value to the FORT. The value is then passed to the Acquiring bank and displayed to the merchant in the Acquirer settlement file.34. - _XYZ9239-yu898
merchant_extraAlphanumericExtra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.999. ; / _ - , ' @JohnSmith
merchant_extra1AlphanumericExtra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.250. ; / _ - , ' @JohnSmith
merchant_extra2AlphanumericExtra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.250. ; / _ - , ' @JohnSmith
merchant_extra3AlphanumericExtra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.250. ; / _ - , ' @JohnSmith
merchant_extra4AlphanumericExtra data sent by merchant. Will be received and sent back as received. Will not be displayed in any report.250. ; / _ - , ' @JohnSmith

Methods

getPayFortDeviceToken() : For generate deviceId to provide as parameter in sdk_token generation api.

RNPayFort(parameters) : For payment procedure.

Test Card Details

You want to test a transaction but you don’t have a credit card or user credentials for our other payments options? Well we’ve got your back, here you can find card numbers for any type of test you wish to do.

Credit Cards

Card typeNumberExpiry dateCVV / CVC
Visa400555000000000105/21123
MasterCard512345678901234605/21123
AMEX34567890123456405/211234

3-D Secure Credit Cards

Card typeNumberExpiry dateCVV / CVC
Visa455701234567890205/21123
MasterCard531358100012343005/21123
AMEX37420000000000405/211234

Local Payment Methods

Payment optionNumberExpiry dateCVV / CVC
Knet000000000105/171234
Payment optionNumberExpiry dateOTPPin
Naps421537550088324306/1712341234
Payment optionPayment IDPasswordOTP
SadadsadadOlpTest1234112358
Payment optionNumberCard type
E-dirham4724439901004942Gold Card

Digital Wallets

Payment optionNumberExpiry dateCVV / CVC
MasterPass400000000000000205/21123
Visa Checkout400000000000000205/21123

for more details, visit references Payfort Documentation and Payfort Mobile SDK

1.0.16

4 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago