Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-tappay

Package Overview
Dependencies
Maintainers
0
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-tappay

TODO

  • 1.8.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

react-native-tappay react-native-tappay is released under the MIT license. npm version npm

Write once, run everywhere

Tappay is a great payment service provider which provide many popular payment method. We want to write once and run everywhere(Web/Android/iOS).

react-native-tappay is a wrapper around the iOS Tappay SDK , Android Tappay SDK and Web Tappay SDK, allowing for Tappay integration in React Native apps. Provided JS Code to call native functions.

This package aims to support functional usage without Form. So you can custom your component/behavior or intergrate with other library as you want.

Support react-native for web

Yes, this library support web usage(react-native-web), write once and runs on iOS/Android/Web.

PR Welcome

We use it on our production App/MWeb for 2 years. Keep update and PR welcome.

Tappay SDK support Version

Getting started

$ npm install react-native-tappay --save

or

$ yarn add react-native-tappay

React Native 0.60 and higher

On newer versions of React Native, linking is automatic.

React Native 0.59 and lower

$ react-native link react-native-tappay

iOS

CocoaPods on iOS needs this extra step:

$ cd ios
$ pod install
Android

Add these lines in your build.gradle:

flatDir {
  ...
+   dirs "$rootDir/../node_modules/react-native-tappay/android/libs"
  ...
}

Usage

Currently supports RBA setup

without RBA
import { useTapPay } from 'react-native-tappay';

function MyComponent() {
  const [isLoadedSuccess, TapPay] = useTapPay({ appId, appKey, env })

  return ...
}
with RBA
import { useTapPay } from 'react-native-tappay';

function MyComponent() {
  const [isLoadedSuccess, TapPay] = useTapPay({ appId, appKey, env, rbaId, rbaKey })

  return ...
}

Example

TapPay.cardSetup({
  fields: {
    number: {
      // css selector
      element: '#card-number',
      placeholder: '**** **** **** ****'
    },
    expirationDate: {
      // DOM object
      element: document.getElementById('card-expiration-date'),
      placeholder: 'MM / YY'
    },
    ccv: {
      element: '#card-ccv',
      placeholder: 'ccv'
    },
  },
  styles: {
    input: {
      color: 'gray',
    },
    'input.ccv': {
      'font-size': '16px',
    },
    'input.expiration-date': {
      'font-size': '16px',
    },
    'input.card-number': {
      'font-size': '16px',
    },
    ':focus': {
      color: warrior,
    },
    '.valid': {
      color: warrior,
    },
    '.invalid': {
      color: warrior,
    },
  },
});
TapPay.validateCard('4242424242424242', '01', '23', '123')
  .then(result => {
    console.log({
      "isCardNumberValid": result.isCardNumberValid,
      "isExpiredDateValid": result.isExpiredDateValid,
      "isCCVValid": result.isCCVValid,
      "cardType": result.cardType,
    });
  })
  .catch(error => {
    console.error(error);
  });
TapPay.setCard('4242424242424242', '01', '23', '123');
TapPay.onCardUpdate(update => {
  const { cardType, canGetPrime, status } = update;

  setCardType(cardType);
  setValidated(canGetPrime);
  setHasNumberError(status.number === 2);
  setHasExpiryError(status.expiry === 2);
  setHasCCVError(status.ccv === 2);
});
TapPay.getDirectPayPrime()
  .then(result => {
    console.log({
      "prime": result.prime,
      "bincode": result.bincode,
      "lastfour": result.lastfour,
      "issuer": result.issuer,
      "type": result.type,
      "funding": result.funding,
      "cardidentifier":result.cardidentifier,
    });
  })
  .catch(error => {
    console.error(error);
  });
TapPay.removeCard();

Props

NameTypeRequired
appIdnumberYES
appKeystringYES
envstringYES
rbaIdstringNO
rbaKeystringNO

Methods

cardSetup [Web Only]

Parameters: args: CardSetupArgs
Returns: void

CardSetupArgs

validateCard

Parameters: cardNumber: string, dueMonth: string, dueYear: string, CCV: string
Returns: void

setCard

Parameters: cardNumber: string, dueMonth: string, dueYear: string, CCV: string
Returns: void

onCardUpdate [Web Only]

Parameters: callback: (result: UpdateResult) => void
Returns: void

UpdateResult

getDirectPayPrime

Parameters: none
Returns: Promise<GetCardPrimeResolveValue>

GetCardPrimeResolveValue

removeCard

Parameters: none
Returns: Promise<GetCardPrimeResolveValue>

getLinePayPrime

Parameters: url: string
Returns: Promise<{ prime: string | null }>

isLinePayAvailable

Parameters: void
Returns: Promise<boolean>

handleLinePayURL

Parameters: url: string
Returns: Promise<boolean>

getApplePayPrime(IOS Only)

Parameters: MerchantData, CartData[CartItem]
Returns: Promise<{ prime: string | null }>

isApplePayAvailable(IOS/Web Only)

Parameters: void
Returns: Promise<boolean>

webSetupApplePay(Web Only)

Parameters: MerchantData, CartData[CartItem]
Returns: Promise<boolean>

webGetApplePayPrime(Web Only)

Parameters: void
Returns: Promise<{ prime: string | null }>

Types

CardSetupArgs

NameTypeContent
fields.number{ element: HTMLElement or string, placeholder: string }
fields.expirationDate{ element: HTMLElement or string, placeholder: string }
fields.ccv{ element: HTMLElement or string, placeholder: string }ccv is optional, if there is input, it will be validated, if there is no input, it will not.
If you don't want to display the ccv field, don't need to set.
stylesObjectSupported CSS - TapPay Fields Styles

UpdateResult

NameTypeContent
cardTypestringmastercard, visa, jcb, amex, unionpay, unknown
canGetPrimeboolean
hasErrorboolean
status.numbernumber0 = The field has been filled in and there is no problem
1 = The field has not been filled in yet
2 = Field error
3 = Typing
status.expirynumber0 = The field has been filled in and there is no problem
1 = The field has not been filled in yet
2 = Field error
3 = Typing
status.ccvnumber0 = The field has been filled in and there is no problem
1 = The field has not been filled in yet
2 = Field error
3 = Typing

MerchantData

NameTypeContent
merchantNamestring
merchantIdentifierstringyour ios certification merchantIdentifier
countryCodestring
currencyCodestring

CartItem

NameTypeContent
itemNamestring
pricenumber
GetCardPrimeResolveValue
NameTypeContent
primestring
bincodestring
lastfourstring
issuerstring
fundingnumber-1 = Unknown
0 = Credit Card
1 = Debit Card
2 = Prepaid Card
typenumber-1 = Unknown
1 = VISA
2 = MasterCard
3 = JCB
4 = Union Pay
5 = AMEX
cardidentifierstring
merchantReferenceInfo{ affiliate_codes: Array }

Suppported Payment

📄 License

react-native-tappay is MIT licensed, as found in the LICENSE file.

Keywords

FAQs

Package last updated on 11 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc