react-native-khalti-sdk
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

banner

react-native-khalti-sdk

React-native wrapper for khalti iOS and android sdks. Currently this sdk only supports payment through khalti.

example

To run the example clone the repo, go to the example folder, yarn , pod install and yarn ios/android.

Installation

npm install react-native-khalti-sdk

or

yarn add react-native-khalti-sdk

Android

Step 1

Create a folder named xml inside the res folder of android and add a file with name network_security_config.xml and paste the following code.

<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config cleartextTrafficPermitted="true" />
    <domain-config cleartextTrafficPermitted="true">
        <domain includeSubdomains="true">192.168.52.25</domain>
        <domain includeSubdomains="true">192.168.52.20</domain>
        <domain includeSubdomains="true">192.168.52.22</domain>
        <domain includeSubdomains="true">192.168.52.127</domain>
        <domain includeSubdomains="true">192.168.52.99</domain>
        <domain includeSubdomains="true">192.168.1.195</domain>
        <domain includeSubdomains="true">a.khalti.com</domain>
        <domain includeSubdomains="true">192.168.52.28</domain>
        <domain includeSubdomains="true">192.168.52.38</domain>
        <domain includeSubdomains="true">192.168.12.106</domain>
        <domain includeSubdomains="true">192.168.52.133</domain>
        <domain includeSubdomains="true">192.168.52.126</domain>
        <domain includeSubdomains="true">192.168.52.161</domain>
        <domain includeSubdomains="false">localhost</domain>
    </domain-config>
</network-security-config>

Step 2

Then goto the manifest.xml and add

android:allowBackup="true"
android:networkSecurityConfig="@xml/network_security_config"

in the application section.

Step 3

./gradlew clean

iOS

Step 1

Add url scheme as "KhaltiPayExampleScheme" in the URL types section.

Step 2

install cocoapods-user-defined-build-types

Step 3

Add the following in your podfile (see example ios for reference)

plugin 'cocoapods-user-defined-build-types'

enable_user_defined_build_types!

Step 3

Add the following line and run pod install

pod 'react-native-khalti-sdk', :build_type => :dynamic_framework

Usage

import KhaltiSdk from "react-native-khalti-sdk";

...
    try {
      const result = await KhaltiSdk.startKhaltiSdk(
        merchantKey,
        productName,
        productId,
        productUrl,
        amount,
        additionalData,
        'KhaltiPayExampleScheme'
      );
      console.log({ result });
    } catch (e) {
      console.log({ e });
    }

Contributing

Bhuwan GOD Kandel Aashan Ghimire

License

MIT

Package Sidebar

Install

npm i react-native-khalti-sdk

Weekly Downloads

8

Version

1.0.2

License

MIT

Unpacked Size

98.5 kB

Total Files

24

Last publish

Collaborators

  • andresh