Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'`,
Comment thread
jkasprzyk17 marked this conversation as resolved.
Resolved
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
Expand Down Expand Up @@ -96,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<GooglePayButtonType, …>`, 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
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
4 changes: 3 additions & 1 deletion docs/docs/api/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package/src/specs/GooglePayButton.nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export type GooglePayButtonType =
| 'pay'
| 'subscribe'
| 'plain'
| 'pix'
| 'ewallet'

export type GooglePayButtonTheme = 'dark' | 'light'

Expand Down
Loading