judokit-react-native 3.3.9 → 3.4.2
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/RNJudopay.podspec +1 -1
- package/android/build.gradle +3 -1
- package/android/src/main/java/com/reactlibrary/Extensions.kt +198 -34
- package/android/src/main/java/com/reactlibrary/Helpers.kt +97 -56
- package/android/src/main/java/com/reactlibrary/JudoReactNativeModule.kt +55 -77
- package/ios/Classes/RNJudo.m +33 -47
- package/ios/Classes/Wrappers/RNWrappers.h +10 -0
- package/ios/Classes/Wrappers/RNWrappers.m +115 -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 +29 -0
package/JudoPay.tsx
CHANGED
|
@@ -144,20 +144,30 @@ class JudoPay {
|
|
|
144
144
|
*
|
|
145
145
|
* @param mode - a JudoTransactionMode value that defines if the transaction is either a payment or pre-auth.
|
|
146
146
|
* @param configuration - a JudoConfiguration object that is used to configure/customize the payment flow.
|
|
147
|
-
* @param
|
|
147
|
+
* @param cardToken - the saved card token string.
|
|
148
|
+
* @param securityCode - the saved card token security code.
|
|
149
|
+
* @param cardholderName - the saved card token cardholder name.
|
|
150
|
+
* @param cardScheme - the saved card token scheme name.
|
|
148
151
|
*
|
|
149
152
|
* @returns an asynchronous JudoResponse object, containing the transaction results.
|
|
150
153
|
*/
|
|
151
154
|
public async performTokenTransaction(
|
|
152
155
|
mode: JudoTransactionMode,
|
|
153
156
|
configuration: JudoConfiguration,
|
|
154
|
-
|
|
157
|
+
cardToken: string,
|
|
158
|
+
securityCode: string,
|
|
159
|
+
cardholderName: string,
|
|
160
|
+
cardScheme: string
|
|
155
161
|
): Promise<JudoResponse> {
|
|
156
162
|
const params = this.generateTransactionModeParameters(
|
|
157
163
|
mode,
|
|
158
164
|
configuration
|
|
159
165
|
)
|
|
160
|
-
params['cardToken'] =
|
|
166
|
+
params['cardToken'] = cardToken
|
|
167
|
+
params['securityCode'] = securityCode
|
|
168
|
+
params['cardholderName'] = cardholderName
|
|
169
|
+
params['cardScheme'] = cardScheme
|
|
170
|
+
|
|
161
171
|
return NativeModules.RNJudo.performTokenTransaction(params)
|
|
162
172
|
}
|
|
163
173
|
|
package/RNJudopay.podspec
CHANGED
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.source_files = "ios/Classes/**/*.{h,m}"
|
|
16
16
|
s.requires_arc = true
|
|
17
17
|
s.dependency "React"
|
|
18
|
-
s.dependency "JudoKit-iOS", "
|
|
18
|
+
s.dependency "JudoKit-iOS", "3.1.0"
|
|
19
19
|
|
|
20
20
|
s.test_spec 'RNJudoTests' do |test_spec|
|
|
21
21
|
test_spec.source_files = 'ios/RNJudoTests/**/*.{h,m}'
|
package/android/build.gradle
CHANGED
|
@@ -86,6 +86,8 @@ repositories {
|
|
|
86
86
|
mavenCentral()
|
|
87
87
|
google()
|
|
88
88
|
|
|
89
|
+
maven { url 'https://vocalinkzapp.jfrog.io/artifactory/merchant-library-maven/' }
|
|
90
|
+
|
|
89
91
|
maven { url "$projectDir/../node_modules/react-native/android" }
|
|
90
92
|
}
|
|
91
93
|
|
|
@@ -99,7 +101,7 @@ dependencies {
|
|
|
99
101
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
|
|
100
102
|
implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.1.0'
|
|
101
103
|
|
|
102
|
-
implementation 'com.judopay:judokit-android:
|
|
104
|
+
implementation 'com.judopay:judokit-android:3.0.4'
|
|
103
105
|
|
|
104
106
|
//JUnit 5
|
|
105
107
|
testImplementation "org.junit.jupiter:junit-jupiter-api:$junit5_version"
|
|
@@ -7,6 +7,18 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
7
7
|
import com.judopay.judokit.android.JUDO_OPTIONS
|
|
8
8
|
import com.judopay.judokit.android.Judo
|
|
9
9
|
import com.judopay.judokit.android.JudoActivity
|
|
10
|
+
import com.judopay.judokit.android.model.CardNetwork
|
|
11
|
+
|
|
12
|
+
const val CARD_SCHEME_VISA = "visa"
|
|
13
|
+
const val CARD_SCHEME_MASTERCARD = "mastercard"
|
|
14
|
+
const val CARD_SCHEME_AMEX = "amex"
|
|
15
|
+
|
|
16
|
+
internal fun ReadableMap?.hasKey(key: String): Boolean {
|
|
17
|
+
if (this != null) {
|
|
18
|
+
return this.hasKey(key)
|
|
19
|
+
}
|
|
20
|
+
return false
|
|
21
|
+
}
|
|
10
22
|
|
|
11
23
|
internal val ReadableMap.configuration: ReadableMap?
|
|
12
24
|
get() = getMap("configuration")
|
|
@@ -31,6 +43,30 @@ internal val ReadableMap.securityCode: String?
|
|
|
31
43
|
return null
|
|
32
44
|
}
|
|
33
45
|
|
|
46
|
+
internal val ReadableMap.cardholderName: String?
|
|
47
|
+
get() {
|
|
48
|
+
if (hasKey("cardholderName")) {
|
|
49
|
+
return getString("cardholderName")
|
|
50
|
+
}
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
internal val ReadableMap.cardType: CardNetwork
|
|
55
|
+
get() {
|
|
56
|
+
val cardScheme = if (hasKey("cardScheme")) {
|
|
57
|
+
getString("cardScheme") ?: ""
|
|
58
|
+
} else {
|
|
59
|
+
""
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return when (cardScheme.lowercase()) {
|
|
63
|
+
CARD_SCHEME_VISA -> CardNetwork.VISA
|
|
64
|
+
CARD_SCHEME_MASTERCARD -> CardNetwork.MASTERCARD
|
|
65
|
+
CARD_SCHEME_AMEX -> CardNetwork.AMEX
|
|
66
|
+
else -> CardNetwork.OTHER
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
34
70
|
internal val ReadableMap.judoId: String?
|
|
35
71
|
get() = configuration?.getString("judoId")
|
|
36
72
|
|
|
@@ -64,10 +100,144 @@ internal val ReadableMap.paymentReference: String?
|
|
|
64
100
|
internal val ReadableMap.isInitialRecurringPayment: Boolean?
|
|
65
101
|
get() = configuration?.getBoolean("isInitialRecurringPayment")
|
|
66
102
|
|
|
103
|
+
internal val ReadableMap.networkTimeout: ReadableMap?
|
|
104
|
+
get() {
|
|
105
|
+
if (configuration.hasKey("networkTimeout")) {
|
|
106
|
+
return configuration?.getMap("networkTimeout")
|
|
107
|
+
}
|
|
108
|
+
return null
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
internal val ReadableMap.cardAddress: ReadableMap?
|
|
112
|
+
get() {
|
|
113
|
+
if (configuration.hasKey("cardAddress")) {
|
|
114
|
+
return configuration?.getMap("cardAddress")
|
|
115
|
+
}
|
|
116
|
+
return null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
internal val ReadableMap.cardAddressLine1: String?
|
|
120
|
+
get() {
|
|
121
|
+
if (cardAddress.hasKey("line1")) {
|
|
122
|
+
return cardAddress?.getString("line1")
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return null
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
internal val ReadableMap.cardAddressLine2: String?
|
|
129
|
+
get() {
|
|
130
|
+
if (cardAddress.hasKey("line2")) {
|
|
131
|
+
return cardAddress?.getString("line2")
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
internal val ReadableMap.cardAddressLine3: String?
|
|
138
|
+
get() {
|
|
139
|
+
if (cardAddress.hasKey("line3")) {
|
|
140
|
+
return cardAddress?.getString("line3")
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return null
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
internal val ReadableMap.cardAddressPostCode: String?
|
|
147
|
+
get() {
|
|
148
|
+
if (cardAddress.hasKey("postCode")) {
|
|
149
|
+
return cardAddress?.getString("postCode")
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return null
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
internal val ReadableMap.cardAddressTown: String?
|
|
156
|
+
get() {
|
|
157
|
+
if (cardAddress.hasKey("town")) {
|
|
158
|
+
return cardAddress?.getString("town")
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return null
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
internal val ReadableMap.cardAddressCountryCode: Int?
|
|
165
|
+
get() {
|
|
166
|
+
if (cardAddress.hasKey("countryCode")) {
|
|
167
|
+
return cardAddress?.getInt("countryCode")
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return null
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
internal val ReadableMap.networkConnectTimeout: Long?
|
|
174
|
+
get() = networkTimeout?.getDouble("connectTimeout")?.toLong()
|
|
175
|
+
|
|
176
|
+
internal val ReadableMap.networkReadTimeout: Long?
|
|
177
|
+
get() = networkTimeout?.getDouble("readTimeout")?.toLong()
|
|
178
|
+
|
|
179
|
+
internal val ReadableMap.networkWriteTimeout: Long?
|
|
180
|
+
get() = networkTimeout?.getDouble("writeTimeout")?.toLong()
|
|
181
|
+
|
|
182
|
+
internal val ReadableMap.challengeRequestIndicator: String?
|
|
183
|
+
get() {
|
|
184
|
+
if (configuration.hasKey("challengeRequestIndicator")) {
|
|
185
|
+
return configuration?.getString("challengeRequestIndicator")
|
|
186
|
+
}
|
|
187
|
+
return null
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
internal val ReadableMap.scaExemption: String?
|
|
191
|
+
get() {
|
|
192
|
+
if (configuration.hasKey("scaExemption")) {
|
|
193
|
+
return configuration?.getString("scaExemption")
|
|
194
|
+
}
|
|
195
|
+
return null
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
internal val ReadableMap.mobileNumber: String?
|
|
199
|
+
get() {
|
|
200
|
+
if (configuration.hasKey("mobileNumber")) {
|
|
201
|
+
return configuration?.getString("mobileNumber")
|
|
202
|
+
}
|
|
203
|
+
return null
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
internal val ReadableMap.phoneCountryCode: String?
|
|
207
|
+
get() {
|
|
208
|
+
if (configuration.hasKey("phoneCountryCode")) {
|
|
209
|
+
return configuration?.getString("phoneCountryCode")
|
|
210
|
+
}
|
|
211
|
+
return null
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
internal val ReadableMap.emailAddress: String?
|
|
215
|
+
get() {
|
|
216
|
+
if (configuration.hasKey("emailAddress")) {
|
|
217
|
+
return configuration?.getString("emailAddress")
|
|
218
|
+
}
|
|
219
|
+
return null
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
internal val ReadableMap.threeDSTwoMaxTimeout: Int?
|
|
223
|
+
get() {
|
|
224
|
+
if (configuration.hasKey("threeDSTwoMaxTimeout")) {
|
|
225
|
+
return configuration?.getInt("threeDSTwoMaxTimeout")
|
|
226
|
+
}
|
|
227
|
+
return null
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
internal val ReadableMap.threeDSTwoMessageVersion: String?
|
|
231
|
+
get() {
|
|
232
|
+
if (configuration.hasKey("threeDSTwoMessageVersion")) {
|
|
233
|
+
return configuration?.getString("threeDSTwoMessageVersion")
|
|
234
|
+
}
|
|
235
|
+
return null
|
|
236
|
+
}
|
|
237
|
+
|
|
67
238
|
internal val ReadableMap.metadata: ReadableMap?
|
|
68
239
|
get() {
|
|
69
|
-
|
|
70
|
-
if (hasKey) {
|
|
240
|
+
if (reference.hasKey("metadata")) {
|
|
71
241
|
return reference?.getMap("metadata")
|
|
72
242
|
}
|
|
73
243
|
return null
|
|
@@ -75,8 +245,7 @@ internal val ReadableMap.metadata: ReadableMap?
|
|
|
75
245
|
|
|
76
246
|
internal val ReadableMap.cardNetworkValue: Int?
|
|
77
247
|
get() {
|
|
78
|
-
|
|
79
|
-
if (hasKey) {
|
|
248
|
+
if (configuration.hasKey("supportedCardNetworks")) {
|
|
80
249
|
return configuration?.getInt("supportedCardNetworks")
|
|
81
250
|
}
|
|
82
251
|
return null
|
|
@@ -84,8 +253,7 @@ internal val ReadableMap.cardNetworkValue: Int?
|
|
|
84
253
|
|
|
85
254
|
internal val ReadableMap.paymentMethodValue: Int?
|
|
86
255
|
get() {
|
|
87
|
-
|
|
88
|
-
if (hasKey) {
|
|
256
|
+
if (configuration.hasKey("paymentMethods")) {
|
|
89
257
|
return configuration?.getInt("paymentMethods")
|
|
90
258
|
}
|
|
91
259
|
return null
|
|
@@ -93,8 +261,7 @@ internal val ReadableMap.paymentMethodValue: Int?
|
|
|
93
261
|
|
|
94
262
|
internal val ReadableMap.uiConfiguration: ReadableMap?
|
|
95
263
|
get() {
|
|
96
|
-
|
|
97
|
-
if (hasKey) {
|
|
264
|
+
if (configuration.hasKey("uiConfiguration")) {
|
|
98
265
|
return configuration?.getMap("uiConfiguration")
|
|
99
266
|
}
|
|
100
267
|
return null
|
|
@@ -112,10 +279,17 @@ internal val ReadableMap.shouldPaymentButtonDisplayAmount: Boolean?
|
|
|
112
279
|
internal val ReadableMap.shouldPaymentMethodsVerifySecurityCode: Boolean?
|
|
113
280
|
get() = uiConfiguration?.getBoolean("shouldPaymentMethodsVerifySecurityCode")
|
|
114
281
|
|
|
282
|
+
internal val ReadableMap.shouldAskForBillingInformation: Boolean
|
|
283
|
+
get() {
|
|
284
|
+
if (uiConfiguration.hasKey("shouldAskForBillingInformation")) {
|
|
285
|
+
return uiConfiguration?.getBoolean("shouldAskForBillingInformation") ?: true
|
|
286
|
+
}
|
|
287
|
+
return true
|
|
288
|
+
}
|
|
289
|
+
|
|
115
290
|
internal val ReadableMap.primaryAccountDetails: ReadableMap?
|
|
116
291
|
get() {
|
|
117
|
-
|
|
118
|
-
if (hasKey) {
|
|
292
|
+
if (configuration.hasKey("primaryAccountDetails")) {
|
|
119
293
|
return configuration?.getMap("primaryAccountDetails")
|
|
120
294
|
}
|
|
121
295
|
return null
|
|
@@ -123,8 +297,7 @@ internal val ReadableMap.primaryAccountDetails: ReadableMap?
|
|
|
123
297
|
|
|
124
298
|
internal val ReadableMap.name: String?
|
|
125
299
|
get() {
|
|
126
|
-
|
|
127
|
-
if (hasKey) {
|
|
300
|
+
if (primaryAccountDetails.hasKey("name")) {
|
|
128
301
|
return primaryAccountDetails?.getString("name")
|
|
129
302
|
}
|
|
130
303
|
return null
|
|
@@ -132,8 +305,7 @@ internal val ReadableMap.name: String?
|
|
|
132
305
|
|
|
133
306
|
internal val ReadableMap.accountNumber: String?
|
|
134
307
|
get() {
|
|
135
|
-
|
|
136
|
-
if (hasKey) {
|
|
308
|
+
if (primaryAccountDetails.hasKey("accountNumber")) {
|
|
137
309
|
return primaryAccountDetails?.getString("accountNumber")
|
|
138
310
|
}
|
|
139
311
|
return null
|
|
@@ -141,8 +313,7 @@ internal val ReadableMap.accountNumber: String?
|
|
|
141
313
|
|
|
142
314
|
internal val ReadableMap.dateOfBirth: String?
|
|
143
315
|
get() {
|
|
144
|
-
|
|
145
|
-
if (hasKey) {
|
|
316
|
+
if (primaryAccountDetails.hasKey("dateOfBirth")) {
|
|
146
317
|
return primaryAccountDetails?.getString("dateOfBirth")
|
|
147
318
|
}
|
|
148
319
|
return null
|
|
@@ -150,8 +321,7 @@ internal val ReadableMap.dateOfBirth: String?
|
|
|
150
321
|
|
|
151
322
|
internal val ReadableMap.postCode: String?
|
|
152
323
|
get() {
|
|
153
|
-
|
|
154
|
-
if (hasKey) {
|
|
324
|
+
if (primaryAccountDetails.hasKey("postCode")) {
|
|
155
325
|
return primaryAccountDetails?.getString("postCode")
|
|
156
326
|
}
|
|
157
327
|
return null
|
|
@@ -159,8 +329,7 @@ internal val ReadableMap.postCode: String?
|
|
|
159
329
|
|
|
160
330
|
internal val ReadableMap.googlePayConfiguration: ReadableMap?
|
|
161
331
|
get() {
|
|
162
|
-
|
|
163
|
-
if (hasKey) {
|
|
332
|
+
if (configuration.hasKey("googlePayConfiguration")) {
|
|
164
333
|
return configuration?.getMap("googlePayConfiguration")
|
|
165
334
|
}
|
|
166
335
|
return null
|
|
@@ -183,8 +352,7 @@ internal val ReadableMap.isShippingAddressRequired: Boolean?
|
|
|
183
352
|
|
|
184
353
|
internal val ReadableMap.billingAddressParameters: ReadableMap?
|
|
185
354
|
get() {
|
|
186
|
-
|
|
187
|
-
if (hasKey) {
|
|
355
|
+
if (googlePayConfiguration.hasKey("billingAddressParameters")) {
|
|
188
356
|
return googlePayConfiguration?.getMap("billingAddressParameters")
|
|
189
357
|
}
|
|
190
358
|
return null
|
|
@@ -192,8 +360,7 @@ internal val ReadableMap.billingAddressParameters: ReadableMap?
|
|
|
192
360
|
|
|
193
361
|
internal val ReadableMap.shippingAddressParameters: ReadableMap?
|
|
194
362
|
get() {
|
|
195
|
-
|
|
196
|
-
if (hasKey) {
|
|
363
|
+
if (googlePayConfiguration.hasKey("shippingAddressParameters")) {
|
|
197
364
|
return googlePayConfiguration?.getMap("shippingAddressParameters")
|
|
198
365
|
}
|
|
199
366
|
return null
|
|
@@ -210,8 +377,7 @@ internal val ReadableMap.isShippingPhoneNumberRequired: Boolean?
|
|
|
210
377
|
|
|
211
378
|
internal val ReadableMap.allowedCountryCodeList: ReadableArray?
|
|
212
379
|
get() {
|
|
213
|
-
|
|
214
|
-
if (hasKey) {
|
|
380
|
+
if (shippingAddressParameters.hasKey("allowedCountryCodes")) {
|
|
215
381
|
return shippingAddressParameters?.getArray("allowedCountryCodes")
|
|
216
382
|
}
|
|
217
383
|
return null
|
|
@@ -219,17 +385,16 @@ internal val ReadableMap.allowedCountryCodeList: ReadableArray?
|
|
|
219
385
|
|
|
220
386
|
internal val ReadableMap.pbbaConfiguration: ReadableMap?
|
|
221
387
|
get() {
|
|
222
|
-
|
|
223
|
-
if (hasKey) {
|
|
388
|
+
if (configuration.hasKey("pbbaConfiguration")) {
|
|
224
389
|
return configuration?.getMap("pbbaConfiguration")
|
|
225
390
|
}
|
|
226
391
|
return null
|
|
227
392
|
}
|
|
228
393
|
|
|
229
|
-
internal val ReadableMap.
|
|
394
|
+
internal val ReadableMap.pbbaMobileNumber: String?
|
|
230
395
|
get() = pbbaConfiguration?.getString("mobileNumber")
|
|
231
396
|
|
|
232
|
-
internal val ReadableMap.
|
|
397
|
+
internal val ReadableMap.pbbaEmailAddress: String?
|
|
233
398
|
get() = pbbaConfiguration?.getString("emailAddress")
|
|
234
399
|
|
|
235
400
|
internal val ReadableMap.deeplinkScheme: String?
|
|
@@ -237,8 +402,7 @@ internal val ReadableMap.deeplinkScheme: String?
|
|
|
237
402
|
|
|
238
403
|
internal val ReadableMap.deeplinkURL: String?
|
|
239
404
|
get() {
|
|
240
|
-
|
|
241
|
-
return if (hasKey) {
|
|
405
|
+
return if (pbbaConfiguration.hasKey("deeplinkURL")) {
|
|
242
406
|
pbbaConfiguration?.getString("deeplinkURL")
|
|
243
407
|
} else {
|
|
244
408
|
null
|
|
@@ -246,5 +410,5 @@ internal val ReadableMap.deeplinkURL: String?
|
|
|
246
410
|
}
|
|
247
411
|
|
|
248
412
|
fun Judo.toJudoActivityIntent(packageContext: Context): Intent =
|
|
249
|
-
|
|
250
|
-
|
|
413
|
+
Intent(packageContext, JudoActivity::class.java)
|
|
414
|
+
.also { it.putExtra(JUDO_OPTIONS, this) }
|
|
@@ -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,70 @@ 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
|
+
.setCountryCode(options.cardAddressCountryCode)
|
|
135
151
|
.build()
|
|
152
|
+
}
|
|
153
|
+
return null
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
internal fun getNetworkTimeout(options: ReadableMap): NetworkTimeout? {
|
|
157
|
+
val networkTimeout = options.networkTimeout
|
|
158
|
+
if (networkTimeout != null) {
|
|
159
|
+
return NetworkTimeout.Builder()
|
|
160
|
+
.setConnectTimeout(options.networkConnectTimeout)
|
|
161
|
+
.setReadTimeout(options.networkReadTimeout)
|
|
162
|
+
.setWriteTimeout(options.networkWriteTimeout)
|
|
163
|
+
.build()
|
|
164
|
+
}
|
|
165
|
+
return null
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
internal fun getChallengeRequestIndicator(options: ReadableMap): ChallengeRequestIndicator? {
|
|
169
|
+
val challengeRequestIndicator = ChallengeRequestIndicator.values().firstOrNull { it.value == options.challengeRequestIndicator }
|
|
170
|
+
return challengeRequestIndicator ?: ChallengeRequestIndicator.CHALLENGE_AS_MANDATE
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
internal fun getScaExemption(options: ReadableMap): ScaExemption {
|
|
174
|
+
val scaExemption = ScaExemption.values().firstOrNull { it.value == options.scaExemption }
|
|
175
|
+
return scaExemption ?: ScaExemption.LOW_VALUE
|
|
136
176
|
}
|
|
137
177
|
|
|
138
178
|
internal fun getAuthorization(options: ReadableMap): Authorization {
|
|
@@ -140,16 +180,16 @@ internal fun getAuthorization(options: ReadableMap): Authorization {
|
|
|
140
180
|
|
|
141
181
|
options.secret?.let { secret ->
|
|
142
182
|
return BasicAuthorization.Builder()
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
183
|
+
.setApiToken(token)
|
|
184
|
+
.setApiSecret(secret)
|
|
185
|
+
.build()
|
|
146
186
|
}
|
|
147
187
|
|
|
148
188
|
options.paymentSession?.let { paymentSession ->
|
|
149
189
|
return PaymentSessionAuthorization.Builder()
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
190
|
+
.setApiToken(token)
|
|
191
|
+
.setPaymentSession(paymentSession)
|
|
192
|
+
.build()
|
|
153
193
|
}
|
|
154
194
|
|
|
155
195
|
throw IllegalArgumentException("No secret or payment session in the authorization")
|
|
@@ -174,16 +214,16 @@ internal fun getAmount(options: ReadableMap): Amount {
|
|
|
174
214
|
else -> Currency.valueOf(currencyValue)
|
|
175
215
|
}
|
|
176
216
|
return Amount.Builder()
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
217
|
+
.setAmount(options.amountValue)
|
|
218
|
+
.setCurrency(currency)
|
|
219
|
+
.build()
|
|
180
220
|
}
|
|
181
221
|
|
|
182
222
|
internal fun getReference(options: ReadableMap): Reference? {
|
|
183
223
|
|
|
184
224
|
var builder = Reference.Builder()
|
|
185
|
-
|
|
186
|
-
|
|
225
|
+
.setConsumerReference(options.consumerReference)
|
|
226
|
+
.setPaymentReference(options.paymentReference)
|
|
187
227
|
|
|
188
228
|
val metadataMap = options.metadata
|
|
189
229
|
metadataMap?.let {
|
|
@@ -291,11 +331,12 @@ internal fun getPaymentMethods(options: ReadableMap): Array<PaymentMethod>? {
|
|
|
291
331
|
internal fun getUIConfiguration(options: ReadableMap): UiConfiguration? {
|
|
292
332
|
return if (options.uiConfiguration != null) {
|
|
293
333
|
UiConfiguration.Builder()
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
334
|
+
.setAvsEnabled(options.isAVSEnabled)
|
|
335
|
+
.setShouldPaymentMethodsDisplayAmount(options.shouldPaymentMethodsDisplayAmount)
|
|
336
|
+
.setShouldPaymentButtonDisplayAmount(options.shouldPaymentButtonDisplayAmount)
|
|
337
|
+
.setShouldPaymentMethodsVerifySecurityCode(options.shouldPaymentMethodsVerifySecurityCode)
|
|
338
|
+
.setShouldAskForBillingInformation(options.shouldAskForBillingInformation)
|
|
339
|
+
.build()
|
|
299
340
|
} else {
|
|
300
341
|
null
|
|
301
342
|
}
|
|
@@ -326,14 +367,14 @@ internal fun getGooglePayConfiguration(options: ReadableMap): GooglePayConfigura
|
|
|
326
367
|
|
|
327
368
|
return if (options.googlePayConfiguration != null) {
|
|
328
369
|
GooglePayConfiguration.Builder()
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
370
|
+
.setTransactionCountryCode(options.countryCode)
|
|
371
|
+
.setEnvironment(environment)
|
|
372
|
+
.setIsEmailRequired(options.isEmailRequired)
|
|
373
|
+
.setIsBillingAddressRequired(options.isBillingAddressRequired)
|
|
374
|
+
.setBillingAddressParameters(billingParameters)
|
|
375
|
+
.setIsShippingAddressRequired(options.isShippingAddressRequired)
|
|
376
|
+
.setShippingAddressParameters(shippingParameters)
|
|
377
|
+
.build()
|
|
337
378
|
} else {
|
|
338
379
|
null
|
|
339
380
|
}
|
|
@@ -345,8 +386,8 @@ internal fun getBillingParameters(options: ReadableMap): GooglePayBillingAddress
|
|
|
345
386
|
else -> GooglePayAddressFormat.FULL
|
|
346
387
|
}
|
|
347
388
|
return GooglePayBillingAddressParameters(
|
|
348
|
-
|
|
349
|
-
|
|
389
|
+
addressFormat,
|
|
390
|
+
options.isBillingPhoneNumberRequired
|
|
350
391
|
)
|
|
351
392
|
}
|
|
352
393
|
|
|
@@ -361,8 +402,8 @@ internal fun getShippingParameters(options: ReadableMap): GooglePayShippingAddre
|
|
|
361
402
|
}
|
|
362
403
|
|
|
363
404
|
return GooglePayShippingAddressParameters(
|
|
364
|
-
|
|
365
|
-
|
|
405
|
+
allowedCountryCodes,
|
|
406
|
+
options.isShippingPhoneNumberRequired
|
|
366
407
|
)
|
|
367
408
|
}
|
|
368
409
|
|
|
@@ -375,11 +416,11 @@ internal fun getPBBAConfiguration(options: ReadableMap): PBBAConfiguration? {
|
|
|
375
416
|
}
|
|
376
417
|
|
|
377
418
|
PBBAConfiguration.Builder()
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
419
|
+
.setMobileNumber(options.pbbaMobileNumber)
|
|
420
|
+
.setEmailAddress(options.pbbaEmailAddress)
|
|
421
|
+
.setDeepLinkURL(deeplinkUri)
|
|
422
|
+
.setDeepLinkScheme(options.deeplinkScheme)
|
|
423
|
+
.build()
|
|
383
424
|
} else {
|
|
384
425
|
null
|
|
385
426
|
}
|