judokit-react-native 3.3.7 → 3.4.0

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.
@@ -9,17 +9,8 @@ import com.judopay.judokit.android.Judo
9
9
  import com.judopay.judokit.android.api.model.Authorization
10
10
  import com.judopay.judokit.android.api.model.BasicAuthorization
11
11
  import com.judopay.judokit.android.api.model.PaymentSessionAuthorization
12
- import com.judopay.judokit.android.model.Amount
13
- import com.judopay.judokit.android.model.CardNetwork
14
- import com.judopay.judokit.android.model.Currency
15
- import com.judopay.judokit.android.model.GooglePayConfiguration
16
- import com.judopay.judokit.android.model.JudoResult
17
- import com.judopay.judokit.android.model.PBBAConfiguration
18
- import com.judopay.judokit.android.model.PaymentMethod
19
- import com.judopay.judokit.android.model.PaymentWidgetType
20
- import com.judopay.judokit.android.model.PrimaryAccountDetails
21
- import com.judopay.judokit.android.model.Reference
22
- import com.judopay.judokit.android.model.UiConfiguration
12
+ import com.judopay.judokit.android.api.model.request.Address
13
+ import com.judopay.judokit.android.model.*
23
14
  import com.judopay.judokit.android.model.googlepay.GooglePayAddressFormat
24
15
  import com.judopay.judokit.android.model.googlepay.GooglePayBillingAddressParameters
25
16
  import com.judopay.judokit.android.model.googlepay.GooglePayEnvironment
@@ -118,21 +109,71 @@ internal fun getJudoConfiguration(type: PaymentWidgetType, options: ReadableMap)
118
109
  val primaryAccountDetails = getPrimaryAccountDetails(options)
119
110
  val googlePayConfiguration = getGooglePayConfiguration(options)
120
111
  val pbbaConfiguration = getPBBAConfiguration(options)
112
+ val timeouts = getNetworkTimeout(options)
113
+ val challengeRequestIndicator = getChallengeRequestIndicator(options)
114
+ val scaExemption = getScaExemption(options)
115
+ val address = getAddress(options)
121
116
 
122
117
  return Judo.Builder(type)
123
- .setAuthorization(authorization)
124
- .setIsSandboxed(options.isSandboxed)
125
- .setJudoId(options.judoId)
126
- .setAmount(amount)
127
- .setReference(reference)
128
- .setSupportedCardNetworks(cardNetworks)
129
- .setPaymentMethods(paymentMethods)
130
- .setUiConfiguration(uiConfiguration)
131
- .setPrimaryAccountDetails(primaryAccountDetails)
132
- .setGooglePayConfiguration(googlePayConfiguration)
133
- .setPBBAConfiguration(pbbaConfiguration)
134
- .setInitialRecurringPayment(options.isInitialRecurringPayment)
118
+ .setAuthorization(authorization)
119
+ .setIsSandboxed(options.isSandboxed)
120
+ .setJudoId(options.judoId)
121
+ .setAmount(amount)
122
+ .setReference(reference)
123
+ .setSupportedCardNetworks(cardNetworks)
124
+ .setPaymentMethods(paymentMethods)
125
+ .setUiConfiguration(uiConfiguration)
126
+ .setPrimaryAccountDetails(primaryAccountDetails)
127
+ .setGooglePayConfiguration(googlePayConfiguration)
128
+ .setPBBAConfiguration(pbbaConfiguration)
129
+ .setInitialRecurringPayment(options.isInitialRecurringPayment)
130
+ .setNetworkTimeout(timeouts)
131
+ .setChallengeRequestIndicator(challengeRequestIndicator)
132
+ .setScaExemption(scaExemption)
133
+ .setMobileNumber(options.mobileNumber)
134
+ .setEmailAddress(options.emailAddress)
135
+ .setThreeDSTwoMaxTimeout(options.threeDSTwoMaxTimeout)
136
+ .setThreeDSTwoMessageVersion(options.threeDSTwoMessageVersion)
137
+ .setPhoneCountryCode(options.phoneCountryCode)
138
+ .setAddress(address)
139
+ .build()
140
+ }
141
+
142
+ internal fun getAddress(options: ReadableMap): Address? {
143
+ if (options.cardAddress != null) {
144
+ return Address.Builder()
145
+ .setLine1(options.cardAddressLine1)
146
+ .setLine2(options.cardAddressLine2)
147
+ .setLine3(options.cardAddressLine3)
148
+ .setTown(options.cardAddressTown)
149
+ .setPostCode(options.cardAddressPostCode)
150
+ .setBillingCountry(options.cardAddressBillingCountry)
151
+ .setCountryCode(options.cardAddressCountryCode)
135
152
  .build()
153
+ }
154
+ return null
155
+ }
156
+
157
+ internal fun getNetworkTimeout(options: ReadableMap): NetworkTimeout? {
158
+ val networkTimeout = options.networkTimeout
159
+ if (networkTimeout != null) {
160
+ return NetworkTimeout.Builder()
161
+ .setConnectTimeout(options.networkConnectTimeout)
162
+ .setReadTimeout(options.networkReadTimeout)
163
+ .setWriteTimeout(options.networkWriteTimeout)
164
+ .build()
165
+ }
166
+ return null
167
+ }
168
+
169
+ internal fun getChallengeRequestIndicator(options: ReadableMap): ChallengeRequestIndicator? {
170
+ val challengeRequestIndicator = ChallengeRequestIndicator.values().firstOrNull { it.value == options.challengeRequestIndicator }
171
+ return challengeRequestIndicator ?: ChallengeRequestIndicator.CHALLENGE_AS_MANDATE
172
+ }
173
+
174
+ internal fun getScaExemption(options: ReadableMap): ScaExemption {
175
+ val scaExemption = ScaExemption.values().firstOrNull { it.value == options.scaExemption }
176
+ return scaExemption ?: ScaExemption.LOW_VALUE
136
177
  }
137
178
 
138
179
  internal fun getAuthorization(options: ReadableMap): Authorization {
@@ -140,16 +181,16 @@ internal fun getAuthorization(options: ReadableMap): Authorization {
140
181
 
141
182
  options.secret?.let { secret ->
142
183
  return BasicAuthorization.Builder()
143
- .setApiToken(token)
144
- .setApiSecret(secret)
145
- .build()
184
+ .setApiToken(token)
185
+ .setApiSecret(secret)
186
+ .build()
146
187
  }
147
188
 
148
189
  options.paymentSession?.let { paymentSession ->
149
190
  return PaymentSessionAuthorization.Builder()
150
- .setApiToken(token)
151
- .setPaymentSession(paymentSession)
152
- .build()
191
+ .setApiToken(token)
192
+ .setPaymentSession(paymentSession)
193
+ .build()
153
194
  }
154
195
 
155
196
  throw IllegalArgumentException("No secret or payment session in the authorization")
@@ -174,16 +215,16 @@ internal fun getAmount(options: ReadableMap): Amount {
174
215
  else -> Currency.valueOf(currencyValue)
175
216
  }
176
217
  return Amount.Builder()
177
- .setAmount(options.amountValue)
178
- .setCurrency(currency)
179
- .build()
218
+ .setAmount(options.amountValue)
219
+ .setCurrency(currency)
220
+ .build()
180
221
  }
181
222
 
182
223
  internal fun getReference(options: ReadableMap): Reference? {
183
224
 
184
225
  var builder = Reference.Builder()
185
- .setConsumerReference(options.consumerReference)
186
- .setPaymentReference(options.paymentReference)
226
+ .setConsumerReference(options.consumerReference)
227
+ .setPaymentReference(options.paymentReference)
187
228
 
188
229
  val metadataMap = options.metadata
189
230
  metadataMap?.let {
@@ -291,11 +332,12 @@ internal fun getPaymentMethods(options: ReadableMap): Array<PaymentMethod>? {
291
332
  internal fun getUIConfiguration(options: ReadableMap): UiConfiguration? {
292
333
  return if (options.uiConfiguration != null) {
293
334
  UiConfiguration.Builder()
294
- .setAvsEnabled(options.isAVSEnabled)
295
- .setShouldPaymentMethodsDisplayAmount(options.shouldPaymentMethodsDisplayAmount)
296
- .setShouldPaymentButtonDisplayAmount(options.shouldPaymentButtonDisplayAmount)
297
- .setShouldPaymentMethodsVerifySecurityCode(options.shouldPaymentMethodsVerifySecurityCode)
298
- .build()
335
+ .setAvsEnabled(options.isAVSEnabled)
336
+ .setShouldPaymentMethodsDisplayAmount(options.shouldPaymentMethodsDisplayAmount)
337
+ .setShouldPaymentButtonDisplayAmount(options.shouldPaymentButtonDisplayAmount)
338
+ .setShouldPaymentMethodsVerifySecurityCode(options.shouldPaymentMethodsVerifySecurityCode)
339
+ .setShouldAskForBillingInformation(options.shouldAskForBillingInformation)
340
+ .build()
299
341
  } else {
300
342
  null
301
343
  }
@@ -326,14 +368,14 @@ internal fun getGooglePayConfiguration(options: ReadableMap): GooglePayConfigura
326
368
 
327
369
  return if (options.googlePayConfiguration != null) {
328
370
  GooglePayConfiguration.Builder()
329
- .setTransactionCountryCode(options.countryCode)
330
- .setEnvironment(environment)
331
- .setIsEmailRequired(options.isEmailRequired)
332
- .setIsBillingAddressRequired(options.isBillingAddressRequired)
333
- .setBillingAddressParameters(billingParameters)
334
- .setIsShippingAddressRequired(options.isShippingAddressRequired)
335
- .setShippingAddressParameters(shippingParameters)
336
- .build()
371
+ .setTransactionCountryCode(options.countryCode)
372
+ .setEnvironment(environment)
373
+ .setIsEmailRequired(options.isEmailRequired)
374
+ .setIsBillingAddressRequired(options.isBillingAddressRequired)
375
+ .setBillingAddressParameters(billingParameters)
376
+ .setIsShippingAddressRequired(options.isShippingAddressRequired)
377
+ .setShippingAddressParameters(shippingParameters)
378
+ .build()
337
379
  } else {
338
380
  null
339
381
  }
@@ -345,8 +387,8 @@ internal fun getBillingParameters(options: ReadableMap): GooglePayBillingAddress
345
387
  else -> GooglePayAddressFormat.FULL
346
388
  }
347
389
  return GooglePayBillingAddressParameters(
348
- addressFormat,
349
- options.isBillingPhoneNumberRequired
390
+ addressFormat,
391
+ options.isBillingPhoneNumberRequired
350
392
  )
351
393
  }
352
394
 
@@ -361,8 +403,8 @@ internal fun getShippingParameters(options: ReadableMap): GooglePayShippingAddre
361
403
  }
362
404
 
363
405
  return GooglePayShippingAddressParameters(
364
- allowedCountryCodes,
365
- options.isShippingPhoneNumberRequired
406
+ allowedCountryCodes,
407
+ options.isShippingPhoneNumberRequired
366
408
  )
367
409
  }
368
410
 
@@ -375,11 +417,11 @@ internal fun getPBBAConfiguration(options: ReadableMap): PBBAConfiguration? {
375
417
  }
376
418
 
377
419
  PBBAConfiguration.Builder()
378
- .setMobileNumber(options.mobileNumber)
379
- .setEmailAddress(options.emailAddress)
380
- .setDeepLinkURL(deeplinkUri)
381
- .setDeepLinkScheme(options.deeplinkScheme)
382
- .build()
420
+ .setMobileNumber(options.pbbaMobileNumber)
421
+ .setEmailAddress(options.pbbaEmailAddress)
422
+ .setDeepLinkURL(deeplinkUri)
423
+ .setDeepLinkScheme(options.deeplinkScheme)
424
+ .build()
383
425
  } else {
384
426
  null
385
427
  }
@@ -15,9 +15,9 @@ import com.judopay.judokit.android.api.model.response.Receipt
15
15
  import com.judopay.judokit.android.api.model.response.toCardVerificationModel
16
16
  import com.judopay.judokit.android.api.model.response.toJudoPaymentResult
17
17
  import com.judopay.judokit.android.api.model.response.toJudoResult
18
- import com.judopay.judokit.android.model.JudoPaymentResult
19
- import com.judopay.judokit.android.model.JudoResult
20
- import com.judopay.judokit.android.model.PaymentWidgetType
18
+ import com.judopay.judokit.android.model.*
19
+ import com.judopay.judokit.android.service.CardTransactionManager
20
+ import com.judopay.judokit.android.service.CardTransactionManagerResultListener
21
21
  import com.judopay.judokit.android.toTokenRequest
22
22
  import com.judopay.judokit.android.ui.cardverification.THREE_DS_ONE_DIALOG_FRAGMENT_TAG
23
23
  import com.judopay.judokit.android.ui.cardverification.ThreeDSOneCardVerificationDialogFragment
@@ -33,9 +33,10 @@ const val JUDO_PAYMENT_WIDGET_REQUEST_CODE = 65520
33
33
  const val JUDO_PROMISE_REJECTION_CODE = "JUDO_ERROR"
34
34
 
35
35
  class JudoReactNativeModule internal constructor(val context: ReactApplicationContext) :
36
- ReactContextBaseJavaModule(context) {
36
+ ReactContextBaseJavaModule(context), CardTransactionManagerResultListener {
37
37
 
38
38
  private val listener = JudoReactNativeActivityEventListener()
39
+ internal var transactionPromise: Promise? = null
39
40
 
40
41
  /**
41
42
  * A broadcast receiver to catch Pay by Bank app /order/bank/sale response event.
@@ -106,59 +107,75 @@ class JudoReactNativeModule internal constructor(val context: ReactApplicationCo
106
107
  @ReactMethod
107
108
  fun performTokenTransaction(options: ReadableMap, promise: Promise) {
108
109
  try {
110
+ val activity = context.currentActivity as FragmentActivity
111
+ val manager = CardTransactionManager.getInstance(activity)
109
112
 
110
113
  val judo = getTokenTransactionConfiguration(options)
111
114
 
112
- val service = JudoApiServiceFactory.createApiService(context, judo)
113
-
114
115
  val cardToken = options.cardToken
115
- val securityCode = options.securityCode
116
116
 
117
117
  if (cardToken == null) {
118
118
  promise.reject(JUDO_PROMISE_REJECTION_CODE, "No card token found")
119
119
  return
120
120
  }
121
121
 
122
- val tokenTransactionCallback = object : Callback<JudoApiCallResult<Receipt>> {
123
-
124
- override fun onFailure(call: Call<JudoApiCallResult<Receipt>>, t: Throwable) {
125
- promise.reject(t)
126
- }
127
-
128
- override fun onResponse(call: Call<JudoApiCallResult<Receipt>>, response: Response<JudoApiCallResult<Receipt>>) {
129
-
130
- if (response.body() == null) {
131
- promise.reject(JUDO_PROMISE_REJECTION_CODE, "Response body is empty")
132
- return
133
- }
134
-
135
- when (val data = response.body()?.toJudoPaymentResult(context.resources)) {
136
- is JudoPaymentResult.Success -> {
137
- val receipt = (response.body() as JudoApiCallResult.Success).data
138
- if (receipt != null && receipt.is3dSecureRequired) {
139
- handleThreeDSAuthentication(promise, service, receipt)
140
- } else {
141
- promise.resolve(getMappedResult(receipt?.toJudoResult()))
142
- }
143
- }
144
- is JudoPaymentResult.Error -> {
145
- promise.reject(JUDO_PROMISE_REJECTION_CODE, data.error.message)
146
- }
147
- }
148
- }
149
- }
122
+ val details = TransactionDetails.Builder()
123
+ .setCardHolderName(options.cardholderName)
124
+ .setSecurityNumber(options.securityCode)
125
+ .setCardType(options.cardType)
126
+ .setCardToken(cardToken)
127
+ .setEmail(judo.emailAddress)
128
+ .setCountryCode(judo.address?.countryCode.toString())
129
+ .setPhoneCountryCode(judo.phoneCountryCode)
130
+ .setMobileNumber(judo.mobileNumber)
131
+ .setAddressLine1(judo.address?.line1)
132
+ .setAddressLine2(judo.address?.line2)
133
+ .setAddressLine3(judo.address?.line3)
134
+ .setCity(judo.address?.town)
135
+ .setPostalCode(judo.address?.postCode)
136
+ .build()
137
+
138
+ transactionPromise = promise
150
139
 
151
140
  when (judo.paymentWidgetType) {
152
- PaymentWidgetType.CARD_PAYMENT -> service.tokenPayment(judo.toTokenRequest(cardToken, securityCode)).enqueue(tokenTransactionCallback)
153
- PaymentWidgetType.PRE_AUTH -> service.preAuthTokenPayment(judo.toTokenRequest(cardToken, securityCode)).enqueue(tokenTransactionCallback)
141
+ PaymentWidgetType.CARD_PAYMENT -> manager.paymentWithToken(details, JudoReactNativeModule::class.java.name)
142
+ PaymentWidgetType.PRE_AUTH -> manager.preAuthWithToken(details, JudoReactNativeModule::class.java.name)
154
143
  else -> promise.reject(JUDO_PROMISE_REJECTION_CODE, "${judo.paymentWidgetType.name} payment widget type is not valid for token transactions")
155
144
  }
156
-
157
145
  } catch (exception: Exception) {
158
146
  promise.reject(exception)
159
147
  }
160
148
  }
161
149
 
150
+ override fun initialize() {
151
+ super.initialize()
152
+
153
+ val activity = context.currentActivity as FragmentActivity
154
+ CardTransactionManager.getInstance(activity).registerResultListener(this)
155
+ }
156
+
157
+ override fun invalidate() {
158
+ super.invalidate()
159
+
160
+ val activity = context.currentActivity as FragmentActivity
161
+ CardTransactionManager.getInstance(activity).unRegisterResultListener(this)
162
+ }
163
+
164
+ override fun onCardTransactionResult(result: JudoPaymentResult) {
165
+ transactionPromise?.let {
166
+ if (result is JudoPaymentResult.Success) {
167
+ it.resolve(getMappedResult(result.result))
168
+ } else {
169
+ val message = when (result) {
170
+ is JudoPaymentResult.Error -> result.error.message
171
+ is JudoPaymentResult.UserCancelled -> result.error.message
172
+ else -> "The transaction was unsuccessful"
173
+ }
174
+ it.reject(JUDO_PROMISE_REJECTION_CODE, message)
175
+ }
176
+ }
177
+ }
178
+
162
179
  @ReactMethod
163
180
  fun isBankingAppAvailable(promise: Promise) {
164
181
  try {
@@ -173,40 +190,4 @@ class JudoReactNativeModule internal constructor(val context: ReactApplicationCo
173
190
  val intent = configuration.toJudoActivityIntent(it)
174
191
  it.startActivityForResult(intent, JUDO_PAYMENT_WIDGET_REQUEST_CODE)
175
192
  }
176
-
177
- private fun handleThreeDSAuthentication(promise: Promise, service: JudoApiService, receipt: Receipt) {
178
- val callback = object : ThreeDSOneCompletionCallback {
179
- override fun onSuccess(success: JudoPaymentResult) {
180
- handleSuccessfulThreeDSTransaction(success, promise)
181
- }
182
-
183
- override fun onFailure(error: JudoPaymentResult) {
184
- handleFailedThreeDSTransaction(error, promise)
185
- }
186
- }
187
-
188
- val fragment = ThreeDSOneCardVerificationDialogFragment(
189
- service,
190
- receipt.toCardVerificationModel(),
191
- callback
192
- )
193
- fragment.show((context.currentActivity as FragmentActivity).supportFragmentManager, THREE_DS_ONE_DIALOG_FRAGMENT_TAG)
194
- }
195
-
196
- private fun handleFailedThreeDSTransaction(error: JudoPaymentResult, promise: Promise) {
197
- val message = when (error) {
198
- is JudoPaymentResult.Error -> error.error.message
199
- is JudoPaymentResult.UserCancelled -> error.error.message
200
- else -> "The transaction was unsuccessful"
201
- }
202
- promise.reject(JUDO_PROMISE_REJECTION_CODE, message)
203
- }
204
-
205
- private fun handleSuccessfulThreeDSTransaction(success: JudoPaymentResult, promise: Promise) {
206
- if (success is JudoPaymentResult.Success) {
207
- promise.resolve(getMappedResult(success.result))
208
- } else {
209
- promise.reject(JUDO_PROMISE_REJECTION_CODE, "Unknown error occured")
210
- }
211
- }
212
193
  }
@@ -1,17 +1,17 @@
1
1
  package com.reactlibrary
2
2
 
3
+ import android.widget.Button
3
4
  import com.facebook.react.uimanager.SimpleViewManager
4
5
  import com.facebook.react.uimanager.ThemedReactContext
5
- import com.judopay.judokit.android.ui.common.PayByBankButton
6
6
 
7
- class JudoReactNativePBBAManager: SimpleViewManager<PayByBankButton>() {
7
+ class JudoReactNativePBBAManager: SimpleViewManager<Button>() {
8
8
 
9
9
  override fun getName(): String {
10
10
  return "RNPBBAButton"
11
11
  }
12
12
 
13
- override fun createViewInstance(reactContext: ThemedReactContext): PayByBankButton {
14
- return PayByBankButton(reactContext)
13
+ override fun createViewInstance(reactContext: ThemedReactContext): Button {
14
+ return Button(reactContext)
15
15
  }
16
16
 
17
17
  }
@@ -42,7 +42,7 @@ typedef NS_ENUM(NSUInteger, JudoSDKInvocationType) {
42
42
 
43
43
  @property (nonatomic, strong) JudoKit *judoKit;
44
44
  @property (nonatomic, strong) JPApiService *apiService;
45
- @property (nonatomic, strong) JP3DSService *threeDSService;
45
+ @property (nonatomic, strong) JPCardTransactionService *transactionService;
46
46
  @property (nonatomic, strong) JPCompletionBlock completionBlock;
47
47
 
48
48
  @end
@@ -104,31 +104,24 @@ RCT_REMAP_METHOD(performTokenTransaction,
104
104
  performTokenTransactionWithResolver:(RCTPromiseResolveBlock)resolve
105
105
  rejecter:(RCTPromiseRejectBlock)reject) {
106
106
 
107
- self.apiService = [RNWrappers apiServiceFromProperties:properties];
108
- self.threeDSService = [[JP3DSService alloc] initWithApiService:self.apiService];
107
+ self.transactionService = [RNWrappers cardTransactionServiceFromProperties:properties];
109
108
  self.completionBlock = [self completionBlockWithResolve:resolve andReject:reject];
110
109
 
111
110
  JPTransactionMode transactionMode = [RNWrappers transactionModeFromProperties:properties];
112
111
  JPConfiguration *configuration = [RNWrappers configurationFromProperties:properties];
113
-
114
- NSString *cardToken = [RNWrappers cardTokenFromProperties:properties];
115
- JPTokenRequest *tokenRequest = [[JPTokenRequest alloc] initWithConfiguration:configuration
116
- andCardToken:cardToken];
117
-
118
- __weak typeof(self) weakSelf = self;
119
-
112
+
113
+ JPCardTransactionDetails *details = [[JPCardTransactionDetails new] initWithConfiguration:configuration];
114
+ details.cardToken = [RNWrappers cardTokenFromProperties:properties];
115
+ details.secureCode = [RNWrappers securityCodeFromProperties:properties];
116
+ details.cardholderName = [RNWrappers cardholderNameFromProperties:properties];
117
+ details.cardType = [RNWrappers cardTypeFromProperties:properties];
118
+
120
119
  if (transactionMode == JPTransactionModePreAuth) {
121
- [self.apiService invokePreAuthTokenPaymentWithRequest:tokenRequest
122
- andCompletion:^(JPResponse *response, JPError *error) {
123
- [weakSelf handleResponse:response andError:error];
124
- }];
120
+ [self.transactionService invokePreAuthTokenPaymentWithDetails:details andCompletion:self.completionBlock];
125
121
  return;
126
122
  }
127
123
 
128
- [self.apiService invokeTokenPaymentWithRequest:tokenRequest
129
- andCompletion:^(JPResponse *response, JPError *error) {
130
- [weakSelf handleResponse:response andError:error];
131
- }];
124
+ [self.transactionService invokeTokenPaymentWithDetails:details andCompletion:self.completionBlock];
132
125
  }
133
126
 
134
127
  RCT_REMAP_METHOD(fetchTransactionDetails,
@@ -191,46 +184,27 @@ RCT_REMAP_METHOD(fetchTransactionDetails,
191
184
  NSError *error = [[NSError alloc] initWithDomain:RNJudoErrorDomain
192
185
  code:0
193
186
  userInfo:exception.userInfo];
194
-
195
187
  reject(kJudoPromiseRejectionCode, exception.reason, error);
196
188
  }
197
189
  }
198
190
 
199
- - (void)handleResponse:(JPResponse *)response andError:(JPError *)error {
200
-
201
- if (error.code != Judo3DSRequestError) {
202
- self.completionBlock(response, error);
203
- return;
204
- }
205
-
206
- JP3DSConfiguration *configuration = [JP3DSConfiguration configurationWithError:error];
207
- [self.threeDSService invoke3DSecureWithConfiguration:configuration completion:self.completionBlock];
208
- }
209
-
210
- //----------------------------------------------
211
- // MARK: - React Native methods
212
- //----------------------------------------------
213
-
214
- - (dispatch_queue_t)methodQueue {
215
- return dispatch_get_main_queue();
216
- }
217
-
218
- + (BOOL)requiresMainQueueSetup {
219
- return YES;
220
- }
221
-
222
191
  - (JPCompletionBlock)completionBlockWithResolve:(RCTPromiseResolveBlock)resolve
223
192
  andReject:(RCTPromiseRejectBlock)reject {
224
-
225
193
  return ^(JPResponse *response, NSError *error) {
226
194
  if (error) {
227
-
228
195
  if (error.code == JPError.judoUserDidCancelError.code) {
229
196
  reject(kJudoPromiseRejectionCode, @"Transaction cancelled", error);
230
197
  return;
231
198
  }
232
-
233
- reject(kJudoPromiseRejectionCode, @"Transaction failed", error);
199
+
200
+ NSString *description = error.userInfo[NSLocalizedDescriptionKey];
201
+ NSString *message = @"Transaction failed";
202
+
203
+ if (description && description.length > 0) {
204
+ message = description;
205
+ }
206
+
207
+ reject(kJudoPromiseRejectionCode, message, error);
234
208
  } else {
235
209
  NSDictionary *mappedResponse = [RNWrappers dictionaryFromResponse:response];
236
210
  resolve(mappedResponse);
@@ -238,4 +212,16 @@ RCT_REMAP_METHOD(fetchTransactionDetails,
238
212
  };
239
213
  }
240
214
 
215
+ //----------------------------------------------
216
+ // MARK: - React Native methods
217
+ //----------------------------------------------
218
+
219
+ - (dispatch_queue_t)methodQueue {
220
+ return dispatch_get_main_queue();
221
+ }
222
+
223
+ + (BOOL)requiresMainQueueSetup {
224
+ return YES;
225
+ }
226
+
241
227
  @end
@@ -46,6 +46,10 @@
46
46
  */
47
47
  + (JPApiService *)apiServiceFromProperties:(NSDictionary *)properties;
48
48
 
49
+ + (JPCardTransactionService *)cardTransactionServiceFromProperties:(NSDictionary *)properties;
50
+
51
+ + (id<JPAuthorization>)authorizationFromProperties:(NSDictionary *)properties;
52
+
49
53
  /**
50
54
  * A method that returns the correct TransactionType value based on the passed dictionary parameters
51
55
  * TransactionType is set to switch between Payment, PreAuth, Register Card, Check Card and Save Card transactions
@@ -96,6 +100,12 @@
96
100
  */
97
101
  + (NSString *)cardTokenFromProperties:(NSDictionary *)properties;
98
102
 
103
+ + (NSString *)securityCodeFromProperties:(NSDictionary *)properties;
104
+
105
+ + (NSString *)cardholderNameFromProperties:(NSDictionary *)properties;
106
+
107
+ + (JPCardNetworkType)cardTypeFromProperties:(NSDictionary *)properties;
108
+
99
109
  /**
100
110
  * A method that returns the receipt ID contained in the properties dictionary
101
111
  *