@expensify/react-native-wallet 0.1.37 → 0.1.38

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.
@@ -76,6 +76,8 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
76
76
  pendingCreateWalletPromise?.resolve(resultCode == RESULT_OK)
77
77
  pendingCreateWalletPromise = null
78
78
  } else if (requestCode == REQUEST_CODE_PUSH_TOKENIZE) {
79
+ val localPromise = pendingPushTokenizePromise
80
+ pendingPushTokenizePromise = null
79
81
  if (resultCode == RESULT_OK) {
80
82
  data?.let {
81
83
  val tokenId = it.getStringExtra(TapAndPay.EXTRA_ISSUER_TOKEN_ID).toString()
@@ -84,7 +86,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
84
86
  OnCardActivatedEvent.NAME,
85
87
  OnCardActivatedEvent("activated", tokenId).toMap()
86
88
  )
87
- pendingPushTokenizePromise?.resolve(TokenizationStatus.SUCCESS.code)
89
+ localPromise?.resolve(TokenizationStatus.SUCCESS.code)
88
90
  }
89
91
  } else if (resultCode == RESULT_CANCELED) {
90
92
  sendEvent(
@@ -92,7 +94,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
92
94
  OnCardActivatedEvent.NAME,
93
95
  OnCardActivatedEvent("canceled", null).toMap()
94
96
  )
95
- pendingPushTokenizePromise?.resolve(TokenizationStatus.CANCELED.code)
97
+ localPromise?.resolve(TokenizationStatus.CANCELED.code)
96
98
  }
97
99
  }
98
100
  }
@@ -185,6 +187,9 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
185
187
  override fun addCardToGoogleWallet(
186
188
  data: ReadableMap, promise: Promise
187
189
  ) {
190
+ if (pendingPushTokenizePromise != null) {
191
+ return promise.reject(E_OPERATION_FAILED, "A tokenization request is already in progress")
192
+ }
188
193
  try {
189
194
  val cardData = data.toCardData() ?: return promise.reject(E_INVALID_DATA, "Insufficient data")
190
195
  val cardNetwork = getCardNetwork(cardData.network)
@@ -205,12 +210,16 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
205
210
  activity, pushTokenizeRequest, REQUEST_CODE_PUSH_TOKENIZE
206
211
  )
207
212
  } catch (e: java.lang.Exception) {
213
+ pendingPushTokenizePromise = null
208
214
  promise.reject(e)
209
215
  }
210
216
  }
211
217
 
212
218
  @ReactMethod
213
219
  override fun resumeAddCardToGoogleWallet(data: ReadableMap, promise: Promise) {
220
+ if (pendingPushTokenizePromise != null) {
221
+ return promise.reject(E_OPERATION_FAILED, "A tokenization request is already in progress")
222
+ }
214
223
  try {
215
224
  val tokenReferenceID = data.getString("tokenReferenceID")
216
225
  ?: return promise.reject(E_INVALID_DATA, "Missing tokenReferenceID")
@@ -232,6 +241,7 @@ class WalletModule internal constructor(context: ReactApplicationContext) :
232
241
  REQUEST_CODE_PUSH_TOKENIZE
233
242
  )
234
243
  } catch (e: java.lang.Exception) {
244
+ pendingPushTokenizePromise = null
235
245
  promise.reject(e)
236
246
  }
237
247
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expensify/react-native-wallet",
3
- "version": "0.1.37",
3
+ "version": "0.1.38",
4
4
  "description": "A React Native module designed for seamless integration of Card Push Provisioning into Apple Wallet and Google Wallet, enabling easy and secure addition of payment cards directly from your application.",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "lib/commonjs/index",