1.0.4 • Published 1 year ago

react-native-directpay-ipg-plugin v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

react-native-directpay-ipg

React native SDK for DirectPay IPG

Installation

npm install react-native-directpay-ipg-plugin

Usage

import { IPGComponent, IPGStage } from 'react-native-directpay-ipg-plugin';

// ...

<IPGComponent
    stage={IPGStage.DEV}
    signature={signature}
    dataString={payload}
    callback={(data: any) => {
        console.log(JSON.stringify(data));
    }}
/>

How to make a payment?

  1. first select stage - IPGStage.DEV / IPGStage.PROD
  2. Create payment payload & signature from Server-side and parse signature and base64 encoded payload to IPGComponent

    Note: it's the best practice to create payload and signature from server side. otherwise the data will be compromised.

payload

Payload is a base64 encoded string that created from JSON payload string. Here is a sample object,

payload = {
   merchant_id : "xxxxxx",
   amount : "10.00",
   type : "ONE_TIME",
   order_id : "CP123456789",
   currency : "LKR",
   response_url : "https://test.com/response-endpoint",
   first_name : "Sam",
   last_name : "Perera",
   email : "user@email.com",
   phone : "0712345678",
   logo : "",
};

signature

Signature is HmacSHA256 hash of the base64 encoded payload string. The secret for HmacSHA256 can be found at developer portal.

createHmacSha256Hash(base64jsonPayload, secret);

Provide these two arguments to IPGComponent and you'll receive the reponse from callback function.


Read more at Documentation

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT