@exodus/react-native-wallet 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +268 -0
- package/android/build.gradle +103 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/expensify/wallet/Utils.kt +148 -0
- package/android/src/main/java/com/expensify/wallet/WalletModule.kt +380 -0
- package/android/src/main/java/com/expensify/wallet/WalletPackage.kt +48 -0
- package/android/src/main/java/com/expensify/wallet/components/RNAddToWalletButtonManager.kt +19 -0
- package/android/src/main/java/com/expensify/wallet/components/RNAddToWalletButtonView.kt +42 -0
- package/android/src/main/java/com/expensify/wallet/error/InvalidNetworkError.kt +6 -0
- package/android/src/main/java/com/expensify/wallet/event/OnCardActivatedEvent.kt +18 -0
- package/android/src/main/java/com/expensify/wallet/model/CardData.kt +12 -0
- package/android/src/main/java/com/expensify/wallet/model/CardStatus.kt +15 -0
- package/android/src/main/java/com/expensify/wallet/model/TokenizationStatus.kt +7 -0
- package/android/src/main/java/com/expensify/wallet/model/WalletData.kt +7 -0
- package/android/src/main/res/drawable/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable/googlewallet_button_background.xml +5 -0
- package/android/src/main/res/drawable/googlewallet_button_overlay.xml +11 -0
- package/android/src/main/res/drawable-af/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-af/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-am/add_to_googlewallet_button_content.xml +34 -0
- package/android/src/main/res/drawable-am/badge_add_to_googlewallet_button_content.xml +34 -0
- package/android/src/main/res/drawable-ar/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ar/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-az/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-az/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-bg/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-bg/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-bn/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-bn/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-br/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-br/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-bs/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-bs/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-by/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-by/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ca/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ca/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-cz/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-cz/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-de/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-de/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-dk/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-dk/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rau/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rau/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rca/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rca/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rgb/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rgb/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rin/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rin/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rsg/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rsg/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rus/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rus/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rza/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-en-rza/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-es-res/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-es-res/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-es-rus/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-es-rus/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-et/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-et/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fa/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-fa/badge_add_to_googlewallet_button_content.xml +34 -0
- package/android/src/main/res/drawable-fl/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fl/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fp/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fp/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fr-rca/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fr-rca/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fr-rfr/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-fr-rfr/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-gr/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-gr/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-he/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-he/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hr/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hr/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hu/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hu/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hy/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-hy/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-id/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-id/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-is/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-is/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-it/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-it/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-jp/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-jp/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ka/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ka/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-kh/add_to_googlewallet_button_content.xml +33 -0
- package/android/src/main/res/drawable-kh/badge_add_to_googlewallet_button_content.xml +33 -0
- package/android/src/main/res/drawable-kk/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-kk/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ky/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ky/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-lo/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-lo/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-lt/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-lt/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-lv/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-lv/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-mdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-mk/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-mk/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-mn/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-mn/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-my/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-my/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-ne/add_to_googlewallet_button_content.xml +28 -0
- package/android/src/main/res/drawable-ne/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-nl/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-nl/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-no/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-no/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-pl/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-pl/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-pt/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-pt/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ro/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ro/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ru/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ru/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-se/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-se/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-si/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-si/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-sk/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sk/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sl/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sl/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sq/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sq/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sr/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sr/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-sw/add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-sw/badge_add_to_googlewallet_button_content.xml +31 -0
- package/android/src/main/res/drawable-th/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-th/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-tr/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-tr/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-uk/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-uk/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-ur/add_to_googlewallet_button_content.xml +34 -0
- package/android/src/main/res/drawable-ur/badge_add_to_googlewallet_button_content.xml +34 -0
- package/android/src/main/res/drawable-uz/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-uz/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-vi/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-vi/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-xhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-xxhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-xxxhdpi/googlepay_button_background_image.9.png +0 -0
- package/android/src/main/res/drawable-zh-rhk/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-zh-rhk/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-zh-rtw/add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/drawable-zh-rtw/badge_add_to_googlewallet_button_content.xml +7 -0
- package/android/src/main/res/layout/add_to_googlewallet_badge.xml +35 -0
- package/android/src/main/res/layout/add_to_googlewallet_button.xml +34 -0
- package/android/src/main/res/values/googlewallet_strings.xml +7 -0
- package/android/src/paper/java/com/expensify/wallet/NativeWalletSpec.java +83 -0
- package/assets/buttons/android_button.svg +16 -0
- package/assets/buttons/ios_button.svg +259 -0
- package/assets/hero-image.png +0 -0
- package/assets/signature-dark.png +0 -0
- package/assets/signature-light.png +0 -0
- package/ios/RNAddToWalletButtonBridge.m +8 -0
- package/ios/RNWallet.h +13 -0
- package/ios/RNWallet.mm +153 -0
- package/ios/WalletManager.swift +297 -0
- package/ios/components/RNAddToWalletButtonManager.swift +13 -0
- package/ios/components/RNAddToWalletButtonView.swift +67 -0
- package/ios/stucts/AddPassResponse.swift +36 -0
- package/ios/stucts/CardInfo.swift +37 -0
- package/ios/stucts/WalletEncryptedPayload.swift +27 -0
- package/lib/commonjs/AddToWalletButton.js +83 -0
- package/lib/commonjs/AddToWalletButton.js.map +1 -0
- package/lib/commonjs/NativeWallet.js +22 -0
- package/lib/commonjs/NativeWallet.js.map +1 -0
- package/lib/commonjs/index.js +156 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/utils.js +38 -0
- package/lib/commonjs/utils.js.map +1 -0
- package/lib/module/AddToWalletButton.js +76 -0
- package/lib/module/AddToWalletButton.js.map +1 -0
- package/lib/module/NativeWallet.js +17 -0
- package/lib/module/NativeWallet.js.map +1 -0
- package/lib/module/index.js +132 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/utils.js +32 -0
- package/lib/module/utils.js.map +1 -0
- package/lib/typescript/src/AddToWalletButton.d.ts +16 -0
- package/lib/typescript/src/AddToWalletButton.d.ts.map +1 -0
- package/lib/typescript/src/NativeWallet.d.ts +77 -0
- package/lib/typescript/src/NativeWallet.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +22 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/utils.d.ts +5 -0
- package/lib/typescript/src/utils.d.ts.map +1 -0
- package/package.json +157 -0
- package/react-native-wallet.podspec +36 -0
- package/src/AddToWalletButton.tsx +78 -0
- package/src/NativeWallet.ts +115 -0
- package/src/index.tsx +184 -0
- package/src/utils.ts +35 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Expensify, Inc.
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
<img src="./assets/hero-image.png" alt="@expensify/react-native-wallet" />
|
|
2
|
+
|
|
3
|
+
## Features
|
|
4
|
+
- ⚛️ Card In-App Provisioning seamless integration
|
|
5
|
+
- ♻️ Universal solution (Apple Wallet and Google Wallet)
|
|
6
|
+
- 💳 Easy and secure addition of payment cards from your app directly
|
|
7
|
+
- 💰 Supports Visa, MasterCard, Amex and Discover payment cards
|
|
8
|
+
|
|
9
|
+
## Getting started
|
|
10
|
+
|
|
11
|
+
Using the `react-native-wallet` Push Provisioning features requires proper configuration and access from both Google and Apple.
|
|
12
|
+
Please follow the instructions below before installing the library:
|
|
13
|
+
|
|
14
|
+
### Android
|
|
15
|
+
|
|
16
|
+
To be able to interact with the Google Wallet on the Android please make sure to complete all of the steps below following [the Google Push Provisioning documentation](https://developers.google.com/pay/issuers/apis/push-provisioning/android/setup):
|
|
17
|
+
|
|
18
|
+
#### Step 1: Get access to Google TapAndPay SDK
|
|
19
|
+
|
|
20
|
+
1. Visit [the Google Pay Android Push Provisioning API documentation](https://developers.google.com/pay/issuers/apis/push-provisioning/android/) and request access to it.
|
|
21
|
+
|
|
22
|
+
2. Once getting an approval from the Google team
|
|
23
|
+
1. Download the [TapAndPay SDK](https://developers.google.com/pay/issuers/apis/push-provisioning/android/releases).
|
|
24
|
+
2. Unzip it and extract the SDK into the `/android/libs` folder in your React Native project (if there is no `libs` folder, create one).
|
|
25
|
+
3. Add `/android/libs` to `.gitignore`.
|
|
26
|
+
|
|
27
|
+
3. Then connect the SDK to your project in `build.gradle`, for example like in [example/android/build.gradle](https://github.com/Expensify/react-native-wallet/blob/main/example/android/build.gradle):
|
|
28
|
+
|
|
29
|
+
```groovy
|
|
30
|
+
allprojects {
|
|
31
|
+
repositories {
|
|
32
|
+
google()
|
|
33
|
+
maven { url "file://${rootDir}/libs" }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Step 2: Whitelist your app for SDK use.
|
|
39
|
+
|
|
40
|
+
To use the Google SDK in your app, you will need to whitelist your app details. Without it, calling some functions will result in a `Not verified` error.
|
|
41
|
+
To resolve it, please follow the instructions from [the official Google documentation](https://developers.google.com/pay/issuers/apis/push-provisioning/android/allowlist).
|
|
42
|
+
|
|
43
|
+
For your builds, you will need to prepare your app's `package name` and `fingerprint` following [these steps](https://developers.google.com/pay/issuers/apis/push-provisioning/android/allowlist#how_to_get_your_apps_fingerprint). The values should, for example, look like this:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Package name: com.app.package.name
|
|
47
|
+
|
|
48
|
+
Fingerprint: SHA256: 36:38:63:59:6E:...:00:82:16:4E:FF
|
|
49
|
+
```
|
|
50
|
+
> [!TIP]
|
|
51
|
+
> You can display your SHA-256 certificate checksum using `apksigner` or `keytool`.
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
With all the required data, submit the form and wait for Google's response. After successfully whitelisting your app you will be able to use Google SDK within our library.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
### iOS
|
|
58
|
+
|
|
59
|
+
### Step 1: Apply for appropriate entitlements
|
|
60
|
+
|
|
61
|
+
To enable In-App Provisioning in your app, you must request activation of the appropriate Apple Pay entitlements for your developer Team ID. Enterprise Team IDs are not supported. This entitlement is not available by default in our panel; you will need to request it. Send an email to apple-pay-provisioning@apple.com with your app name, Team ID, and Adam ID.
|
|
62
|
+
|
|
63
|
+
Once Apple verifies your identity, you should get documentation named `Getting Started with Apple Pay In-App Provisioning, Verification & Security`. In this confidential document you will find all the relevant information about:
|
|
64
|
+
- Prerequisites for your project
|
|
65
|
+
- Best practices to follow
|
|
66
|
+
- How In-App Provisioning works
|
|
67
|
+
- UX requirements
|
|
68
|
+
- Testing process
|
|
69
|
+
- and more...
|
|
70
|
+
|
|
71
|
+
Make sure to familiarize yourself with that document before deploying your app.
|
|
72
|
+
|
|
73
|
+
### Step 2: Activate the entitlement
|
|
74
|
+
|
|
75
|
+
After getting a positive response from Apple, open the developer portal panel and search `Certificates, Identifiers & Profiles` -> `Profiles` -> `Our distribution profile` -> `Edit` and add the `ApplePay In-App Provisioning Distribution` entitlement.
|
|
76
|
+
It’s available only for the production environment so your QA must work with physical devices and cards.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
### Step 3: Add the entitlement to your project
|
|
80
|
+
|
|
81
|
+
Add `com.apple.developer.payment-pass-provisioning` entitlement to your project. Find or create `.entitlements` file in your project and add the entitlement like below (similarly to [WalletExample.entitlements](https://github.com/Expensify/react-native-wallet/blob/main/example/ios/WalletExample/WalletExample.entitlements)):
|
|
82
|
+
|
|
83
|
+
```xml
|
|
84
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
85
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
86
|
+
<plist version="1.0">
|
|
87
|
+
<dict>
|
|
88
|
+
...
|
|
89
|
+
<!-- In-App Provisioning special entitlement-->
|
|
90
|
+
<key>com.apple.developer.payment-pass-provisioning</key>
|
|
91
|
+
<true/>
|
|
92
|
+
</dict>
|
|
93
|
+
</plist>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Installation
|
|
97
|
+
|
|
98
|
+
After completing the setup from the section above, install the `react-native-wallet` package from npm:
|
|
99
|
+
|
|
100
|
+
```sh
|
|
101
|
+
npm install @expensify/react-native-wallet
|
|
102
|
+
```
|
|
103
|
+
or
|
|
104
|
+
```sh
|
|
105
|
+
yarn add @expensify/react-native-wallet
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## Required data
|
|
111
|
+
Here you can find data elements used in the library, essential to work with Google Wallet and Apple Wallet APIs.
|
|
112
|
+
|
|
113
|
+
### Android
|
|
114
|
+
- **Opaque Payment Card** (OPC) - a binary blob of information Google Pay receives from the issuer app that could be presented to TSP to receive a token.
|
|
115
|
+
- **Token Service Provider** (TSP) - a service that enhances payment security by replacing a credit card number during transactions with a unique digital identifier - token. The TSP specifies the tokenization service used to create a given token e.g. Visa, MasterCard, American Express.
|
|
116
|
+
- **Token Reference ID** - a unique identifying number to refer to a DPAN (Dynamic Personal Account Number). Token Providers will assign each DPAN an issuer token ID at the time of tokenization.
|
|
117
|
+
|
|
118
|
+
### iOS
|
|
119
|
+
- **Nonce** - a one-time nonce value generated by Apple’s servers. This nonce must be included in the add payment request’s encrypted data.
|
|
120
|
+
- **Nonce Signature** - the device-specific signature for the nonce. This signature must be included in the add payment request’s encrypted data.
|
|
121
|
+
- **Certificates** - an array of NSData objects. Each object contains a DER encoded X.509 certificate, with the leaf first and root last. You must download the root CA to validate the entire chain.
|
|
122
|
+
- **Encrypted Pass Data**- an encrypted JSON file containing the sensitive information needed to add a card to Apple Pay (Base 64 encoded). [More details here.](https://developer.apple.com/documentation/passkit/pkaddpaymentpassrequest/encryptedpassdata)
|
|
123
|
+
- **Ephemeral Public Key** - a key used by elliptic curve cryptography (ECC) (Base 64 encoded).
|
|
124
|
+
|
|
125
|
+
# API Reference
|
|
126
|
+
The library offers seven functions for seamless integration and use of the Apple Wallet and Google Wallet APIs. Additionally, it includes one listener that informs when the added card has been activated. Below, these functions are described along with the data types involved.
|
|
127
|
+
|
|
128
|
+
## Functions
|
|
129
|
+
|
|
130
|
+
| Function | Description | Parameters | Returns / Type | iOS | Android |
|
|
131
|
+
|----------|-------------|------------|----------------|:---:|:-------:|
|
|
132
|
+
| **getSecureWalletInfo** | Returns necessary platform-specific wallet information for secure transactions. | None | `WalletData` | ❌ | ✅ |
|
|
133
|
+
| **checkWalletAvailability** | Checks if the wallet is ready and initializes it if possible. | None | `boolean` | ✅ | ✅ |
|
|
134
|
+
| **getCardStatusBySuffix** | Retrieves the current status of a card in the wallet. | `lastDigits: string`<br>(The last few digits of the card number) | `CardStatus` | ✅ | ✅ |
|
|
135
|
+
| **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` | ✅ | ✅ |
|
|
136
|
+
| **addCardToGoogleWallet** | Initiates native Push Provisioning flow for adding a card to the Google Wallet. | `data`: `AndroidCardData` | `TokenizationStatus` | ❌ | ✅ |
|
|
137
|
+
| **resumeAddCardToGoogleWallet** | Resumes the Push Provisioning flow for adding a card to the Google Wallet using existing token reference ID. | `data`: `AndroidResumeCardData` | `TokenizationStatus` | ❌ | ✅ |
|
|
138
|
+
| **listTokens** | Lists all tokens currently stored in the Google Wallet. | None | `TokenInfo[]` | ❌ | ✅ |
|
|
139
|
+
| **addCardToAppleWallet** | Initiates native Push Provisioning flow for adding a card to the Apple Wallet. | `data`: `IOSCardData`,<br>`issuerEncrypt-`<br>`PayloadCallback: IOSIssuerCallback` | `void` | ✅ | ❌ |
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
## Data Types
|
|
143
|
+
|
|
144
|
+
| Type | Description | Fields |
|
|
145
|
+
|------|-------------|--------|
|
|
146
|
+
| **AndroidWalletData** | Specific information for Android devices required for wallet transactions. | `deviceID: string`,<br>`walletAccountID: string` |
|
|
147
|
+
| **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` |
|
|
148
|
+
| **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` |
|
|
149
|
+
| **UserAddress** | Structured address used for cardholder verification. | `name: string`,<br>`addressOne: string`,<br>`addressTwo: string`,<br>`city: string`,<br>`administrativeArea: string`,<br>`countryCode: string`,<br>`postalCode: string`,<br>`phoneNumber: string` |
|
|
150
|
+
| **IOSCardData** | Data related to a card that is to be added on iOS platform. | `network: string`,<br>`activationData: string`,<br>`encryptedPassData: string`,<br>`ephemeralPublicKey: string`,<br>`cardHolderTitle: string`,<br>`cardHolderName: string`,<br>`lastDigits: string`,<br>`cardDescription: string`,<br>`cardDescriptionComment: string` |
|
|
151
|
+
| **onCardActivatedPayload** | Data used by listener to notice when a card’s status changes. | `tokenId: string`,<br> `actionStatus: 'activated' \| 'canceled'`<br> |
|
|
152
|
+
| **IOSIssuerCallback** | This callback is invoked with a nonce, its signature, and a certificate array obtained from Apple. It is expected that you will forward these details to your server or the card issuer's API to securely encrypt the payload required for adding cards to the Apple Wallet. | `(nonce: string, nonceSignature: string, certificate: string[]) => IOSEncryptPayload` |
|
|
153
|
+
| **IOSEncryptPayload** | An object containing the necessary elements to complete the addition of a card to Apple Wallet. | `encryptedPassData: string`,<br>`activationData: string`,<br>`ephemeralPublicKey: string` |
|
|
154
|
+
| **TokenInfo** | Information about a token stored in Google Wallet. | `identifier: string`,<br>`lastDigits: string`,<br>`tokenState: number` |
|
|
155
|
+
|
|
156
|
+
## Card Status
|
|
157
|
+
|
|
158
|
+
| Type | Possible Values |
|
|
159
|
+
|------|-----------------|
|
|
160
|
+
| **CardStatus** | `not found`, `active`, `requireAuthorization`, `pending`, `suspended`, `deactivated` |
|
|
161
|
+
|
|
162
|
+
## Listeners
|
|
163
|
+
|
|
164
|
+
| Listener | Event Description | Register Function | Unregister Function |
|
|
165
|
+
|----------|-------------------|-------------------|---------------------|
|
|
166
|
+
| **_cardActivation_** | Notifies when a card's status changes to activated. | `addListener(event: string, callback: (data: onCardActivatedPayload) => void): EmitterSubscription` | `removeListener(subscription: EmitterSubscription): void` |
|
|
167
|
+
|
|
168
|
+
## Components
|
|
169
|
+
|
|
170
|
+
### `AddToWalletButton`
|
|
171
|
+
|
|
172
|
+
A ready-to-use component that simplifies the addition of payment cards to Google Wallet and Apple Wallet. The button automatically adapts its appearance according to the platform and language specified.
|
|
173
|
+
It uses official assets provided by [Google](https://developers.google.com/wallet/generic/resources/brand-guidelines) and [Apple](https://developer.apple.com/wallet/add-to-apple-wallet-guidelines/) in their Wallet-related branding guidelines.
|
|
174
|
+
|
|
175
|
+
> [!IMPORTANT]
|
|
176
|
+
> Please bear in mind the brand rules provided by [Google](https://developers.google.com/wallet/generic/resources/brand-guidelines) and [Apple](https://developer.apple.com/wallet/add-to-apple-wallet-guidelines/) when adding this component to your application.
|
|
177
|
+
|
|
178
|
+
Adhering to these guidelines is crucial not only to comply with legal requirements but also to reassure users of the authenticity and security of your application.
|
|
179
|
+
|
|
180
|
+
> [!NOTE]
|
|
181
|
+
> Localization is automatically handled by the system settings, ensuring the button language matches the device's preferred language.
|
|
182
|
+
|
|
183
|
+
| Property | Type | Required | Description | Platform Specific |
|
|
184
|
+
|----------------|---------------------------------------------|----------|-------------------------------------------------------------------|-------------------|
|
|
185
|
+
| **onPress** | `(e: GestureResponderEvent) => void` | Yes | A callback that is triggered when the button is pressed. | No |
|
|
186
|
+
| **style** | `ViewStyle` | No | Customizes the overall style of the component. | No |
|
|
187
|
+
| **buttonStyle**| `'black' \| 'blackOutline'` | No | Customizes the button style. | iOS Only |
|
|
188
|
+
| **buttonType** | `'basic' \| 'badge'` | No | Defines the button's type (e.g., primary, secondary). | No |
|
|
189
|
+
| **borderRadius**| `number` | No | The border radius of the button, applicable to iOS buttons only. | iOS Only |
|
|
190
|
+
|
|
191
|
+
#### Usage Example:
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
<AddToWalletButton
|
|
195
|
+
onPress={() => console.log('Button pressed!')}
|
|
196
|
+
style={styles.longButton}
|
|
197
|
+
buttonStyle="blackOutline"
|
|
198
|
+
buttonType="badge"
|
|
199
|
+
borderRadius={4}
|
|
200
|
+
/>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
| Android | iOS |
|
|
204
|
+
|:----:|:---------------:|
|
|
205
|
+
| <img src="./assets/buttons/android_button.svg" height="50" /> | <img src="./assets/buttons/ios_button.svg" height="50" /> |
|
|
206
|
+
|
|
207
|
+
# Publishing your app
|
|
208
|
+
|
|
209
|
+
To successfully publish your app, you will need to navigate through a series of mandatory test cases on both platforms.
|
|
210
|
+
|
|
211
|
+
### Android
|
|
212
|
+
|
|
213
|
+
Before deploying your app to the Google Play Store, make sure you have taken care of the security when implementing Push Provisioning and properly tested your code. To accomplish it, please familiarize yourself with [the Google's App Push Provisioning best practices](https://developers.google.com/pay/issuers/apis/push-provisioning/android/best-practices).
|
|
214
|
+
|
|
215
|
+
The latest information about deploying apps with Google TapAndPay SDK can be found in the [pre-launch process](https://developers.google.com/pay/issuers/apis/push-provisioning/android/launch-process#step_3_issuer_app_product_review) and [beta tests](https://developers.google.com/pay/issuers/apis/push-provisioning/android/beta-testing) sections in Google documentation. Make sure to complete all of the steps specified by Google connected to the __Google's branding__, __API safety__, and __app stability__.
|
|
216
|
+
|
|
217
|
+
The app will need to be reviewed by Google. During this process, it will need to pass 4 mandatory test cases that are specified [here](https://developers.google.com/pay/issuers/apis/push-provisioning/android/test-cases). They verify how your app handles card state tracking in different scenarios.
|
|
218
|
+
|
|
219
|
+
> [!NOTE]
|
|
220
|
+
>Please make sure to hide the `Add to Google Wallet` buttons when cards are already added to the wallet.
|
|
221
|
+
|
|
222
|
+
### iOS
|
|
223
|
+
|
|
224
|
+
When implementing the In-App Push Provisioning feature in your App make sure that your app follows Apple's [branding guidelines connected to Apple Wallet](https://developer.apple.com/wallet/add-to-apple-wallet-guidelines/). Remember that you must not create your own buttons or your app could be rejected at revision. You can use the[ AddWalletButton component](#components) instead!
|
|
225
|
+
When the pass is already provisioned, make sure to hide this button and replace it with text like `Added to Apple Wallet`. The card is fully provisioned once it added to your main device (user's iPhone) and all linked devices (for example Apple Watch).
|
|
226
|
+
|
|
227
|
+
Next to branding guidelines, please follow the instructions and best practices from [the In-App provisioning documentation]((#ios)) provided by Apple.
|
|
228
|
+
|
|
229
|
+
The In-App Provisioning feature must be reviewed and verified by Apple's certification team before submitting your app to the App Store. Below are some key scenarios that may be tested during the review process:
|
|
230
|
+
- Enrolling a card into Apple Wallet
|
|
231
|
+
- Enrolling a card into the Apple Watch
|
|
232
|
+
- Attempting to enroll a card that has already been added via the Wallet app
|
|
233
|
+
- Manually adding a card using its IBAN
|
|
234
|
+
- Adding multiple cards from the same issuer
|
|
235
|
+
- Adding and removing the same card
|
|
236
|
+
- Handling an incoming call during the provisioning process
|
|
237
|
+
- ...
|
|
238
|
+
|
|
239
|
+
Apple may request a demonstration of certain test scenarios, such as verifying the ability to add up to twenty different cards for a single user. Be prepared to provide validation for such cases.
|
|
240
|
+
|
|
241
|
+
Additionally, when submitting your app to the App Store, you must include:
|
|
242
|
+
- A demo account for testing.
|
|
243
|
+
- A demo video showcasing the In-App Provisioning experience.
|
|
244
|
+
|
|
245
|
+
# Compatibility
|
|
246
|
+
|
|
247
|
+
`@expensify/react-native-wallet` is compatible with the five latest minor releases of React Native (≥0.76.0) and works exclusively with the new architecture.
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
# Contributing
|
|
251
|
+
|
|
252
|
+
Contributions to this library are done under [https://github.com/Expensify/App](https://github.com/Expensify/App). Please refer to that repo and all its guidelines for contributing.
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
MIT
|
|
257
|
+
|
|
258
|
+
----------
|
|
259
|
+
|
|
260
|
+
This library is co-developed by [**Expensify**](https://www.expensify.com/), the fastest way to do expenses, travel, and corporate cards, in collaboration with [**Software Mansion**](https://swmansion.com/), React Native core contributors and experts in building high-performing mobile solutions.
|
|
261
|
+
|
|
262
|
+
<p align="center">
|
|
263
|
+
<picture>
|
|
264
|
+
<source media="(prefers-color-scheme: light)" srcset="./assets/signature-light.png" />
|
|
265
|
+
<source media="(prefers-color-scheme: dark)" srcset="./assets/signature-dark.png" />
|
|
266
|
+
<img alt="Brought to you by Software Mansion + Expensify" src="./assets/signature-light.png" width="600" />
|
|
267
|
+
</picture>
|
|
268
|
+
</p>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
|
|
3
|
+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Wallet_kotlinVersion"]
|
|
4
|
+
|
|
5
|
+
repositories {
|
|
6
|
+
google()
|
|
7
|
+
mavenCentral()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
dependencies {
|
|
11
|
+
classpath "com.android.tools.build:gradle:7.3.1"
|
|
12
|
+
// noinspection DifferentKotlinGradleVersion
|
|
13
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def reactNativeArchitectures() {
|
|
18
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
19
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def isNewArchitectureEnabled() {
|
|
23
|
+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
apply plugin: "com.android.library"
|
|
27
|
+
apply plugin: "kotlin-android"
|
|
28
|
+
|
|
29
|
+
if (isNewArchitectureEnabled()) {
|
|
30
|
+
apply plugin: "com.facebook.react"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
def getExtOrDefault(name) {
|
|
34
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Wallet_" + name]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
def getExtOrIntegerDefault(name) {
|
|
38
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Wallet_" + name]).toInteger()
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
android {
|
|
42
|
+
namespace "com.expensify.wallet"
|
|
43
|
+
|
|
44
|
+
sourceSets {
|
|
45
|
+
main {
|
|
46
|
+
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
52
|
+
|
|
53
|
+
defaultConfig {
|
|
54
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
55
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
56
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
buildFeatures {
|
|
61
|
+
buildConfig true
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
buildTypes {
|
|
65
|
+
release {
|
|
66
|
+
minifyEnabled false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
lintOptions {
|
|
71
|
+
disable "GradleCompatible"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
compileOptions {
|
|
75
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
sourceSets {
|
|
80
|
+
main {
|
|
81
|
+
if (!isNewArchitectureEnabled()) {
|
|
82
|
+
java.srcDirs += [
|
|
83
|
+
"src/paper/java"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
repositories {
|
|
91
|
+
mavenCentral()
|
|
92
|
+
google()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
96
|
+
|
|
97
|
+
dependencies {
|
|
98
|
+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
99
|
+
//noinspection GradleDynamicVers ion
|
|
100
|
+
implementation "com.facebook.react:react-native:+"
|
|
101
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
102
|
+
implementation 'com.google.android.gms:play-services-tapandpay:+'
|
|
103
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
package com.expensify.wallet
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReadableMap
|
|
5
|
+
import com.facebook.react.bridge.WritableMap
|
|
6
|
+
import com.google.android.gms.tapandpay.issuer.UserAddress
|
|
7
|
+
import com.expensify.wallet.model.CardData
|
|
8
|
+
import kotlinx.coroutines.Deferred
|
|
9
|
+
import kotlinx.coroutines.Dispatchers
|
|
10
|
+
import kotlinx.coroutines.async
|
|
11
|
+
import kotlinx.coroutines.coroutineScope
|
|
12
|
+
import kotlinx.coroutines.suspendCancellableCoroutine
|
|
13
|
+
import kotlinx.coroutines.withContext
|
|
14
|
+
import kotlin.coroutines.resume
|
|
15
|
+
import kotlin.coroutines.resumeWithException
|
|
16
|
+
|
|
17
|
+
object Utils {
|
|
18
|
+
fun ReadableMap.toCardData(): CardData? {
|
|
19
|
+
val addressMap = this.getMap("userAddress") ?: return null
|
|
20
|
+
|
|
21
|
+
val userAddress = UserAddress.newBuilder()
|
|
22
|
+
.setName(addressMap.getString("name") ?: "")
|
|
23
|
+
.setAddress1(addressMap.getString("addressOne") ?: "")
|
|
24
|
+
.setAddress2(addressMap.getString("addressTwo") ?: "")
|
|
25
|
+
.setLocality(addressMap.getString("locality") ?: "")
|
|
26
|
+
.setAdministrativeArea(addressMap.getString("administrativeArea") ?: "")
|
|
27
|
+
.setCountryCode(addressMap.getString("countryCode") ?: "")
|
|
28
|
+
.setPostalCode(addressMap.getString("postalCode") ?: "")
|
|
29
|
+
.setPhoneNumber(addressMap.getString("phoneNumber") ?: "")
|
|
30
|
+
.build()
|
|
31
|
+
|
|
32
|
+
return CardData(
|
|
33
|
+
network = this.getString("network") ?: "",
|
|
34
|
+
opaquePaymentCard = this.getString("opaquePaymentCard") ?: "",
|
|
35
|
+
cardHolderName = this.getString("cardHolderName") ?: "",
|
|
36
|
+
lastDigits = this.getString("lastDigits") ?: "",
|
|
37
|
+
userAddress = userAddress
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
suspend fun getAsyncResult(
|
|
42
|
+
resultType: Class<String>,
|
|
43
|
+
getPromiseOperation: (Promise) -> Unit
|
|
44
|
+
): Deferred<String> = coroutineScope {
|
|
45
|
+
async {
|
|
46
|
+
withContext(Dispatchers.IO) {
|
|
47
|
+
suspendCancellableCoroutine { continuation ->
|
|
48
|
+
val promise = object : Promise {
|
|
49
|
+
@Deprecated(
|
|
50
|
+
"Prefer passing a module-specific error code to JS. Using this method will pass the error code UNSPECIFIED",
|
|
51
|
+
replaceWith = ReplaceWith("reject(code, message)")
|
|
52
|
+
)
|
|
53
|
+
override fun reject(message: String) {
|
|
54
|
+
continuation.resumeWithException(
|
|
55
|
+
Exception("Error: $message")
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
override fun reject(code: String, userInfo: WritableMap) {
|
|
60
|
+
val errorMessage = "Error: $code\nUserInfo: $userInfo"
|
|
61
|
+
continuation.resumeWithException(
|
|
62
|
+
Exception(errorMessage)
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
override fun reject(code: String, message: String?) {
|
|
67
|
+
val errorMessage = "Error: $code\nMessage: ${message ?: "No message provided"}"
|
|
68
|
+
continuation.resumeWithException(
|
|
69
|
+
Exception(errorMessage)
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
override fun reject(code: String, message: String?, userInfo: WritableMap) {
|
|
74
|
+
val errorMessage =
|
|
75
|
+
"Error: $code\nMessage: ${message ?: "No message provided"}\nUserInfo: $userInfo"
|
|
76
|
+
continuation.resumeWithException(
|
|
77
|
+
Exception(errorMessage)
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
override fun reject(code: String, message: String?, throwable: Throwable?) {
|
|
82
|
+
val errorMessage = "Error: $code\nMessage: ${message ?: "No message provided"}"
|
|
83
|
+
continuation.resumeWithException(
|
|
84
|
+
throwable ?: Exception(errorMessage)
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
override fun reject(code: String, throwable: Throwable?) {
|
|
89
|
+
val errorMessage = "Error: $code"
|
|
90
|
+
continuation.resumeWithException(
|
|
91
|
+
throwable ?: Exception(errorMessage)
|
|
92
|
+
)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
override fun reject(code: String, throwable: Throwable?, userInfo: WritableMap) {
|
|
96
|
+
val errorMessage = "Error: $code\nUserInfo: $userInfo"
|
|
97
|
+
continuation.resumeWithException(
|
|
98
|
+
throwable ?: Exception(errorMessage)
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
override fun reject(
|
|
103
|
+
code: String?,
|
|
104
|
+
message: String?,
|
|
105
|
+
throwable: Throwable?,
|
|
106
|
+
userInfo: WritableMap?
|
|
107
|
+
) {
|
|
108
|
+
val errorMessage = buildString {
|
|
109
|
+
append("Error: ${code ?: "Unknown code"}")
|
|
110
|
+
if (message != null) append("\nMessage: $message")
|
|
111
|
+
if (userInfo != null) append("\nUserInfo: $userInfo")
|
|
112
|
+
}
|
|
113
|
+
continuation.resumeWithException(
|
|
114
|
+
throwable ?: Exception(errorMessage)
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
override fun reject(throwable: Throwable) {
|
|
119
|
+
continuation.resumeWithException(
|
|
120
|
+
throwable
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
override fun reject(throwable: Throwable, userInfo: WritableMap) {
|
|
125
|
+
val errorMessage = "Exception occurred\nUserInfo: $userInfo"
|
|
126
|
+
continuation.resumeWithException(
|
|
127
|
+
Exception(errorMessage, throwable)
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
override fun resolve(value: Any?) {
|
|
132
|
+
if (resultType.isInstance(value)) {
|
|
133
|
+
continuation.resume(value as String)
|
|
134
|
+
} else {
|
|
135
|
+
continuation.resumeWithException(
|
|
136
|
+
RuntimeException("Expected result of type ${resultType.simpleName}, but got ${value?.javaClass?.simpleName}")
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
142
|
+
getPromiseOperation(promise)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
}
|