judokit-react-native 4.4.0 → 5.0.1
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/JudoKit-ReactNative.podspec +1 -1
- package/README.md +2 -2
- package/android/build.gradle +74 -32
- package/android/gradle.properties +6 -6
- package/android/src/main/java/com/judopay/judokit/reactnative/Helpers.kt +24 -20
- package/android/src/main/java/com/judopay/judokit/reactnative/JudoActivityEventListener.kt +1 -1
- package/android/src/main/java/com/judopay/judokit/reactnative/{JudoKitReactNativeModule.kt → JudoKitReactNativeModuleImpl.kt} +48 -32
- package/android/src/newarch/java/com/judopay/judokit/reactnative/JudoKitReactNativeModule.kt +62 -0
- package/android/src/newarch/java/com/judopay/judokit/reactnative/JudoKitReactNativePackage.kt +38 -0
- package/android/src/oldarch/java/com/judopay/judokit/reactnative/JudoKitReactNativeModule.kt +55 -0
- package/ios/JudoKitReactNative.h +3 -4
- package/ios/JudoKitReactNative.mm +36 -24
- package/ios/RNTypes.h +0 -1
- package/ios/Wrappers/RNWrappers.m +2 -33
- package/lib/commonjs/judo-kit/index.js +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/specs/NativeJudoKitReactNativeModule.js +9 -0
- package/lib/commonjs/specs/NativeJudoKitReactNativeModule.js.map +1 -0
- package/lib/commonjs/types/judo-configuration.js +4 -1
- package/lib/commonjs/types/judo-configuration.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/judo-kit/index.js +3 -1
- package/lib/module/judo-kit/index.js.map +1 -1
- package/lib/module/specs/NativeJudoKitReactNativeModule.js +5 -0
- package/lib/module/specs/NativeJudoKitReactNativeModule.js.map +1 -0
- package/lib/module/types/index.js +2 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/judo-apple-pay-configuration.js +2 -0
- package/lib/module/types/judo-apple-pay-configuration.js.map +1 -1
- package/lib/module/types/judo-configuration.js +6 -1
- package/lib/module/types/judo-configuration.js.map +1 -1
- package/lib/module/types/judo-google-pay-configuration.js +2 -0
- package/lib/module/types/judo-google-pay-configuration.js.map +1 -1
- package/lib/typescript/src/judo-kit/index.d.ts +1 -1
- package/lib/typescript/src/specs/NativeJudoKitReactNativeModule.d.ts +14 -0
- package/lib/typescript/src/specs/NativeJudoKitReactNativeModule.d.ts.map +1 -0
- package/lib/typescript/src/types/judo-configuration.d.ts +0 -1
- package/lib/typescript/src/types/judo-configuration.d.ts.map +1 -1
- package/package.json +27 -17
- package/src/judo-kit/index.ts +1 -1
- package/src/specs/NativeJudoKitReactNativeModule.ts +16 -0
- package/src/types/judo-configuration.ts +0 -1
- /package/android/src/{main → oldarch}/java/com/judopay/judokit/reactnative/JudoKitReactNativePackage.kt +0 -0
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.source = { :git => "https://github.com/Judopay/JudoKit-ReactNative.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm}"
|
|
18
|
-
s.dependency "JudoKit-iOS", "
|
|
18
|
+
s.dependency "JudoKit-iOS", "5.0.2"
|
|
19
19
|
|
|
20
20
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
21
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
package/README.md
CHANGED
|
@@ -29,7 +29,7 @@ judoKit
|
|
|
29
29
|
.invokeTransaction(JudoTransactionType.Payment, {
|
|
30
30
|
judoId: '123456',
|
|
31
31
|
amount: {
|
|
32
|
-
value: '1.
|
|
32
|
+
value: '1.50',
|
|
33
33
|
currency: 'GBP',
|
|
34
34
|
},
|
|
35
35
|
reference: {
|
|
@@ -69,7 +69,7 @@ const judoKit = new JudoPay(authorization);
|
|
|
69
69
|
|
|
70
70
|
function App(): React.JSX.Element {
|
|
71
71
|
const invokeJudoKit = () => {
|
|
72
|
-
const amount: JudoAmount = {value: '1.
|
|
72
|
+
const amount: JudoAmount = {value: '1.50', currency: 'GBP'};
|
|
73
73
|
const reference: JudoReference = {
|
|
74
74
|
paymentReference: 'your-payment-reference',
|
|
75
75
|
consumerReference: 'your-consumer-reference',
|
package/android/build.gradle
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
buildscript {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['JudoKitReactNative_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
ext.getExtOrIntegerDefault = { name ->
|
|
7
|
+
return getExtOrDefault(name).toInteger()
|
|
8
|
+
}
|
|
4
9
|
|
|
5
10
|
repositories {
|
|
6
11
|
google()
|
|
@@ -8,44 +13,44 @@ buildscript {
|
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:8.
|
|
16
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
12
17
|
// noinspection DifferentKotlinGradleVersion
|
|
13
|
-
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$
|
|
18
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
14
19
|
}
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
def isNewArchitectureEnabled() {
|
|
18
|
-
|
|
23
|
+
// To opt-in for the New Architecture, you can either:
|
|
24
|
+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
25
|
+
// - Invoke gradle with `-newArchEnabled=true`
|
|
26
|
+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
27
|
+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
def reactNativeArchitectures() {
|
|
31
|
+
def value = project.getProperties().get("reactNativeArchitectures")
|
|
32
|
+
return value ? value.split(",") : [
|
|
33
|
+
"armeabi-v7a",
|
|
34
|
+
"x86",
|
|
35
|
+
"x86_64",
|
|
36
|
+
"arm64-v8a"
|
|
37
|
+
]
|
|
19
38
|
}
|
|
20
39
|
|
|
21
40
|
apply plugin: "com.android.library"
|
|
22
41
|
apply plugin: "kotlin-android"
|
|
23
42
|
|
|
24
43
|
if (isNewArchitectureEnabled()) {
|
|
25
|
-
apply plugin:
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
def getExtOrDefault(name) {
|
|
29
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["JudoKitReactNative_" + name]
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
def getExtOrIntegerDefault(name) {
|
|
33
|
-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["JudoKitReactNative_" + name]).toInteger()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
def supportsNamespace() {
|
|
37
|
-
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
|
|
38
|
-
def major = parsed[0].toInteger()
|
|
39
|
-
def minor = parsed[1].toInteger()
|
|
40
|
-
|
|
41
|
-
// Namespace support was added in 7.3.0
|
|
42
|
-
return (major == 7 && minor >= 3) || major >= 8
|
|
44
|
+
apply plugin: 'com.facebook.react'
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
android {
|
|
46
|
-
|
|
48
|
+
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
49
|
+
if (agpVersion.tokenize('.')[0].toInteger() >= 7) {
|
|
47
50
|
namespace "com.judopay.judokit.reactnative"
|
|
48
|
-
|
|
51
|
+
buildFeatures {
|
|
52
|
+
buildConfig true
|
|
53
|
+
}
|
|
49
54
|
sourceSets {
|
|
50
55
|
main {
|
|
51
56
|
manifest.srcFile "src/main/AndroidManifestNew.xml"
|
|
@@ -55,10 +60,23 @@ android {
|
|
|
55
60
|
|
|
56
61
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
57
62
|
|
|
63
|
+
// Used to override the NDK path/version on internal CI or by allowing
|
|
64
|
+
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
|
65
|
+
if (rootProject.hasProperty("ndkPath")) {
|
|
66
|
+
ndkPath rootProject.ext.ndkPath
|
|
67
|
+
}
|
|
68
|
+
if (rootProject.hasProperty("ndkVersion")) {
|
|
69
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
70
|
+
}
|
|
71
|
+
|
|
58
72
|
defaultConfig {
|
|
59
73
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
60
74
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
75
|
+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
61
76
|
|
|
77
|
+
ndk {
|
|
78
|
+
abiFilters (*reactNativeArchitectures())
|
|
79
|
+
}
|
|
62
80
|
}
|
|
63
81
|
|
|
64
82
|
buildTypes {
|
|
@@ -75,21 +93,45 @@ android {
|
|
|
75
93
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
76
94
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
77
95
|
}
|
|
96
|
+
|
|
97
|
+
sourceSets.main {
|
|
98
|
+
java {
|
|
99
|
+
if (isNewArchitectureEnabled()) {
|
|
100
|
+
srcDirs += [
|
|
101
|
+
"src/newarch/java",
|
|
102
|
+
// Codegen specs
|
|
103
|
+
"generated/java",
|
|
104
|
+
"generated/jni"
|
|
105
|
+
]
|
|
106
|
+
} else {
|
|
107
|
+
srcDirs += [
|
|
108
|
+
"src/oldarch/java"
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
78
113
|
}
|
|
79
114
|
|
|
80
115
|
repositories {
|
|
81
116
|
mavenCentral()
|
|
117
|
+
maven {
|
|
118
|
+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
119
|
+
url "$rootDir/../node_modules/react-native/android"
|
|
120
|
+
}
|
|
82
121
|
google()
|
|
83
122
|
}
|
|
84
123
|
|
|
85
|
-
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
86
|
-
def judokit_android_version = getExtOrDefault("judoKitAndroidVersion")
|
|
87
|
-
|
|
88
124
|
dependencies {
|
|
89
|
-
// For < 0.71, this will be from the local maven repo
|
|
90
|
-
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
|
|
91
125
|
//noinspection GradleDynamicVersion
|
|
92
126
|
implementation "com.facebook.react:react-native:+"
|
|
93
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib:$
|
|
94
|
-
implementation "com.judopay:judokit-android:$
|
|
127
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:${getExtOrDefault('kotlinVersion')}"
|
|
128
|
+
implementation "com.judopay:judokit-android:${getExtOrDefault('judoKitAndroidVersion')}"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (isNewArchitectureEnabled()) {
|
|
132
|
+
react {
|
|
133
|
+
jsRootDir = file("../src/")
|
|
134
|
+
libraryName = "JudoKitReactNative"
|
|
135
|
+
codegenJavaPackageName = "com.judopay.judokit.reactnative"
|
|
136
|
+
}
|
|
95
137
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
JudoKitReactNative_kotlinVersion=1.
|
|
2
|
-
JudoKitReactNative_minSdkVersion=
|
|
3
|
-
JudoKitReactNative_targetSdkVersion=
|
|
4
|
-
JudoKitReactNative_compileSdkVersion=
|
|
5
|
-
JudoKitReactNative_ndkversion=
|
|
6
|
-
JudoKitReactNative_judoKitAndroidVersion=
|
|
1
|
+
JudoKitReactNative_kotlinVersion=2.1.21
|
|
2
|
+
JudoKitReactNative_minSdkVersion=24
|
|
3
|
+
JudoKitReactNative_targetSdkVersion=35
|
|
4
|
+
JudoKitReactNative_compileSdkVersion=35
|
|
5
|
+
JudoKitReactNative_ndkversion=27.1.12297006
|
|
6
|
+
JudoKitReactNative_judoKitAndroidVersion=5.0.2
|
|
@@ -45,10 +45,14 @@ import com.judopay.judokit.android.model.typeId
|
|
|
45
45
|
private const val TRANSACTION_TYPE_PAYMENT = "payment"
|
|
46
46
|
private const val TRANSACTION_TYPE_PRE_AUTH = "preauth"
|
|
47
47
|
|
|
48
|
-
@Deprecated(
|
|
48
|
+
@Deprecated(
|
|
49
|
+
"Register Card functionality has been deprecated. Please use Check Card feature instead.",
|
|
50
|
+
)
|
|
49
51
|
private const val TRANSACTION_TYPE_REGISTER = "register"
|
|
50
52
|
|
|
51
|
-
@Deprecated(
|
|
53
|
+
@Deprecated(
|
|
54
|
+
"Register Card functionality has been deprecated. Please use Check Card feature instead.",
|
|
55
|
+
)
|
|
52
56
|
private const val TRANSACTION_TYPE_REGISTER_CARD = "registercard"
|
|
53
57
|
private const val TRANSACTION_TYPE_SAVE_CARD = "save"
|
|
54
58
|
private const val TRANSACTION_TYPE_CHECK_CARD = "checkcard"
|
|
@@ -123,7 +127,9 @@ internal fun getPaymentMethodsConfiguration(options: ReadableMap): Judo {
|
|
|
123
127
|
internal fun getMappedType(type: String?): Int {
|
|
124
128
|
val typeInLowercase = type?.lowercase()
|
|
125
129
|
val typeValue =
|
|
126
|
-
TransactionType.values().firstOrNull {
|
|
130
|
+
TransactionType.values().firstOrNull {
|
|
131
|
+
it.typeAsStrings?.contains(typeInLowercase) ?: false
|
|
132
|
+
}
|
|
127
133
|
|
|
128
134
|
return typeValue?.value ?: TransactionType.UNKNOWN.value
|
|
129
135
|
}
|
|
@@ -187,11 +193,7 @@ internal fun getJudoConfigurationForApiService(options: ReadableMap): Judo {
|
|
|
187
193
|
.setCurrency(Currency.GBP)
|
|
188
194
|
.build()
|
|
189
195
|
|
|
190
|
-
val reference =
|
|
191
|
-
Reference
|
|
192
|
-
.Builder()
|
|
193
|
-
.setConsumerReference("reference")
|
|
194
|
-
.build()
|
|
196
|
+
val reference = Reference.Builder().setConsumerReference("reference").build()
|
|
195
197
|
|
|
196
198
|
return Judo
|
|
197
199
|
.Builder(PaymentWidgetType.CARD_PAYMENT)
|
|
@@ -231,7 +233,6 @@ internal fun getJudoConfiguration(
|
|
|
231
233
|
.setReference(reference)
|
|
232
234
|
.setSupportedCardNetworks(cardNetworks)
|
|
233
235
|
.setPaymentMethods(paymentMethods)
|
|
234
|
-
.setUiConfiguration(uiConfiguration)
|
|
235
236
|
.setPrimaryAccountDetails(primaryAccountDetails)
|
|
236
237
|
.setGooglePayConfiguration(googlePayConfiguration)
|
|
237
238
|
.setInitialRecurringPayment(options.isInitialRecurringPayment)
|
|
@@ -248,6 +249,10 @@ internal fun getJudoConfiguration(
|
|
|
248
249
|
.setAddress(address)
|
|
249
250
|
.setSubProductInfo(getSubProductInfo(options))
|
|
250
251
|
|
|
252
|
+
if (uiConfiguration != null) {
|
|
253
|
+
builder.setUiConfiguration(uiConfiguration)
|
|
254
|
+
}
|
|
255
|
+
|
|
251
256
|
if (type.isTokenPayment) {
|
|
252
257
|
val cardHolderName = options.cardholderName?.ifBlank { null }
|
|
253
258
|
val securityCode = options.securityCode?.ifBlank { null }
|
|
@@ -273,7 +278,9 @@ internal fun getJudoConfiguration(
|
|
|
273
278
|
}
|
|
274
279
|
|
|
275
280
|
internal fun getRecommendationConfiguration(options: ReadableMap): RecommendationConfiguration? =
|
|
276
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 &&
|
|
281
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1 &&
|
|
282
|
+
options.recommendationConfiguration != null
|
|
283
|
+
) {
|
|
277
284
|
RecommendationConfiguration
|
|
278
285
|
.Builder()
|
|
279
286
|
.setUrl(options.recommendationURL)
|
|
@@ -315,7 +322,9 @@ internal fun getNetworkTimeout(options: ReadableMap): NetworkTimeout? {
|
|
|
315
322
|
}
|
|
316
323
|
|
|
317
324
|
internal fun getChallengeRequestIndicator(options: ReadableMap): ChallengeRequestIndicator? =
|
|
318
|
-
ChallengeRequestIndicator.values().firstOrNull {
|
|
325
|
+
ChallengeRequestIndicator.values().firstOrNull {
|
|
326
|
+
it.value == options.challengeRequestIndicator
|
|
327
|
+
}
|
|
319
328
|
|
|
320
329
|
internal fun getScaExemption(options: ReadableMap): ScaExemption? = ScaExemption.values().firstOrNull { it.value == options.scaExemption }
|
|
321
330
|
|
|
@@ -385,9 +394,7 @@ internal fun getReference(options: ReadableMap): Reference? {
|
|
|
385
394
|
val metadataMap = options.metadata
|
|
386
395
|
metadataMap?.let {
|
|
387
396
|
val bundle = Bundle()
|
|
388
|
-
metadataMap.toHashMap().forEach {
|
|
389
|
-
bundle.putString(it.key, it.value.toString())
|
|
390
|
-
}
|
|
397
|
+
metadataMap.toHashMap().forEach { bundle.putString(it.key, it.value.toString()) }
|
|
391
398
|
builder = builder.setMetaData(bundle)
|
|
392
399
|
}
|
|
393
400
|
|
|
@@ -455,7 +462,6 @@ internal fun getPaymentMethods(options: ReadableMap): Array<PaymentMethod>? {
|
|
|
455
462
|
|
|
456
463
|
val cardPaymentValue = 1
|
|
457
464
|
val googlePaymentValue = 1 shl 2
|
|
458
|
-
val idealPaymentValue = 1 shl 3
|
|
459
465
|
val allPaymentValues = 1 shl 5
|
|
460
466
|
|
|
461
467
|
options.paymentMethodValue?.let {
|
|
@@ -469,10 +475,6 @@ internal fun getPaymentMethods(options: ReadableMap): Array<PaymentMethod>? {
|
|
|
469
475
|
paymentMethods?.add(PaymentMethod.GOOGLE_PAY)
|
|
470
476
|
}
|
|
471
477
|
|
|
472
|
-
if (it and idealPaymentValue == idealPaymentValue) {
|
|
473
|
-
// noop
|
|
474
|
-
}
|
|
475
|
-
|
|
476
478
|
if (it and allPaymentValues == allPaymentValues) {
|
|
477
479
|
return PaymentMethod.values()
|
|
478
480
|
}
|
|
@@ -498,7 +500,9 @@ internal fun getUIConfiguration(options: ReadableMap): UiConfiguration? {
|
|
|
498
500
|
options.isAVSEnabled?.let { setAvsEnabled(it) }
|
|
499
501
|
options.shouldPaymentMethodsDisplayAmount?.let { setShouldPaymentMethodsDisplayAmount(it) }
|
|
500
502
|
options.shouldPaymentButtonDisplayAmount?.let { setShouldPaymentButtonDisplayAmount(it) }
|
|
501
|
-
options.shouldPaymentMethodsVerifySecurityCode?.let {
|
|
503
|
+
options.shouldPaymentMethodsVerifySecurityCode?.let {
|
|
504
|
+
setShouldPaymentMethodsVerifySecurityCode(it)
|
|
505
|
+
}
|
|
502
506
|
}
|
|
503
507
|
|
|
504
508
|
return builder.build()
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
package com.judopay.judokit.reactnative
|
|
2
2
|
|
|
3
|
+
import android.app.Activity
|
|
3
4
|
import com.facebook.react.bridge.Promise
|
|
4
5
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
-
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
-
import com.facebook.react.bridge.ReactMethod
|
|
7
6
|
import com.facebook.react.bridge.ReadableMap
|
|
8
7
|
import com.judopay.judokit.android.Judo
|
|
9
8
|
import com.judopay.judokit.android.api.factory.JudoApiServiceFactory
|
|
@@ -14,65 +13,60 @@ import retrofit2.Call
|
|
|
14
13
|
import retrofit2.Callback
|
|
15
14
|
import retrofit2.Response
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const val MODULE_NAME = "JudoKitReactNative"
|
|
19
|
-
|
|
20
|
-
class JudoKitReactNativeModule internal constructor(
|
|
16
|
+
class JudoKitReactNativeModuleImpl(
|
|
21
17
|
private val reactContext: ReactApplicationContext,
|
|
22
|
-
)
|
|
23
|
-
override fun getName() = MODULE_NAME
|
|
24
|
-
|
|
18
|
+
) {
|
|
25
19
|
private val listener = JudoActivityEventListener()
|
|
26
20
|
|
|
27
21
|
init {
|
|
28
22
|
reactContext.addActivityEventListener(listener)
|
|
29
23
|
}
|
|
30
24
|
|
|
31
|
-
@ReactMethod
|
|
32
25
|
fun invokeTransaction(
|
|
26
|
+
currentActivity: Activity?,
|
|
33
27
|
options: ReadableMap,
|
|
34
28
|
promise: Promise,
|
|
35
29
|
) {
|
|
36
30
|
try {
|
|
37
31
|
val judo = getTransactionConfiguration(options)
|
|
38
|
-
startJudoActivity(judo, promise)
|
|
32
|
+
startJudoActivity(currentActivity, judo, promise)
|
|
39
33
|
} catch (error: Exception) {
|
|
40
34
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, error.localizedMessage, error)
|
|
41
35
|
}
|
|
42
36
|
}
|
|
43
37
|
|
|
44
|
-
@ReactMethod
|
|
45
38
|
fun invokeGooglePay(
|
|
39
|
+
currentActivity: Activity?,
|
|
46
40
|
options: ReadableMap,
|
|
47
41
|
promise: Promise,
|
|
48
42
|
) {
|
|
49
43
|
try {
|
|
50
44
|
val judo = getGoogleTransactionConfiguration(options)
|
|
51
|
-
startJudoActivity(judo, promise)
|
|
45
|
+
startJudoActivity(currentActivity, judo, promise)
|
|
52
46
|
} catch (error: Exception) {
|
|
53
47
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, error.localizedMessage, error)
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
50
|
|
|
57
|
-
@ReactMethod
|
|
58
51
|
fun invokePaymentMethodScreen(
|
|
52
|
+
currentActivity: Activity?,
|
|
59
53
|
options: ReadableMap,
|
|
60
54
|
promise: Promise,
|
|
61
55
|
) {
|
|
62
56
|
try {
|
|
63
57
|
val judo = getPaymentMethodsConfiguration(options)
|
|
64
|
-
startJudoActivity(judo, promise)
|
|
58
|
+
startJudoActivity(currentActivity, judo, promise)
|
|
65
59
|
} catch (error: Exception) {
|
|
66
60
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, error.localizedMessage, error)
|
|
67
61
|
}
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
@ReactMethod
|
|
71
64
|
fun performTokenTransaction(
|
|
65
|
+
currentActivity: Activity?,
|
|
72
66
|
options: ReadableMap,
|
|
73
67
|
promise: Promise,
|
|
74
68
|
) {
|
|
75
|
-
if (options.cardToken
|
|
69
|
+
if (options.cardToken.isNullOrEmpty()) {
|
|
76
70
|
promise.reject(
|
|
77
71
|
JUDO_PROMISE_REJECTION_CODE,
|
|
78
72
|
"No card token provided, please make sure you provide it when invoking performTokenTransaction.",
|
|
@@ -82,13 +76,12 @@ class JudoKitReactNativeModule internal constructor(
|
|
|
82
76
|
|
|
83
77
|
try {
|
|
84
78
|
val judo = getTokenTransactionConfiguration(options)
|
|
85
|
-
startJudoActivity(judo, promise)
|
|
79
|
+
startJudoActivity(currentActivity, judo, promise)
|
|
86
80
|
} catch (error: Exception) {
|
|
87
81
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, error.localizedMessage, error)
|
|
88
82
|
}
|
|
89
83
|
}
|
|
90
84
|
|
|
91
|
-
@ReactMethod
|
|
92
85
|
fun fetchTransactionDetails(
|
|
93
86
|
options: ReadableMap,
|
|
94
87
|
promise: Promise,
|
|
@@ -99,7 +92,7 @@ class JudoKitReactNativeModule internal constructor(
|
|
|
99
92
|
|
|
100
93
|
val service = JudoApiServiceFactory.create(reactContext, judo)
|
|
101
94
|
|
|
102
|
-
|
|
95
|
+
service.fetchTransactionWithReceiptId(receiptId).enqueue(
|
|
103
96
|
object : Callback<JudoApiCallResult<Receipt>> {
|
|
104
97
|
override fun onResponse(
|
|
105
98
|
call: Call<JudoApiCallResult<Receipt>>,
|
|
@@ -112,7 +105,10 @@ class JudoKitReactNativeModule internal constructor(
|
|
|
112
105
|
val judoResult = receipt.toJudoResult()
|
|
113
106
|
promise.resolve(getMappedResult(judoResult))
|
|
114
107
|
} else {
|
|
115
|
-
promise.reject(
|
|
108
|
+
promise.reject(
|
|
109
|
+
JUDO_PROMISE_REJECTION_CODE,
|
|
110
|
+
REQUEST_FAILED_MESSAGE,
|
|
111
|
+
)
|
|
116
112
|
}
|
|
117
113
|
}
|
|
118
114
|
|
|
@@ -122,7 +118,10 @@ class JudoKitReactNativeModule internal constructor(
|
|
|
122
118
|
}
|
|
123
119
|
|
|
124
120
|
else -> {
|
|
125
|
-
promise.reject(
|
|
121
|
+
promise.reject(
|
|
122
|
+
JUDO_PROMISE_REJECTION_CODE,
|
|
123
|
+
REQUEST_FAILED_MESSAGE,
|
|
124
|
+
)
|
|
126
125
|
}
|
|
127
126
|
}
|
|
128
127
|
}
|
|
@@ -133,22 +132,39 @@ class JudoKitReactNativeModule internal constructor(
|
|
|
133
132
|
) {
|
|
134
133
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, throwable.localizedMessage, throwable)
|
|
135
134
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
service
|
|
139
|
-
.fetchTransactionWithReceiptId(receiptId)
|
|
140
|
-
.enqueue(fetchTransactionDetailsCallback)
|
|
135
|
+
},
|
|
136
|
+
)
|
|
141
137
|
} catch (error: Exception) {
|
|
142
138
|
promise.reject(JUDO_PROMISE_REJECTION_CODE, error.localizedMessage, error)
|
|
143
139
|
}
|
|
144
140
|
}
|
|
145
141
|
|
|
142
|
+
fun isApplePayAvailableWithConfiguration(
|
|
143
|
+
params: ReadableMap,
|
|
144
|
+
promise: Promise,
|
|
145
|
+
) = promise.reject(JUDO_PROMISE_REJECTION_CODE, APPLE_PAY_UNSUPPORTED)
|
|
146
|
+
|
|
147
|
+
fun invokeApplePay(
|
|
148
|
+
params: ReadableMap,
|
|
149
|
+
promise: Promise,
|
|
150
|
+
) = promise.reject(JUDO_PROMISE_REJECTION_CODE, APPLE_PAY_UNSUPPORTED)
|
|
151
|
+
|
|
146
152
|
private fun startJudoActivity(
|
|
147
|
-
|
|
153
|
+
currentActivity: Activity?,
|
|
154
|
+
judo: Judo,
|
|
148
155
|
promise: Promise,
|
|
149
|
-
)
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
) {
|
|
157
|
+
currentActivity?.let {
|
|
158
|
+
listener.transactionPromise = promise
|
|
159
|
+
val intent = judo.toJudoActivityIntent(it)
|
|
160
|
+
it.startActivityForResult(intent, JUDO_PAYMENT_WIDGET_REQUEST_CODE)
|
|
161
|
+
} ?: promise.reject(JUDO_PROMISE_REJECTION_CODE, "No current activity available")
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
companion object {
|
|
165
|
+
const val REQUEST_FAILED_MESSAGE = "The request was unsuccessful."
|
|
166
|
+
const val JUDO_PROMISE_REJECTION_CODE = "JUDO_ERROR"
|
|
167
|
+
const val APPLE_PAY_UNSUPPORTED = "Apple Pay is not supported on Android."
|
|
168
|
+
const val NAME = "JudoKitReactNative"
|
|
153
169
|
}
|
|
154
170
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package com.judopay.judokit.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReadableMap
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
|
|
8
|
+
@ReactModule(name = JudoKitReactNativeModuleImpl.NAME)
|
|
9
|
+
class JudoKitReactNativeModule(
|
|
10
|
+
reactContext: ReactApplicationContext,
|
|
11
|
+
) : NativeJudoKitReactNativeModuleSpec(reactContext) {
|
|
12
|
+
private val moduleImpl = JudoKitReactNativeModuleImpl(reactContext)
|
|
13
|
+
|
|
14
|
+
override fun invokeTransaction(
|
|
15
|
+
options: ReadableMap,
|
|
16
|
+
promise: Promise,
|
|
17
|
+
) {
|
|
18
|
+
moduleImpl.invokeTransaction(currentActivity, options, promise)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun invokeGooglePay(
|
|
22
|
+
options: ReadableMap,
|
|
23
|
+
promise: Promise,
|
|
24
|
+
) {
|
|
25
|
+
moduleImpl.invokeGooglePay(currentActivity, options, promise)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
override fun invokePaymentMethodScreen(
|
|
29
|
+
options: ReadableMap,
|
|
30
|
+
promise: Promise,
|
|
31
|
+
) {
|
|
32
|
+
moduleImpl.invokePaymentMethodScreen(currentActivity, options, promise)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun performTokenTransaction(
|
|
36
|
+
options: ReadableMap,
|
|
37
|
+
promise: Promise,
|
|
38
|
+
) {
|
|
39
|
+
moduleImpl.performTokenTransaction(currentActivity, options, promise)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
override fun fetchTransactionDetails(
|
|
43
|
+
options: ReadableMap,
|
|
44
|
+
promise: Promise,
|
|
45
|
+
) {
|
|
46
|
+
moduleImpl.fetchTransactionDetails(options, promise)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
override fun isApplePayAvailableWithConfiguration(
|
|
50
|
+
params: ReadableMap,
|
|
51
|
+
promise: Promise,
|
|
52
|
+
) {
|
|
53
|
+
moduleImpl.isApplePayAvailableWithConfiguration(params, promise)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
override fun invokeApplePay(
|
|
57
|
+
params: ReadableMap,
|
|
58
|
+
promise: Promise,
|
|
59
|
+
) {
|
|
60
|
+
moduleImpl.invokeApplePay(params, promise)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package com.judopay.judokit.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
8
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
9
|
+
|
|
10
|
+
class JudoKitReactNativePackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(
|
|
12
|
+
name: String,
|
|
13
|
+
reactContext: ReactApplicationContext,
|
|
14
|
+
): NativeModule? =
|
|
15
|
+
if (name == JudoKitReactNativeModuleImpl.NAME) {
|
|
16
|
+
JudoKitReactNativeModule(reactContext)
|
|
17
|
+
} else {
|
|
18
|
+
null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
22
|
+
val moduleList: Array<Class<out NativeModule?>> = arrayOf(JudoKitReactNativeModule::class.java)
|
|
23
|
+
val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
24
|
+
for (moduleClass in moduleList) {
|
|
25
|
+
val reactModule = moduleClass.getAnnotation(ReactModule::class.java) ?: continue
|
|
26
|
+
reactModuleInfoMap[reactModule.name] =
|
|
27
|
+
ReactModuleInfo(
|
|
28
|
+
reactModule.name,
|
|
29
|
+
moduleClass.name,
|
|
30
|
+
true,
|
|
31
|
+
reactModule.needsEagerInit,
|
|
32
|
+
reactModule.isCxxModule,
|
|
33
|
+
BuildConfig.IS_NEW_ARCHITECTURE_ENABLED,
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
return ReactModuleInfoProvider { reactModuleInfoMap }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
package com.judopay.judokit.reactnative
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.Promise
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.bridge.ReadableMap
|
|
8
|
+
|
|
9
|
+
class JudoKitReactNativeModule(
|
|
10
|
+
reactContext: ReactApplicationContext,
|
|
11
|
+
) : ReactContextBaseJavaModule(reactContext) {
|
|
12
|
+
private val moduleImpl = JudoKitReactNativeModuleImpl(reactContext)
|
|
13
|
+
|
|
14
|
+
override fun getName() = JudoKitReactNativeModuleImpl.NAME
|
|
15
|
+
|
|
16
|
+
@ReactMethod
|
|
17
|
+
fun invokeTransaction(
|
|
18
|
+
options: ReadableMap,
|
|
19
|
+
promise: Promise,
|
|
20
|
+
) {
|
|
21
|
+
moduleImpl.invokeTransaction(currentActivity, options, promise)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@ReactMethod
|
|
25
|
+
fun invokeGooglePay(
|
|
26
|
+
options: ReadableMap,
|
|
27
|
+
promise: Promise,
|
|
28
|
+
) {
|
|
29
|
+
moduleImpl.invokeGooglePay(currentActivity, options, promise)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@ReactMethod
|
|
33
|
+
fun invokePaymentMethodScreen(
|
|
34
|
+
options: ReadableMap,
|
|
35
|
+
promise: Promise,
|
|
36
|
+
) {
|
|
37
|
+
moduleImpl.invokePaymentMethodScreen(currentActivity, options, promise)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@ReactMethod
|
|
41
|
+
fun performTokenTransaction(
|
|
42
|
+
options: ReadableMap,
|
|
43
|
+
promise: Promise,
|
|
44
|
+
) {
|
|
45
|
+
moduleImpl.performTokenTransaction(currentActivity, options, promise)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@ReactMethod
|
|
49
|
+
fun fetchTransactionDetails(
|
|
50
|
+
options: ReadableMap,
|
|
51
|
+
promise: Promise,
|
|
52
|
+
) {
|
|
53
|
+
moduleImpl.fetchTransactionDetails(options, promise)
|
|
54
|
+
}
|
|
55
|
+
}
|
package/ios/JudoKitReactNative.h
CHANGED
|
@@ -25,13 +25,12 @@
|
|
|
25
25
|
static const NSErrorDomain _Nonnull RNJudoErrorDomain = @"com.judopay.react-native.error-domain";
|
|
26
26
|
|
|
27
27
|
#ifdef RCT_NEW_ARCH_ENABLED
|
|
28
|
-
#import
|
|
28
|
+
#import <JudoKitReactNativeSpec/JudoKitReactNativeSpec.h>
|
|
29
|
+
@interface JudoKitReactNative : NativeJudoKitReactNativeModuleSpecBase <NativeJudoKitReactNativeModuleSpec>
|
|
29
30
|
|
|
30
|
-
@interface JudoKitReactNative : NSObject <NativeJudoKitReactNativeSpec>
|
|
31
31
|
#else
|
|
32
32
|
#import <React/RCTBridgeModule.h>
|
|
33
|
-
|
|
34
33
|
@interface JudoKitReactNative : NSObject <RCTBridgeModule>
|
|
35
|
-
#endif
|
|
36
34
|
|
|
35
|
+
#endif
|
|
37
36
|
@end
|