0.0.8 • Published 6 months ago

react-native-rego-googlepay v0.0.8

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

react-native-rego-googlepay

React Native library for adding cards to Google Pay

Installation

npm install react-native-rego-googlepay

You also have to add Google SDK for managing Google Pay to your android project in React Native.

Usage

import AddCardButton, { RegoGooglepay } from 'react-native-rego-googlepay';
import { DeviceEventEmitter } from 'react-native';

// ...

useEffect(() => {
  RegoGooglePay.isCardAlreadyAdded(cardSuffix).then((result) => {
    console.log(result);
  });

  DeviceEventEmitter.addListener(
    'onAddToGooglePayHidden',
    onAddToWalletViewHidden
  );

  DeviceEventEmitter.addListener(
    'onAddToGooglePayError',
    onAddToWalletViewError
  );

  return () => {
    DeviceEventEmitter.removeAllListeners('onAddToGooglePayHidden');
    DeviceEventEmitter.removeAllListeners('onAddToGooglePayError');
  };
}, []);

// ...

const pushProvisioning = {
  apiEndpoint: INSTANT_PROVISIONING_ENDPOINT,
  authorizationToken: AUTHORIZATION_TOKEN,
  cardDescription: CARD_DESCRIPTION,
  deviceId: getUniqueId() // getUniqueId from the react-native-device-info lib
};
const address = {
  addressLine1: ADDRESS_LINE_1,
  addressLine2: ADDRESS_LINE_2,
  locality: LOCALITY,
  name: NAME,
  administrativeArea: ADMINISTRATIVE_AREA,
  phoneNumber: PHONE_NUMBER,
  postalCode: POSTAL_CODE,
};
return (
  <AddCardButton
    style={styles.addCardToWalletButton}
    loading={isGooglePayLoading}
    onPress={() => {
      RegoGooglePay.handleAddToGooglePayClicked(pushProvisioning, address);
    }}
  />
);

License

MIT

0.0.8

6 months ago

0.0.5

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.4

7 months ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago

0.1.0

4 years ago