npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-dhanyatra

v1.1.3

Published

React Native wrapper for Dhanyatra

Downloads

4

Readme

react-native-dhanyatra

npm NPM Version NPM Downloads install size

NPM

React Native wrapper around our Android and iOS mobile SDKs

The following documentation is only focussed on the react-native wrapper around our Android and iOS sdks. To know more about our react-native SDK, refer to the following documentation -

https://dhanyatra.brighthustle.in/docs/payment-gateway/react-native-integration/

To know more about Dhanyatra payment flow and steps involved, read up here: https://docs.dhanyatra.brighthustle.in/docs

Prerequisites

  • Learn about the Dhanyatra Payment Flow.
  • Sign up for a dhanyatra Account and generate the API Keys from the Dhanyatra Dashboard. Using the Test keys helps simulate a sandbox environment. No actual monetary transaction happens when using the Test keys. Use Live keys once you have thoroughly tested the application and are ready to go live.

Installation

Using npm:

npm install --save react-native-dhanyatra

or using yarn:

yarn add react-native-dhanyatra

For Expo Users:

npx expo install react-native-dhanyatra

Requirements

  • iOS 10.0+ / macOS 10.12+ / tvOS 10.0+ / watchOS 3.0+
  • Xcode 11+
  • Swift 5.1+

Linking

Automatic

For React Native 0.60+

# install
npm install react-native-dhanyatra --save
cd ios && open podfile # Change the platform from iOS 9.0 to 10.0
pod install && cd .. # CocoaPods on iOS needs this extra step
# run
yarn react-native run-ios

For React Native 0.59 and lower

  1. $ npm install react-native-dhanyatra --save // Install the Dhanyatra React Native Standard SDK using the npm command.

  2. react-native link react-native-dhanyatra // Link the SDK with React Native Project using Xcode.

  3. Drag the Dhanyatra.framework file from the Libraries folder and drop it under the root folder, for more info follow this link, after this go to Target > General Settings> Framework, Libraries and Embedded Content section, set the Embed status of Dhanyatra.framework to Embed & Sign.

  4. Also make sure the dhanyatra framework is added in the embedded binaries section and you have Always Embed Swift Standard Binaries set to yes in build settings.

Manual

Add the following line to your build targets in your Podfile

pod 'react-native-dhanyatra', :path => '../node_modules/react-native-dhanyatra'

Then run pod install

In XCode, in the project navigator:

  • Right click Libraries
  • Add Files to [your project's name]
  • Go to node_modules/react-native-dhanyatra
  • Add the .xcodeproj file

In XCode, in the project navigator, select your project.

  • Add the libRNDeviceInfo.a from the deviceinfo project to your project's Build Phases ➜ Link Binary With Libraries
  • Click .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure All is toggled on (instead of Basic).
  • Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React
  • Mark both as recursive (should be OK by default).

Run your project (Cmd+R)

  1. Open up android/app/src/main/java/[...]/MainApplication.java
  • Add import com.dhanyatra.rn.DhanyatraPackage; to the imports at the top of the file
  • Add new DhanyatraPackage() to the list returned by the getPackages() method
  1. Append the following lines to android/settings.gradle:
    include ':react-native-dhanyatra'
    project(':react-native-dhanyatra').projectDir = new File(rootProject.projectDir,   '../node_modules/react-native-dhanyatra/android')
  2. Insert the following lines inside the dependencies block in android/app/build.gradle: gradle implementation project(':react-native-dhanyatra')

Note for Expo Applications:

After adding the react-native-dhanyatra package,the option to prebuild the app must be used(this generates the android/ios platform folders in the project to use native-modules). Command for which,

npx expo prebuild

After which the application will be installed on the device/emulator.

npx expo run:[ios|android] --device

Usage

Sample code to integrate with Dhanyatra can be found in [App.tsx][App.tsx] in the included example directory.

To run the example, simply do the following in example directory and then link iOS SDK as explained in the previous section:

$ npm i

Steps

  1. Import DhanyatraCheckout module to your component:

    import DhanyatraCheckout from 'react-native-dhanyatra';
  2. Call DhanyatraCheckout.open method with the payment options. The method returns a JS Promise where then part corresponds to a successful payment and the catch part corresponds to payment failure.

    <TouchableHighlight onPress={() => {
    var options = {
     description: 'Credits towards consultation',
     image: '',
     currency: 'INR',
     key: '', // Your api key
     amount: '5000',
     name: 'foo',
     prefill: {
       email: '[email protected]',
       contact: '9191919191',
       name: 'Dhanyatra'
     },
     theme: {
         color: {
             text: '#ffa800',
             base: '#ffa800'
         }
     },
    }
    DhanyatraCheckout.open(options).then((data) => {
     // handle success
     alert(`Success: ${data.payment_id}`);
    }).catch((error) => {
     // handle failure
     alert(`Error: ${error.code} | ${error.description}`);
    });
    }}>

A descriptive list of valid options for checkout is available (under Manual Checkout column).

Proguard Rules

If you are using proguard for your builds, you need to add following lines to proguard files


-keepattributes _Annotation_
-dontwarn com.dhanyatra.**
-keep class com.dhanyatra.** {_;}
-optimizations !method/inlining/
-keepclasseswithmembers class _ {
public void onPayment\*(...);
}

Things to be taken care

  • The react native plugin is wrapper around native SDK, so it doesn't work with the tools like expo which doesn't support native modules.

FAQ's

  • For UPI Intent in iOS, the info.plist in iOS should be modified to include LSApplicationQueriesSchemes
    • For Bare React-Native Apps:
      • info.plist can directly be modified from the xcode project. LSApplicationQueriesSchemes takes as array value and can currently include only ["tez","phonepe","paytmmp"]
    • For Expo Apps:
      • Directly modifying info.plist is discouraged, and hence this should be added in app.json
        "ios": {
          "infoPlist": {
            "LSApplicationQueriesSchemes": [
               "tez",
               "phonepe",
               "paytmmp"
            ]
          }
        }
      • P.S: The apps won't be visible if the application is run with metro builder. The info.plist is generated successfully and integrated only when the app is built as standalone app.
  • Still having trouble with integrating our payment gateway? Follow this link for more info.

Contributing

See the CONTRIBUTING document. Thank you, contributors!

License

react-native-dhanyatra is Copyright (c) 2020 Bright Hustle Pvt. Ltd. It is distributed under the MIT License.

We ♥ open source software! See our other supported plugins / SDKs or contact us to help you with integrations.