• Stars
    star
    119
  • Rank 289,080 (Top 6 %)
  • Language
    Java
  • License
    MIT License
  • Created almost 8 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

React Native wrapper for Razorpay's mobile SDKs

react-native-razorpay

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://razorpay.com/docs/payment-gateway/react-native-integration/

To know more about Razorpay payment flow and steps involved, read up here: https://docs.razorpay.com/docs

Prerequisites

  • Learn about the Razorpay Payment Flow.
  • Sign up for a Razorpay Account and generate the API Keys from the Razorpay 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-razorpay

or using yarn:

yarn add react-native-razorpay

For Expo Users:

npx expo install react-native-razorpay

Requirements

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

Linking

Automatic

iOS

For React Native 0.60+

# install
npm install react-native-razorpay --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-razorpay --save // Install the Razorpay React Native Standard SDK using the npm command.

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

  3. Drag the Razorpay.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 Razorpay.framework to Embed & Sign.

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

Manual

iOS (via CocoaPods)

Add the following line to your build targets in your Podfile

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

Then run pod install

iOS (without CocoaPods)

In XCode, in the project navigator:

  • Right click Libraries
  • Add Files to [your project's name]
  • Go to node_modules/react-native-razorpay
  • 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)

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

Note for Expo Applications:

After adding the react-native-razorpay 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 Razorpay can be found in index.js 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 RazorpayCheckout module to your component:

    import RazorpayCheckout from 'react-native-razorpay';
  2. Call RazorpayCheckout.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: 'https://i.imgur.com/3g7nmJC.png',
        currency: 'INR',
        key: '', // Your api key
        amount: '5000',
        name: 'foo',
        prefill: {
          email: '[email protected]',
          contact: '9191919191',
          name: 'Razorpay Software'
        },
        theme: {color: '#F37254'}
      }
      RazorpayCheckout.open(options).then((data) => {
        // handle success
        alert(`Success: ${data.razorpay_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.razorpay.**
-keep class com.razorpay.** {*;}
-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-razorpay is Copyright (c) 2020 Razorpay Software 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.

More Repositories

1

blade

Design System that powers Razorpay
TypeScript
436
star
2

ifsc

🏦 IFSC Codes Repository
HTML
326
star
3

go-financial

A go port of numpy-financial functions and more.
Go
301
star
4

razorpay-php

Razorpay PHP Library
PHP
169
star
5

razorpay-node

Razorpay node.js bindings
JavaScript
146
star
6

razorpay-python

Razorpay Python SDK
Python
146
star
7

devstack

Razorpay DevX cloud on laptop solution
Go
125
star
8

razorpay-flutter

Razorpay Flutter Plugin
Dart
105
star
9

razorpay-android-sample-app

Sample app demonstrating integration of Razorpay checkout
Java
86
star
10

ifsc-api

🏦 Standalone API for IFSC codes
CSS
75
star
11

concierge

Web Management & Secure Access Control of AWS Security Groups. Allows you to create IP leases for incoming connections to AWS instances. Also, allows creating invites to allow guest access by URL/Email Invites.Uses two factor authentication for additional security.
Go
68
star
12

razorpay-ruby

Razorpay Ruby SDK
Ruby
62
star
13

react-native-apollo-devtools

Flipper plugin to debug apollo client cache for React Native
TypeScript
57
star
14

razorpay-cordova

Cordova wrapper around Razorpay's Android and iOS SDKs
Shell
51
star
15

razorpay-java

Razorpay Java SDK
Java
50
star
16

metro

The Service Bus!
Go
48
star
17

shubhcron

A drop-in cron replacement that can run your jobs on auspicious timings.
Go
44
star
18

razorpay-woocommerce

Razorpay Payment Extension for Woocommerce
PHP
40
star
19

public-presentations

A curated list of public talks and articles by Razorpay
39
star
20

razorpay-go

Razorpay Go SDK
Go
33
star
21

alohomora

alohomora is razorpay's secret distribution system
Python
31
star
22

razorpay-php-testapp

Sample App for Razorpay PHP Integration
PHP
27
star
23

razorpay-magento

Razorpay Payment Extension for Magento
PHP
27
star
24

trino-gateway

Traffic routing for Trino Clusters
Go
24
star
25

razorpay-pod

πŸ“± CocoaPod implementation of Razorpay's Payment SDK. Refer for instructions:
Objective-C
22
star
26

razorpay-python-testapp

Razorpay test app for python
HTML
18
star
27

razorpay-cordova-sample-app

πŸ“± Razorpay Sample Application for Cordova, Ionic v1 and Ionic v2
JavaScript
16
star
28

opensource.razorpay.com

Razorpay Open Source showcase website
TypeScript
16
star
29

razorpay-opencart

Razorpay Payment Extension for Opencart
PHP
16
star
30

razorpay-whmcs

Razorpay Payment Extension for WHMCS
PHP
15
star
31

i18nify

Javascript library for internationalisation
TypeScript
14
star
32

razorpay-ios-sample-app

πŸ“± Sample app demonstrating integration of Razorpay iOS Framework
Objective-C
14
star
33

razorpay-android-custom-sample-app

Sample app to demonstrate the custom UI integration
Kotlin
13
star
34

razorpay-dot-net

Razorpay .NET SDK
C#
13
star
35

razorpay-edd

Razorpay plugin for Wordpress Easy Digital Downloads
PHP
11
star
36

razorpay-prestashop

Prestashop plugin for Razorpay
PHP
11
star
37

bhadra

Bhadra is a Vulnerability Management Platform to handle all security issues
HTML
11
star
38

razorpay-dotnet-testapp

Test app for .net integration
ASP.NET
10
star
39

lytics.js

Simpler analytics using HTML attributes.
JavaScript
10
star
40

razorpay-cscart

Razorpay Payment Extension for CS Cart
PHP
10
star
41

razorpay-capacitor

Capacitor wrapper around Razorpay's Android and iOS SDKs
TypeScript
10
star
42

razorpay-arastta

Razorpay Payment Extension for Arastta stores
PHP
9
star
43

sorting-hat

Post new signup data to Slack using the clearbit API
Ruby
8
star
44

razorpay-quick-payments

Razorpay Quick Payments plugin for WordPress
PHP
8
star
45

razorpay-woocommerce-subscriptions

Razorpay WooCommerce Subscriptions Plugin
PHP
6
star
46

razorpay-java-testapp

Sample app for Razorpay Java Integration
Java
5
star
47

darts

🎯 The Razorpay Dart Board Championship Hall of Fame
HTML
5
star
48

terraform-aws-ssl-ciphers

Common SSL Negotiation Policies to be used with AWS ELBs using Terraform
HCL
5
star
49

common-frontend-utils

Common Frontend Utils
JavaScript
5
star
50

component.js

Simple and Opinionated way to build UI Components
JavaScript
5
star
51

wercker-ubuntu14.04-ansible1.6

Ubuntu 14.04 with Ansible 1.6 box for http://wercker.com/
5
star
52

gollum-setup

Scripts to help you setup gollum
Ruby
3
star
53

teamcolony-rss

RSS Feed generator for teamcolony reports
Ruby
3
star
54

razorpay-customui-pod

iOS CustomUI SDK of Razorpay
Objective-C
3
star
55

kong-template

Kong template for plugin development
Lua
3
star
56

.github

Razorpay's Public Profile Page
3
star
57

razorpay-flutter-customui

Razorpay Flutter Plugin for Customui
Dart
2
star
58

cryptocows-whitepaper

Technical Documentation for Razorpay CryptoCows
2
star
59

ftx-hackathon

Wiki for the FTX Hackathon
2
star
60

citadel

Documentation Platform
JavaScript
1
star
61

etcd-backup

Docker file for etcd-backup running as a k8s cron job.
Shell
1
star
62

go-openssl

OpenSSL bindings for Golang
Go
1
star
63

dot-settings

JavaScript
1
star
64

subscriptions-magento-plugin

Subscriptions plugin for magento.
PHP
1
star
65

RazorpaySalesDemo

CSS
1
star
66

payment-button-wordpress-plugin

Payment button plugin for wordpress.
PHP
1
star
67

omnipay-razorpay

Razorpay plugin for Omnipay Payment Processing Library
PHP
1
star