Nhảy tới nội dung

RN: PaymentSDK Initial setup

Enable deep linking in ANDROID:

  1. To create a link to your app content, add an intent filter that contains these elements and attribute values in your AndroidManifest.xml:
    1. Include the BROWSABLE category. It is required in order for the intent filter to be accessible from a web browser. Without it, clicking a link in a browser cannot resolve to your app.

      Also include the DEFAULT category. This allows your app to respond to implicit intents. Without this, the activity can be started only if the intent specifies your app component name.

      <category android:name="android.intent.category.DEFAULT" />
      <category android:name="android.intent.category.BROWSABLE" />
    2. To accept the URIs that begin with “chaipay://checkout“

      <data android:scheme="chaipay"
      android:host="checkout" />
      <data android:scheme="zalopay"
      android:host="pay" />
      <data android:scheme="momo"
      android:host="pay" />

Enable deep linking in iOS:

  1. To add the url schemes to the app, Go to ProjectSettings -> info


  2. Add inside the URL types


  1. Should include the application url schemes in info.plist


LSApplicationQueriesSchemes - Specifies the URL schemes you want the app to be able to use with the canOpenURL: method of the UIApplication class.

To use the library:

  1. Add .npmrc file to the project
  • In that file, add the following code and save it Screenshot 2022-05-09 at 4.49.31 PM.png

Screenshot 2022-05-09 at 4.49.56 PM.png

  1. Go. to project terminal, run the following code
npm install @iamport-intl/chaipay-sdk@latest

After successful installation, it will be shown in package.json under dependencies

Screenshot 2022-05-09 at 4.50.21 PM.png

  1. Import the library as below:
import Checkout from 'chaipay-sdk';
  1. Sample Payload containing the payment details:
var payload = {
"key": "lzrYFPfyMLROallZ",
"pmt_channel": ZALOPAY,
"pmt_method": ZALOPAY_WALLET,
"merchant_order_id": 'MERCHANT1628666326578',
"amount": 4499999,
"currency": "VND",
"order_details": [
"id": "knb",
"name": "kim nguyen bao",
"price": 4499999,
"quantity": 1
  1. Initialise the checkout instance as below:
env={"dev"} //Optional
secretKey={SECRET_KEY} // Secret Key
chaipayKey={CHAIPAY_KEY} // chaipay key
ParamsData typeMandatoryDescription
envStringyesenv type. e,g "dev" "prod"
callbackFunctionfuncyesreturns the success and failure callback.
redirectUrlStringyesredirect url for the app
secretKeyStringyesprovided secret key
chaipayKeyStringyesprovided chaipaykey

Sample Response Payload:

Success callback :

"chaipay_order_ref": "1wc00XMK4uKy3EeYBAvRPlkfjkZ",
"channel_order_ref": "210812000000171",
"merchant_order_ref": "MERCHANT1628742344516",
"status": "Success",
"status_code": "2000",
"status_reason": "SUCCESS"

Failure Callback:

"chaipay_order_ref": "1wa0choxhAy2QtE9ix8aNt8T3Mf",
"channel_order_ref": "0",
"merchant_order_ref": "MERCHANT1628681469666",
"status": "Initiated",
"status_code": "4000",

Steps for Signature Hash Generation

createHash: (
) => {
let mainParams =
'amount=' +
encodeURIComponent(amount) +
'&client_key=' +
encodeURIComponent(key) +
'&currency=' +
encodeURIComponent(currency) +
'&failure_url=' +
encodeURIComponent(failureUrl) +
'&merchant_order_id=' +
encodeURIComponent(merchantOrderId) +
'&success_url=' +
let hash = HmacSHA256(mainParams, secretKey);
let signatureHash = Base64.stringify(hash);
return signatureHash;