Index of every page on this site: llms.txt
All skills
gmi-software avatar

/react-native-pay

@443959a
Run it yourself

Expert guide to @gmisoftware/react-native-pay — Apple Pay and Google Pay for React Native through Nitro Modules, with a unified usePaymentCheckout hook and native ApplePayButton / GooglePayButton views. Use when adding Apple Pay or Google Pay, configuring merchant IDs, entitlements, or the Expo config plugin, when the pay button does not appear or Google Pay reports unavailable, when handling a payment token on a backend, when testing payments, and when reasoning about what this library does and does not do with money.

  • 10 files
  • 95.5 KB
  • MIT
  • Updated 3 months ago
  • GitHub
Use this Skill: https://skilld.dev/gh/gmi-software/better-skills/react-native-pay

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesarchitecture.md

≈2.1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Native architecture

How the package is wired together, and where the two platforms diverge. Verified at v0.0.16 (2078fdd).

Layers

your app
  │
  ├─ usePaymentCheckout            src/hooks/usePaymentCheckout.ts      (JS)
  ├─ helpers, types                src/utils, src/types                (JS)
  │
  ├─ HybridPaymentHandler          src/index.ts → createHybridObject   (JS boundary)
  ├─ ApplePayButton                src/index.ts → getHostComponent
  └─ GooglePayButton               src/index.ts → getHostComponent
       │
       │  Nitro specs: src/specs/*.nitro.ts
       │  nitrogen output: nitrogen/generated/{ios,android,shared}
       ▼
  ios/HybridPaymentHandler.swift   ──▶ PassKit
  ios/HybridApplePayButton.swift   ──▶ PKPaymentButton
  android/.../HybridPaymentHandler.kt      ──▶ Google Play Services Wallet
  android/.../HybridGooglePayButton.kt     ──▶ com.google.android.gms.wallet.button.PayButton

There is no hand-written payment logic in C++. The only C++ file in the package is android/src/main/cpp/cpp-adapter.cpp, a nine-line JNI_OnLoad that calls nitrogen's registerAllNatives(). The cpp/** glob in NitroPay.podspec matches nothing. The only native code you would ever edit is Swift and Kotlin.

Nitro specs

Three specs, in src/specs/:

// PaymentHandler.nitro.ts
export interface PaymentHandler
  extends HybridObject<{ ios: 'swift'; android: 'kotlin' }> {
  payServiceStatus(): PayServiceStatus              // synchronous
  startPayment(request: PaymentRequest): Promise<PaymentResult>
  canMakePayments(usingNetworks: string[]): boolean // synchronous
}
// ApplePayButton.nitro.ts  →  HybridView<..., { ios: 'swift' }>
// GooglePayButton.nitro.ts →  HybridView<..., { android: 'kotlin' }>

The platform maps in those type parameters are the reason the buttons are platform-exclusive: no Android implementation of ApplePayButton is generated, so rendering it on Android fails to find a component.

nitro.json binds spec names to implementations:

Spec iOS Android
PaymentHandler HybridPaymentHandler (Swift) HybridPaymentHandler (Kotlin)
ApplePayButton HybridApplePayButton (Swift) —
GooglePayButton — HybridGooglePayButton (Kotlin)

cxxNamespace is ["pay"], iosModuleName is NitroPay, androidCxxLibName is NitroPay, and the Kotlin package is com.margelo.nitro.pay.

Regenerate bindings after editing a spec:

cd package && bun run specs   # tsc && nitrogen --logLevel="debug"

Commit the regenerated nitrogen/generated output — it is checked in and shipped in the npm files array.

Two HybridObject instances

// src/index.ts
export const HybridPaymentHandler =
  NitroModules.createHybridObject<PaymentHandler>('PaymentHandler')
// src/hooks/usePaymentCheckout.ts
const HybridPaymentHandler =
  NitroModules.createHybridObject<PaymentHandler>('PaymentHandler')

Both run at module scope, so they execute on import, before any component renders. Two consequences:

  • Importing anything from the package without the native module present throws at import time, not at call time. This is why a Jest suite needs a react-native-nitro-modules mock — see testing.md.
  • The hook and the exported handler are separate native instances. On Android that means two instances each registering as an ActivityEventListener, and each with its own currentEnvironment and paymentPromise. Mixing the hook's startPayment with the exported HybridPaymentHandler.startPayment in one app is untested territory; pick one.

Where the platforms diverge

The specs are shared; the semantics are not. This table is the single canonical list — the per-platform detail lives in apple-pay.md and google-pay.md.

Behaviour iOS Android
Native API PassKit (PKPaymentAuthorizationViewController, deprecated) Play Services Wallet (PaymentsClient)
supportedNetworks Honoured Ignored — four networks hardcoded
merchantCapabilities Honoured (3DS/EMV/Credit/Debit) Ignored
canMakePayments() Real PassKit capability check String comparison against a fixed list
payServiceStatus() Instant, in-process Blocks up to ~10s on two isReadyToPay awaits
canSetupCards Always effectively false (empty networks array) Real isReadyToPay with existingPaymentMethodRequired: false
Environment switch None — Apple has no test environment flag googlePayEnvironment, defaults to TEST
Authorization result Hardcoded .success after 1s Genuine Activity result code
token.transactionIdentifier Real PassKit value Fresh UUID
result.transactionId Fresh UUID Fresh UUID (a different one)
token.paymentData base64 of PassKit's encrypted blob Google's gateway token string
paymentMethod.type Real (credit/debit/prepaid/store/unknown) Always unknown
paymentMethod.network Real Real network name, but unknown values fall back to visa
secureElementPass, billingAddress Populated when available Always null
Billing/shipping contact fields Honoured Ignored
Logging None at all Log.d on every request
Button reuse Rebuilt on every prop update Early-returns when props are unchanged
Total row Synthetic row added when >1 item totalPrice computed; label always "Total"

Everything in the "Ignored" rows type-checks and runs without error. That is the trap: identical JavaScript produces materially different sheets.

Threading and concurrency

iOS. startPayment immediately hops to DispatchQueue.main.async; PassKit requires main-queue presentation. The delegate's success path schedules on main as well. paymentCompletion, currentPaymentRequest, and delegate are plain stored properties with no synchronisation.

Android. startPayment runs on the caller's thread (the JS thread) up to AutoResolveHelper.resolveTask, then the result arrives on the main thread via onActivityResult. payServiceStatus() blocks the caller with Tasks.await.

Neither platform guards against overlapping payments. Both keep exactly one pending completion/promise field, so:

// don't do this — the first promise never settles
void HybridPaymentHandler.startPayment(a)
void HybridPaymentHandler.startPayment(b)

Serialise in JavaScript. usePaymentCheckout gives you isProcessing for exactly this, but it does not itself reject a concurrent call — it sets state and calls through.

Build configuration

Value File
Android minSdk 26 android/gradle.properties
Android compileSdk / targetSdk 36 android/gradle.properties
Kotlin 2.1.20 android/gradle.properties
NDK 29.0.14206865 android/gradle.properties
AGP 8.13.0 android/build.gradle
Java source/target 1.8 android/build.gradle
Play Services Wallet 19.3.0 android/build.gradle
iOS platforms min_ios_version_supported, visionOS 1.0 NitroPay.podspec
Pod name NitroPay NitroPay.podspec

android/build.gradle applies fix-prefab.gradle, a workaround that reorders prefab publication relative to the native build. If you see prefab or CMake errors, confirm it is still applied.

Note that the podspec declares :visionos => 1.0, but there is no visionOS-specific code and PassKit's availability there is untested by this package. Treat visionOS as unverified.

GOOGLE_PAY_ENVIRONMENT=TEST in android/gradle.properties is dead configuration — no source file reads it. The environment comes from the request at runtime.

What is not here

  • No C++ implementation beyond the generated JNI entry point.
  • No native unit tests (no XCTest, no Robolectric, no instrumentation).
  • No Objective-C++ beyond nitrogen's generated autolinking.
  • No AndroidManifest.xml content of its own — the library's manifest is empty.
  • No DIRECT Google Pay tokenization; only PAYMENT_GATEWAY.
  • No shipping-method or contact-selection callbacks on either platform.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No third-party reports yet.

Signed by skilld at 443959a. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 3 months ago
Other metadata
metadata
{
  "package": "@gmisoftware/react-native-pay",
  "version": "0.0.16",
  "commit": "2078fdda8bdef87b51d20039d7684a255f0baadc",
  "verified": "2026-08-21",
  "repository": "https://github.com/gmi-software/react-native-pay",
  "audience": "library users and library contributors",
  "tags": "react-native, payments, apple-pay, google-pay, passkit, wallet, nitro, expo, ios, android, checkout"
}

README badge

README badge for gmi-software/better-skills/react-native-pay