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: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ The library offers functions for seamless integration and use of the Apple Walle
| **getCardStatusBySuffix** | Retrieves the current status of a card in the wallet. | `lastDigits: string`<br>(The last few digits of the card number) | `CardStatus` | ✅ | ✅ |
| **getCardStatusByIdentifier** | Returns the state of a card based on a platform-specific identifier. On Android, it's `Token Reference ID` and on iOS, it's `Primary Account Identifier`. | `identifier: string`,<br>`tsp: string` | `CardStatus` | ✅ | ✅ |
| **hasEligibleTokenizationTarget** | Checks whether the card can still be added to a Google Wallet target (the phone or a paired wearable). Google recommends it for the "Add to Google Wallet" button when wearables are supported, because a card already on the phone can still be added to a watch. | `last4Digits: string`,<br>`network: string`,<br>`issuerName: string` | `boolean` | ❌ | ✅ |
| **addCardToGoogleWallet** | Initiates native Push Provisioning flow for adding a card to the Google Wallet. Requires a handler that returns the payment credentials for the UAPP flow. [Learn more →](./docs/UAPP.md) | `data`: `AndroidCardData`,<br>`handlePaymentCredentials`: `(data: onPaymentCredentialsRequestPayload) => Promise<AndroidPaymentCredentialsResponse>` | `TokenizationStatus` | ❌ | ✅ |
| **addCardToGoogleWallet** | Initiates native Push Provisioning flow for adding a card to the Google Wallet. Requires a handler that returns the payment credentials, called only for cards with `isGoogleOpaquePaymentCardSupported: true` (UAPP flow). [Learn more →](./docs/UAPP.md) | `data`: `AndroidCardData`,<br>`handlePaymentCredentials`: `(data: onPaymentCredentialsRequestPayload) => Promise<AndroidPaymentCredentialsResponse>` | `TokenizationStatus` | ❌ | ✅ |
| **resumeAddCardToGoogleWallet** | Resumes the Push Provisioning flow for adding a card to the Google Wallet using existing token reference ID. | `data`: `AndroidResumeCardData` | `TokenizationStatus` | ❌ | ✅ |
| **listTokens** | Lists all tokens currently stored in the Google Wallet. | None | `TokenInfo[]` | ❌ | ✅ |
| **listAppleWalletPasses** | Lists Apple Wallet Secure Element passes available to the app, including activation state and whether the pass is remote (for example on Apple Watch). Filter the result for `activationState === 'requireActivation'` or `activationState === 'pending'` to build a pending-cards UI. | None | `IOSWalletPass[]` | ✅ | ❌ |
Expand All @@ -203,7 +203,7 @@ A Wallet decline resolves `{ status: 'error', errorDomain, errorCode }` instead
| Type | Description | Fields |
|------|-------------|--------|
| **AndroidWalletData** | Specific information for Android devices required for wallet transactions. | `deviceID: string`,<br>`walletAccountID: string` |
| **AndroidCardData** | Data related to a card that is to be added on Android platform wallets. | `network: string`,<br>`opaquePaymentCard: string`,<br>`cardHolderName: string`,<br>`lastDigits: string`,<br>`userAddress: UserAddress`,<br>`isVirtualCard?: boolean`,<br>`isBounceProvisioned?: boolean` |
| **AndroidCardData** | Data related to a card that is to be added on Android platform wallets. | `network: string`,<br>`opaquePaymentCard: string`,<br>`cardHolderName: string`,<br>`lastDigits: string`,<br>`userAddress: UserAddress`,<br>`isVirtualCard?: boolean`,<br>`isBounceProvisioned?: boolean`,<br>`isGoogleOpaquePaymentCardSupported?: boolean` |
| **AndroidResumeCardData** | Simplified data structure for resuming card addition to Google Wallet using existing token reference ID. | `network: string`,<br>`tokenReferenceID: string`,<br>`cardHolderName?: string`,<br>`lastDigits?: string` |
| **AndroidPaymentCredentialsResponse** | Response object containing encrypted payment credentials for UAPP flow. [Learn more →](./docs/UAPP.md) | `opaquePaymentCard: string`,<br>`googleOpaquePaymentCard: string` |
| **onPaymentCredentialsRequestPayload** | Payload received when Google Wallet requests payment credentials during UAPP provisioning. [Learn more →](./docs/UAPP.md) | `requestId: string`,<br>`serverSessionId: string`,<br>`walletId: string`,<br>`tokenRequestorId: string \| null`,<br>`opaquePaymentCard: string` |
Expand Down Expand Up @@ -240,6 +240,10 @@ Indicates whether the card has been provisioned through "bounce provisioning". B

This flag helps Google Wallet track cards that were initially added through the Google Wallet app but require additional app-specific configuration or verification. When set to `true`, it signals that this card was previously provisioned through the Google Wallet interface and is now being completed or updated through your application.

#### `isGoogleOpaquePaymentCardSupported?: boolean`

Tells Google Wallet that your backend can generate the Google OPC, which turns on the UAPP flow for this card. Defaults to `false`, so Google Wallet only asks for the TSP OPC and the payment credentials handler is not called. Set it to `true` only for cards your backend supports UAPP for. See [UAPP](./docs/UAPP.md).

## Card Status

| Type | Possible Values |
Expand Down
3 changes: 3 additions & 0 deletions android/src/main/java/com/expensify/wallet/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ object Utils {

val isVirtual = if (hasKey("isVirtualCard")) this.getBoolean("isVirtualCard") else false
val isBounce = if (hasKey("isBounceProvisioned")) this.getBoolean("isBounceProvisioned") else false
val isGoogleOpcSupported =
if (hasKey("isGoogleOpaquePaymentCardSupported")) this.getBoolean("isGoogleOpaquePaymentCardSupported") else false

return CardData(
network = this.getString("network") ?: "",
Expand All @@ -40,6 +42,7 @@ object Utils {
userAddress = userAddress,
isVirtualCard = isVirtual,
isBounceProvisioned = isBounce,
isGoogleOpaquePaymentCardSupported = isGoogleOpcSupported,
)
}

Expand Down
4 changes: 2 additions & 2 deletions android/src/main/java/com/expensify/wallet/WalletModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
return future
}

// This switch enables the UAPP flow
// This switch enables the UAPP flow, without it Google Wallet only asks for the TSP OPC
override fun getGoogleOpaquePaymentCardSupported(): Boolean {
return true
return cardData.isGoogleOpaquePaymentCardSupported
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ data class CardData(
val userAddress: UserAddress,
val isVirtualCard: Boolean = false,
val isBounceProvisioned: Boolean = false,
val isGoogleOpaquePaymentCardSupported: Boolean = false,
)
1 change: 1 addition & 0 deletions apps/common-app/src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const AndroidDummyCardData: AndroidCardData = {
userAddress: dummyAddress,
isVirtualCard: false,
isBounceProvisioned: false,
isGoogleOpaquePaymentCardSupported: true,
};

const AndroidDummyResumeCardData: AndroidResumeCardData = {
Expand Down
10 changes: 6 additions & 4 deletions docs/UAPP.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This library handles the UAPP flow automatically. You just need to set up a hand

## Setup

UAPP is always enabled on Android, so `addCardToGoogleWallet()` requires a payment credentials handler as its second argument:
UAPP is enabled per card with `isGoogleOpaquePaymentCardSupported: true` in the card data. Without it, Google Wallet only asks for the TSP OPC and the handler is not called. `addCardToGoogleWallet()` always takes a payment credentials handler as its second argument:

```typescript
import { addCardToGoogleWallet } from '@expensify/react-native-wallet';
Expand Down Expand Up @@ -52,7 +52,7 @@ const handlePaymentCredentials = async (data) => {
};

// Pass the handler when adding a card
const status = await addCardToGoogleWallet(cardData, handlePaymentCredentials);
const status = await addCardToGoogleWallet({...cardData, isGoogleOpaquePaymentCardSupported: true}, handlePaymentCredentials);
```

## Backend Implementation
Expand Down Expand Up @@ -128,7 +128,7 @@ The handler is only called when Google Wallet requests a Google OPC, and it must
**Example:**
```typescript
const status = await addCardToGoogleWallet(
cardData,
{...cardData, isGoogleOpaquePaymentCardSupported: true},
async (data) => {
const credentials = await fetchCredentialsFromBackend(data);
return credentials;
Expand All @@ -138,12 +138,14 @@ const status = await addCardToGoogleWallet(

### AndroidCardData Optional Fields

When using UAPP with `addCardToGoogleWallet()`, the `AndroidCardData` object supports two optional boolean fields:
When using UAPP with `addCardToGoogleWallet()`, the `AndroidCardData` object supports these optional boolean fields:

- **`isVirtualCard?: boolean`** - Set to `true` if provisioning a virtual card (digitally-generated card number linked to a physical card account). Virtual cards provide enhanced security for online transactions.

- **`isBounceProvisioned?: boolean`** - Set to `true` if the card was initially provisioned through Google Wallet and is now being completed through your app. This is used in bounce provisioning flows where users start in Google Wallet and are redirected to your app for additional verification.

- **`isGoogleOpaquePaymentCardSupported?: boolean`** - Set to `true` to run the UAPP flow for this card. Defaults to `false`, which skips UAPP and never calls the payment credentials handler.

For more details, see the [AndroidCardData Optional Fields](../README.md#androidcarddata-optional-fields) section in the main documentation.

## Testing
Expand Down
1 change: 1 addition & 0 deletions src/NativeWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type AndroidCardData = {
userAddress: UserAddress;
isVirtualCard?: boolean;
isBounceProvisioned?: boolean;
isGoogleOpaquePaymentCardSupported?: boolean;
};

type AndroidResumeCardData = {
Expand Down
Loading