From e7f48a7d54ba7ffcfcace8455422b1f4d069c041 Mon Sep 17 00:00:00 2001 From: Jakub Kasprzyk Date: Mon, 23 Nov 2026 10:34:46 +0100 Subject: [PATCH 1/2] feat(android): pix and ewallet Google Pay buttons Fixes #91 --- CHANGELOG.md | 4 +++ README.md | 4 ++- docs/docs/api/components.md | 4 ++- .../nitro/pay/GooglePayButtonFactory.kt | 4 ++- .../nitro/pay/GooglePayButtonFactoryTest.kt | 29 +++++++++++++++++++ .../android/c++/JGooglePayButtonType.hpp | 6 ++++ .../margelo/nitro/pay/GooglePayButtonType.kt | 4 ++- .../shared/c++/GooglePayButtonType.hpp | 8 +++++ package/src/specs/GooglePayButton.nitro.ts | 2 ++ 9 files changed, 61 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e479f6e..7316e776 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ All notable changes to this project are documented in this file. ### Added +- **`pix` and `ewallet` Google Pay buttons.** `GooglePayButtonType` adds `'pix'` and `'ewallet'`, + Google's `PIX` and `EWALLET` button types. `'pix'` shows "Direct Pix payment"; Google Play + services draws `'ewallet'` like `'buy'` so far. They change only the button: the sheet still + offers cards ([#91](https://github.com/gmi-software/react-native-pay/issues/91)). - **Apple Pay networks from iOS 26.2 to 27.** `PaymentNetwork` adds `conecs` (iOS 26.2), `elCorteIngles` (iOS 26.4) and `ruPay`, `verve`, `humo`, `uzCard`, `payPak`, `maal` and `elcard` (iOS 27). A request may name them, and a card on one of them is reported by name instead of diff --git a/README.md b/README.md index 80ff98c8..69943d2e 100644 --- a/README.md +++ b/README.md @@ -646,7 +646,9 @@ interface GooglePayButtonProps { | "order" | "pay" | "subscribe" - | "plain"; + | "plain" + | "pix" // "Direct Pix payment"; the sheet still offers cards + | "ewallet"; // Google's EWALLET type; the sheet still offers cards theme: "dark" | "light"; diff --git a/docs/docs/api/components.md b/docs/docs/api/components.md index 847eca76..583e00e0 100644 --- a/docs/docs/api/components.md +++ b/docs/docs/api/components.md @@ -74,10 +74,12 @@ Renders the Google Pay button. Only available on Android. The button can show the payer's card, so give it the same `supportedNetworks`, `googlePayAllowedAuthMethods`, `googlePayAllowPrepaidCards` and `merchantCapabilities` as the payment, under the same names. Otherwise it may show a card the payment then refuses. With `usePaymentCheckout`, pass them from `paymentRequest`. An invalid value (an unknown network, auth method or merchant capability, an empty `supportedNetworks` or `googlePayAllowedAuthMethods` list, or no network Google Pay offers) logs a warning in development, with the same rules as the payment. The button then keeps the cards it showed before, or the default cards on the first render, and still calls the current `onPress`. An empty `merchantCapabilities` list is valid and accepts credit and debit cards. **GooglePayButtonType:** -`'buy'` | `'book'` | `'checkout'` | `'donate'` | `'order'` | `'pay'` | `'subscribe'` | `'plain'` +`'buy'` | `'book'` | `'checkout'` | `'donate'` | `'order'` | `'pay'` | `'subscribe'` | `'plain'` | `'pix'` | `'ewallet'` `'donate'` is only for nonprofits that Google has validated. See [The `donate` button](/docs/setup/android-google-pay#the-donate-button). +`'pix'` and `'ewallet'` pass Google's `PIX` and `EWALLET` button types, which Google's API reference does not describe yet. `'pix'` shows "Direct Pix payment" next to the Google Pay logo. Google Play services draws the button, and in our tests (Play services 24.23 and 26.11) `'ewallet'` looked the same as `'buy'`. Both change only the button: the payment sheet still offers cards, because the library asks Google Pay for card payments only. + ### Example ```tsx diff --git a/package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt b/package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt index ec62ad94..ace53d6a 100644 --- a/package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt +++ b/package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt @@ -64,7 +64,7 @@ object GooglePayButtonFactory { /** * Maps GooglePayButtonType to ButtonConstants */ - private fun mapButtonType(type: GooglePayButtonType): Int { + internal fun mapButtonType(type: GooglePayButtonType): Int { return when (type) { GooglePayButtonType.BUY -> ButtonConstants.ButtonType.BUY GooglePayButtonType.BOOK -> ButtonConstants.ButtonType.BOOK @@ -74,6 +74,8 @@ object GooglePayButtonFactory { GooglePayButtonType.PAY -> ButtonConstants.ButtonType.PAY GooglePayButtonType.SUBSCRIBE -> ButtonConstants.ButtonType.SUBSCRIBE GooglePayButtonType.PLAIN -> ButtonConstants.ButtonType.PLAIN + GooglePayButtonType.PIX -> ButtonConstants.ButtonType.PIX + GooglePayButtonType.EWALLET -> ButtonConstants.ButtonType.EWALLET } } diff --git a/package/android/src/test/java/com/margelo/nitro/pay/GooglePayButtonFactoryTest.kt b/package/android/src/test/java/com/margelo/nitro/pay/GooglePayButtonFactoryTest.kt index aa63464d..119feca7 100644 --- a/package/android/src/test/java/com/margelo/nitro/pay/GooglePayButtonFactoryTest.kt +++ b/package/android/src/test/java/com/margelo/nitro/pay/GooglePayButtonFactoryTest.kt @@ -1,5 +1,6 @@ package com.margelo.nitro.pay +import com.google.android.gms.wallet.button.ButtonConstants import org.junit.Assert.assertEquals import org.junit.Test @@ -34,6 +35,34 @@ class GooglePayButtonFactoryTest { assertEquals(listOf("first", "second"), calls) } + @Test + fun mapButtonType_mapsEveryTypeToItsGooglePayButton() { + val expected = mapOf( + GooglePayButtonType.BUY to ButtonConstants.ButtonType.BUY, + GooglePayButtonType.BOOK to ButtonConstants.ButtonType.BOOK, + GooglePayButtonType.CHECKOUT to ButtonConstants.ButtonType.CHECKOUT, + GooglePayButtonType.DONATE to ButtonConstants.ButtonType.DONATE, + GooglePayButtonType.ORDER to ButtonConstants.ButtonType.ORDER, + GooglePayButtonType.PAY to ButtonConstants.ButtonType.PAY, + GooglePayButtonType.SUBSCRIBE to ButtonConstants.ButtonType.SUBSCRIBE, + GooglePayButtonType.PLAIN to ButtonConstants.ButtonType.PLAIN, + GooglePayButtonType.PIX to ButtonConstants.ButtonType.PIX, + GooglePayButtonType.EWALLET to ButtonConstants.ButtonType.EWALLET, + ) + + assertEquals(GooglePayButtonType.entries.toSet(), expected.keys) + for ((type, buttonType) in expected) { + assertEquals(type.name, buttonType, GooglePayButtonFactory.mapButtonType(type)) + } + } + + @Test + fun mapButtonType_givesEachTypeADifferentButton() { + val buttonTypes = GooglePayButtonType.entries.map(GooglePayButtonFactory::mapButtonType) + + assertEquals(buttonTypes.size, buttonTypes.toSet().size) + } + @Test fun pressListener_ignoresTapsWithoutAHandler() { // Does not throw. diff --git a/package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp b/package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp index 2a24892c..5c2af377 100644 --- a/package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp +++ b/package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp @@ -66,6 +66,12 @@ namespace margelo::nitro::pay { case GooglePayButtonType::PLAIN: static const auto fieldPLAIN = clazz->getStaticField("PLAIN"); return clazz->getStaticFieldValue(fieldPLAIN); + case GooglePayButtonType::PIX: + static const auto fieldPIX = clazz->getStaticField("PIX"); + return clazz->getStaticFieldValue(fieldPIX); + case GooglePayButtonType::EWALLET: + static const auto fieldEWALLET = clazz->getStaticField("EWALLET"); + return clazz->getStaticFieldValue(fieldEWALLET); default: std::string stringValue = std::to_string(static_cast(value)); throw std::invalid_argument("Invalid enum value (" + stringValue + "!"); diff --git a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt index 68c0a587..0067124c 100644 --- a/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt +++ b/package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt @@ -23,7 +23,9 @@ enum class GooglePayButtonType(@DoNotStrip @Keep val value: Int) { CHECKOUT(4), PAY(5), SUBSCRIBE(6), - PLAIN(7); + PLAIN(7), + PIX(8), + EWALLET(9); companion object } diff --git a/package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp b/package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp index 26c1dc27..09cfbb18 100644 --- a/package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp +++ b/package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp @@ -37,6 +37,8 @@ namespace margelo::nitro::pay { PAY SWIFT_NAME(pay) = 5, SUBSCRIBE SWIFT_NAME(subscribe) = 6, PLAIN SWIFT_NAME(plain) = 7, + PIX SWIFT_NAME(pix) = 8, + EWALLET SWIFT_NAME(ewallet) = 9, } CLOSED_ENUM; } // namespace margelo::nitro::pay @@ -57,6 +59,8 @@ namespace margelo::nitro { case hashString("pay"): return margelo::nitro::pay::GooglePayButtonType::PAY; case hashString("subscribe"): return margelo::nitro::pay::GooglePayButtonType::SUBSCRIBE; case hashString("plain"): return margelo::nitro::pay::GooglePayButtonType::PLAIN; + case hashString("pix"): return margelo::nitro::pay::GooglePayButtonType::PIX; + case hashString("ewallet"): return margelo::nitro::pay::GooglePayButtonType::EWALLET; default: [[unlikely]] throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum GooglePayButtonType - invalid value!"); } @@ -71,6 +75,8 @@ namespace margelo::nitro { case margelo::nitro::pay::GooglePayButtonType::PAY: return JSIConverter::toJSI(runtime, "pay"); case margelo::nitro::pay::GooglePayButtonType::SUBSCRIBE: return JSIConverter::toJSI(runtime, "subscribe"); case margelo::nitro::pay::GooglePayButtonType::PLAIN: return JSIConverter::toJSI(runtime, "plain"); + case margelo::nitro::pay::GooglePayButtonType::PIX: return JSIConverter::toJSI(runtime, "pix"); + case margelo::nitro::pay::GooglePayButtonType::EWALLET: return JSIConverter::toJSI(runtime, "ewallet"); default: [[unlikely]] throw std::invalid_argument("Cannot convert GooglePayButtonType to JS - invalid value: " + std::to_string(static_cast(arg)) + "!"); @@ -90,6 +96,8 @@ namespace margelo::nitro { case hashString("pay"): case hashString("subscribe"): case hashString("plain"): + case hashString("pix"): + case hashString("ewallet"): return true; default: return false; diff --git a/package/src/specs/GooglePayButton.nitro.ts b/package/src/specs/GooglePayButton.nitro.ts index 65d90ba6..b9866f52 100644 --- a/package/src/specs/GooglePayButton.nitro.ts +++ b/package/src/specs/GooglePayButton.nitro.ts @@ -13,6 +13,8 @@ export type GooglePayButtonType = | 'pay' | 'subscribe' | 'plain' + | 'pix' + | 'ewallet' export type GooglePayButtonTheme = 'dark' | 'light' From 921ef26010fbf73d271d4a7c7cecfbfb8d9cbdfe Mon Sep 17 00:00:00 2001 From: Jakub Kasprzyk Date: Mon, 23 Nov 2026 12:24:14 +0100 Subject: [PATCH 2/2] docs: note new GooglePayButtonType values --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7316e776..7b4a794f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,10 @@ All notable changes to this project are documented in this file. ### Changed +- **`GooglePayButtonType` has two more values**, `'pix'` and `'ewallet'` (see Added). An + exhaustive `switch` over `GooglePayButtonType`, or a `Record`, stops + compiling until it handles them ([#91](https://github.com/gmi-software/react-native-pay/issues/91)). + - **`PaymentNetwork` has nine more values**, so `token.paymentMethod.network` can report `conecs`, `elCorteIngles`, `ruPay`, `verve`, `humo`, `uzCard`, `payPak`, `maal` or `elcard` for a card it reported as `'unknown'` before (see Added). An exhaustive `switch` over