npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@paysafe/paysafe-google-pay

v2.2.1

Published

google pay integration

Downloads

339

Readme

React Native Paysafe Google Pay

Overview

The paysafe-google-pay package is part of the Paysafe PH mobile react native SDK. It provides a React Native integration for Google Pay using Paysafe mobile SDK. It allows developers to easily implement Google Pay functionality in their React Native applications.

Version

Current Version: 2.2.1

Requirements

  • React Native 0.76+ with the New Architecture enabled
  • @paysafe/paysafe-payments-sdk-common v2.2.1+
  • React 18.0.0+
  • Android only — this package is not supported on iOS

Apps on the legacy bridge should stay on @paysafe/paysafe-google-pay 1.x.

Installation

To install the package, run the following command:

npm install @paysafe/paysafe-google-pay@current-version

iOS Setup

This package is not supported for iOS.

Android Setup

  1. Install Java Development Kit (JDK)

    • Use Java 17 (for React Native 0.73+) or Java 11 for older versions.
    • Verify installation:
      java -version
  2. Install Android Studio

    • Download from developer.android.com/studio.
    • Open Android Studio → SDK Manager and install:
      • Android SDK Platform (latest stable, e.g., API 34 or 33)
      • Android SDK Build-Tools
      • Android SDK Command-line Tools
      • (Optional) Android Emulator
  3. Set Environment Variables

    • Add to your shell config (~/.zshrc or ~/.bashrc on macOS/Linux):
      export ANDROID_HOME=$HOME/Library/Android/sdk
      export PATH=$PATH:$ANDROID_HOME/emulator
      export PATH=$PATH:$ANDROID_HOME/platform-tools
    • On Windows, set ANDROID_HOME in System Environment Variables.
  4. Connect a Device or Emulator

    • Enable USB debugging on a physical device (Developer Options).
    • Or create a virtual device in Android Studio → Device Manager.

Usage

Import the package and call the promise-based API:

import { Platform } from 'react-native';
import { setup, getMerchantReferenceNumber } from '@paysafe/paysafe-payments-sdk-common';
import {
  initializeGooglePay,
  tokenizeGooglePay,
} from '@paysafe/paysafe-google-pay';
import type { GooglePayTokenizeOptions } from '@paysafe/paysafe-google-pay';

// 1. Initialize the shared Paysafe SDK (once per app session)
await setup(apiKey, 'TEST');

if (Platform.OS === 'android') {
  // 2. Initialize the Google Pay context for your account
  await initializeGooglePay('US', 'USD', accountId, true);

  // 3. Tokenize — resolves with { paymentHandleToken }
  const options: GooglePayTokenizeOptions = {
    amount: 1000,
    currencyCode: 'USD',
    transactionType: 'PAYMENT',
    merchantRefNum: await getMerchantReferenceNumber(),
    accountId,
    simulator: 'INTERNAL',
  };

  try {
    const { paymentHandleToken } = await tokenizeGooglePay(options);
    // Send paymentHandleToken to your server
  } catch (error) {
    const code =
      typeof error === 'object' && error !== null && 'code' in error
        ? String((error as { code?: string }).code)
        : '';

    if (code === 'GOOGLE_PAY_TOKENIZATION_CANCELED') {
      // User cancelled in the Google Pay sheet
    } else if (code === 'GOOGLE_PAY_TOKENIZATION_FAILED') {
      // Tokenization failed
    } else if (code === 'GOOGLE_PAY_INITIALIZATION_FAILED') {
      // Google Pay context initialization failed
    }
  }
}

This package must be added to a native Android React Native project (or an Expo prebuild / bare workflow). Expo Go is not supported.

API summary

| Function | Returns | Description | | --- | --- | --- | | initializeGooglePay(countryCode, currencyCode, accountId, requestBillingAddress) | Promise<void> | Initializes the native Google Pay context. Rejects with GOOGLE_PAY_INITIALIZATION_FAILED on failure. | | tokenizeGooglePay(options) | Promise<{ paymentHandleToken }> | Runs Google Pay tokenization. Rejects with GOOGLE_PAY_TOKENIZATION_FAILED or GOOGLE_PAY_TOKENIZATION_CANCELED. | | getPaymentMethodConfig() | Promise<GooglePayPaymentMethodConfig> | Returns merchant id, allowed auth methods, card networks, and billing-address flag. | | setupPaysafeSdk(apiKey, environment?) | Promise<void> | Delegates to setup from @paysafe/paysafe-payments-sdk-common. | | isPaysafeSdkInitialized() | Promise<boolean> | Delegates to isInitialized() from the common package. | | getMerchantReferenceNumber() | Promise<string> | Delegates to getMerchantReferenceNumber() from the common package. |

iOS / non‑Android

Google Pay is Android-only. initializeGooglePay, tokenizeGooglePay, and getPaymentMethodConfig reject with Google Pay is only available on Android devices on non‑Android. setupPaysafeSdk, isPaysafeSdkInitialized, and getMerchantReferenceNumber delegate to the common SDK and follow its platform behavior. You can import this package on iOS builds without registering the PaysafeGooglePay native module; the Turbo module is resolved lazily when a Google Pay API runs on Android.

Migrating from 1.x

v1.x exposed void methods; completion arrived via DeviceEventEmitter events such as GooglePayInitializedSuccessful, GooglePayInitializationFailed, GooglePayTokenizationSuccessful, GooglePayTokenizationFailed, and GooglePayTokenizationCanceled. SDK setup (setupPaysafeSdk, isPaysafeSdkInitialized, getMerchantReferenceNumber) lived on this native module.

v2.0.0 uses promises instead. Replace event listeners with await / .then() / .catch() on initializeGooglePay and tokenizeGooglePay. Rejection code values match the old event names in SCREAMING_SNAKE_CASE (for example GOOGLE_PAY_TOKENIZATION_CANCELED). Call setup from @paysafe/paysafe-payments-sdk-common (or the re-exported setupPaysafeSdk) for SDK initialization.

Documentation

For more information on getting started with the Google Pay package of Paysafe PH mobile react native SDK, please refer to the following link:

Documentation

Introduction to Paysafe PH mobile react native SDK