Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including react-native-paytm with all npm packages installed. Try it out:

require("react-native/package.json"); // react-native is a peer dependency. var reactNativePaytm = require("react-native-paytm")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

react-native-paytm v1.0.4

A react native wrapper for PayTM

react-native-paytm

This library has been forked from https://github.com/elanic-tech/react-native-paytm Updated it to work with the latest version of react-native and latest PayTM SDK. Improved the documentaion as well.

Getting started

Alert: Built and tested only for iOS.

installation

Android

react-native link react-native-paytm

iOS

  1. In XCode, in the project navigator, right click LibrariesAdd Files to [your project's name]
  2. Go to node_modulesreact-native-paytm and add RNPayTm.xcodeproj
  3. In XCode, in the project navigator, select your project. Add libRNPayTm.a to your project's Build PhasesLink Binary With Libraries
  4. Run your project (Cmd+R)<

Usage

import paytm from 'react-native-paytm';
import { ..., Platform, DeviceEventEmitter, NativeModules, NativeEventEmitter, ... } from 'react-native';

....

// Daat received from PayTM
const paytmConfig = {
  MID: '...',
  WEBSITE: '...',
  CHANNEL_ID: '...',
  INDUSTRY_TYPE_ID: '...',
  CALLBACK_URL: 'https://securegw.paytm.in/theia/paytmCallback?ORDER_ID='
}

componentWillMount(){
    ...
    if(Platform.OS == 'ios'){
      const { RNPayTm } = NativeModules
      const emitter = new NativeEventEmitter(RNPayTm)
      emitter.addListener('PayTMResponse', this.onPayTmResponse)
    }else{
      DeviceEventEmitter.addListener('PayTMResponse', this.onPayTmResponse)
    }
    ...
}

onPayTmResponse(response) {
  // Process Response
  // response.response in case of iOS
  // reponse in case of Android
  console.log(response);
}

runTransaction(amount, customerId, orderId, mobile, email, checkSum) {
    const callbackUrl = `${paytmConfig.CALLBACK_URL}${orderId}`;
    const details = {
      mode: 'Staging', // 'Staging' or 'Production'
      mid: paytmConfig.MID,
      industryType: paytmConfig.INDUSTRY_TYPE_ID,
      website: paytmConfig.WEBSITE,
      channel: paytmConfig.CHANNEL_ID,
      amount: `${amount}`, // String
      orderId: orderId, // String
      email: email, // String
      phone: mobile, // String
      custId: customerId, // String
      checksumhash: checkSum, //From your server using PayTM Checksum Utility 
      callback: callbackUrl
    };
    paytm.startPayment(details);
}
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free