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.
- package/JudoPay.tsx +13 -3
- package/README.md +2 -2
- package/RNJudopay.podspec +1 -1
- package/android/build.gradle +21 -23
- package/android/src/main/java/com/reactlibrary/Extensions.kt +207 -34
- package/android/src/main/java/com/reactlibrary/Helpers.kt +98 -56
- package/android/src/main/java/com/reactlibrary/JudoReactNativeModule.kt +55 -74
- package/android/src/main/java/com/reactlibrary/JudoReactNativePBBAManager.kt +4 -4
- package/ios/Classes/RNJudo.m +32 -46
- package/ios/Classes/Wrappers/RNWrappers.h +10 -0
- package/ios/Classes/Wrappers/RNWrappers.m +116 -39
- package/ios/Podfile +2 -2
- package/ios/Podfile.lock +16 -8
- package/ios/RNJudo.xcodeproj/project.pbxproj +73 -92
- package/ios/RNJudo.xcodeproj/xcshareddata/xcschemes/RNJudo.xcscheme +1 -1
- package/package.json +1 -1
- package/types/JudoTypes.tsx +30 -0
|
@@ -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.
|
|
13
|
-
import com.judopay.judokit.android.model
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
184
|
+
.setApiToken(token)
|
|
185
|
+
.setApiSecret(secret)
|
|
186
|
+
.build()
|
|
146
187
|
}
|
|
147
188
|
|
|
148
189
|
options.paymentSession?.let { paymentSession ->
|
|
149
190
|
return PaymentSessionAuthorization.Builder()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
-
|
|
178
|
-
|
|
179
|
-
|
|
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
|
-
|
|
186
|
-
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
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
|
-
|
|
349
|
-
|
|
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
|
-
|
|
365
|
-
|
|
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
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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
|
|
19
|
-
import com.judopay.judokit.android.
|
|
20
|
-
import com.judopay.judokit.android.
|
|
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
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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 ->
|
|
153
|
-
PaymentWidgetType.PRE_AUTH ->
|
|
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<
|
|
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):
|
|
14
|
-
return
|
|
13
|
+
override fun createViewInstance(reactContext: ThemedReactContext): Button {
|
|
14
|
+
return Button(reactContext)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
}
|
package/ios/Classes/RNJudo.m
CHANGED
|
@@ -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)
|
|
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.
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
*
|