Masterpass Turkey Package for React Native

Masterpass Turkey Package for React Native,

Installation

npm install @macellan/react-native-masterpass-tr --save

or

yarn add @macellan/react-native-masterpass-tr

Install Dependencies

Please, install dependencies for using this package.

yarn add react-native-webview react-native-event-listeners

Usage

Wrap your parent component in Provider from react-native-masterpass-tr.

import * as React from 'react';
import { MasterPassProvider, IConfig } from 'react-native-masterpass-tr';

const ParentComponent: React.FC = () => {

  /* MasterPass Config Object */
  const config: IConfig = {
    token: '',
    serviceUrl: '',
    clientId: '',
    userId: '',
    sendSmsLanguage: '',
    sendSms: '',
    referenceNo: '',
    clientIp: '',
    sdkUrl: '',
  };

  return (
    <MasterPassProvider config={config}>
      <ChildComponent />
      {/* Other Child Components */}
    </MasterPassProvider>;
  );
}

export default ParentComponent;

Add MasterPassTurkey to the component you want to use.

import * as React from 'react';
import {
  MasterPassTurkey,
  IMasterPassTurkeyRefs,
} from 'react-native-masterpass-tr';

const ChildComponent: React.FC = () => {
  const masterpass = React.useRef<IMasterPassTurkeyRefs>(null);

  const onRegistrationCheck = React.useCallback(() => {
    masterpass.current
      ?.registrationCheck()
      .then((result) => {
        console.log(result);
      })
      .catch((error) => {
        console.log(error);
      });
  }, []);

  return <MasterPassTurkey ref={ref} />;
};

export default ChildComponent;

GitHub:

Source: https://github.com/macellan/react-native-masterpass-tr?ref=reactnativeexample.com

Default image
Lingaraj Senapati
Hey There! I am Lingaraj Senapati, the Co-founder of lingarajtechhub.com My skills are Freelance, Web Developer & Designer, Corporate Trainer, Digital Marketer & Youtuber.
Articles: 253

Newsletter Updates

Enter your email address below to subscribe to our newsletter