@primer-io/react-native 2.6.0 → 2.8.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/android/build.gradle +1 -1
- package/android/src/main/java/com/primerioreactnative/PrimerRN.kt +1 -0
- package/android/src/main/java/com/primerioreactnative/PrimerRNEventListener.kt +24 -1
- package/android/src/main/java/com/primerioreactnative/PrimerRNHeadlessUniversalCheckoutListener.kt +24 -1
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerCheckoutAdditionalInfoRN.kt +13 -0
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerCheckoutDataRN.kt +4 -1
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerEvents.kt +1 -0
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerPaymentInstrumentTokenRN.kt +50 -4
- package/android/src/main/java/com/primerioreactnative/datamodels/PrimerSettingsRN.kt +63 -28
- package/android/src/main/java/com/primerioreactnative/extensions/LocaleSettingsRN.kt +12 -0
- package/android/src/main/java/com/primerioreactnative/extensions/PaymentInstrumentData.kt +24 -0
- package/android/src/main/java/com/primerioreactnative/extensions/PrimerCheckoutAdditionalInfo.kt +12 -0
- package/android/src/main/java/com/primerioreactnative/extensions/PrimerCheckoutData.kt +1 -1
- package/android/src/main/java/com/primerioreactnative/extensions/PrimerDebugOptionsRN.kt +7 -0
- package/android/src/main/java/com/primerioreactnative/extensions/PrimerPaymentMethodOptionsRN.kt +27 -0
- package/android/src/main/java/com/primerioreactnative/extensions/PrimerUIOptionsRN.kt +13 -0
- package/android/src/main/java/com/primerioreactnative/utils/PrimerHeadlessUniversalCheckoutImplementedRNCallbacks.kt +2 -0
- package/android/src/main/java/com/primerioreactnative/utils/PrimerImplementedRNCallbacks.kt +2 -0
- package/ios/DataModels/ImplementedRNCallbacks.swift +6 -3
- package/ios/Headless Universal Checkout/RNTPrimerHeadlessUniversalCheckout.swift +23 -1
- package/ios/RNTPrimer.swift +72 -49
- package/ios/ReactNative-Bridging-Header.h +10 -0
- package/lib/commonjs/Primer.js +14 -3
- package/lib/commonjs/Primer.js.map +1 -1
- package/lib/commonjs/RNPrimer.js +1 -1
- package/lib/commonjs/RNPrimer.js.map +1 -1
- package/lib/commonjs/headless_checkout/PrimerHeadlessUniversalCheckout.js +17 -6
- package/lib/commonjs/headless_checkout/PrimerHeadlessUniversalCheckout.js.map +1 -1
- package/lib/commonjs/headless_checkout/RNPrimerHeadlessUniversalCheckout.js +1 -1
- package/lib/commonjs/headless_checkout/RNPrimerHeadlessUniversalCheckout.js.map +1 -1
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/PrimerCheckoutAdditionalInfo.js +2 -0
- package/lib/commonjs/models/PrimerCheckoutAdditionalInfo.js.map +1 -0
- package/lib/commonjs/models/PrimerCheckoutData.js +3 -0
- package/lib/commonjs/models/PrimerCheckoutData.js.map +1 -1
- package/lib/module/Primer.js +14 -3
- package/lib/module/Primer.js.map +1 -1
- package/lib/module/RNPrimer.js +1 -1
- package/lib/module/RNPrimer.js.map +1 -1
- package/lib/module/headless_checkout/PrimerHeadlessUniversalCheckout.js +17 -6
- package/lib/module/headless_checkout/PrimerHeadlessUniversalCheckout.js.map +1 -1
- package/lib/module/headless_checkout/RNPrimerHeadlessUniversalCheckout.js +1 -1
- package/lib/module/headless_checkout/RNPrimerHeadlessUniversalCheckout.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/PrimerCheckoutAdditionalInfo.js +2 -0
- package/lib/module/models/PrimerCheckoutAdditionalInfo.js.map +1 -0
- package/lib/module/models/PrimerCheckoutData.js +2 -0
- package/lib/module/models/PrimerCheckoutData.js.map +1 -1
- package/lib/typescript/src/RNPrimer.d.ts +1 -1
- package/lib/typescript/src/headless_checkout/RNPrimerHeadlessUniversalCheckout.d.ts +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/models/PrimerCheckoutAdditionalInfo.d.ts +10 -0
- package/lib/typescript/src/models/PrimerCheckoutData.d.ts +3 -1
- package/lib/typescript/src/models/PrimerSettings.d.ts +2 -0
- package/package.json +1 -1
- package/primer-io-react-native.podspec +1 -1
- package/src/Primer.ts +16 -0
- package/src/RNPrimer.ts +2 -0
- package/src/headless_checkout/PrimerHeadlessUniversalCheckout.ts +16 -0
- package/src/headless_checkout/RNPrimerHeadlessUniversalCheckout.ts +2 -0
- package/src/index.tsx +5 -1
- package/src/models/PrimerCheckoutAdditionalInfo.ts +11 -0
- package/src/models/PrimerCheckoutData.ts +5 -2
- package/src/models/PrimerSettings.ts +8 -6
- package/ios/Core/ReactNative-Bridging-Header.h +0 -14
package/android/build.gradle
CHANGED
|
@@ -137,5 +137,5 @@ dependencies {
|
|
|
137
137
|
api 'com.facebook.react:react-native:+'
|
|
138
138
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
139
139
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.3"
|
|
140
|
-
implementation 'io.primer:android:2.
|
|
140
|
+
implementation 'io.primer:android:2.8.0'
|
|
141
141
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.primerioreactnative
|
|
2
2
|
|
|
3
3
|
import com.primerioreactnative.datamodels.*
|
|
4
|
+
import com.primerioreactnative.extensions.*
|
|
4
5
|
import com.primerioreactnative.extensions.toPrimerCheckoutDataRN
|
|
5
6
|
import com.primerioreactnative.extensions.toPrimerClientSessionRN
|
|
6
7
|
import com.primerioreactnative.extensions.toPrimerPaymentMethodDataRN
|
|
@@ -13,6 +14,8 @@ import io.primer.android.completion.PrimerResumeDecisionHandler
|
|
|
13
14
|
import io.primer.android.domain.PrimerCheckoutData
|
|
14
15
|
import io.primer.android.domain.action.models.PrimerClientSession
|
|
15
16
|
import io.primer.android.domain.error.models.PrimerError
|
|
17
|
+
import io.primer.android.domain.payments.additionalInfo.MultibancoCheckoutAdditionalInfo
|
|
18
|
+
import io.primer.android.domain.payments.additionalInfo.PrimerCheckoutAdditionalInfo
|
|
16
19
|
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodData
|
|
17
20
|
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodTokenData
|
|
18
21
|
import kotlinx.serialization.encodeToString
|
|
@@ -38,7 +41,11 @@ class PrimerRNEventListener : PrimerCheckoutListener {
|
|
|
38
41
|
if (implementedRNCallbacks?.isOnCheckoutCompleteImplemented == true) {
|
|
39
42
|
sendEvent?.invoke(
|
|
40
43
|
PrimerEvents.ON_CHECKOUT_COMPLETE.eventName,
|
|
41
|
-
JSONObject(Json.encodeToString(checkoutData.toPrimerCheckoutDataRN()))
|
|
44
|
+
JSONObject(Json.encodeToString(checkoutData.toPrimerCheckoutDataRN())).apply {
|
|
45
|
+
val additionalInfoJson = optJSONObject(Keys.ADDITIONAL_INFO)
|
|
46
|
+
additionalInfoJson?.remove("type")
|
|
47
|
+
putOpt(Keys.ADDITIONAL_INFO, additionalInfoJson)
|
|
48
|
+
}
|
|
42
49
|
)
|
|
43
50
|
} else {
|
|
44
51
|
sendError?.invoke(
|
|
@@ -139,6 +146,22 @@ class PrimerRNEventListener : PrimerCheckoutListener {
|
|
|
139
146
|
}
|
|
140
147
|
}
|
|
141
148
|
|
|
149
|
+
override fun onResumePending(additionalInfo: PrimerCheckoutAdditionalInfo?) {
|
|
150
|
+
if (implementedRNCallbacks?.isOnResumePendingImplemented == true) {
|
|
151
|
+
if (additionalInfo is MultibancoCheckoutAdditionalInfo) {
|
|
152
|
+
sendEvent?.invoke(
|
|
153
|
+
PrimerEvents.ON_RESUME_PENDING.eventName,
|
|
154
|
+
JSONObject(Json.encodeToString(additionalInfo.toCheckoutAdditionalInfoRN()))
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
sendError?.invoke(
|
|
159
|
+
ErrorTypeRN.NativeBridgeFailed
|
|
160
|
+
errorTo "Callback [onResumePending] should be implemented."
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
142
165
|
override fun onDismissed() {
|
|
143
166
|
if (implementedRNCallbacks?.isOnDismissImplemented == true) {
|
|
144
167
|
sendEvent?.invoke(
|
package/android/src/main/java/com/primerioreactnative/PrimerRNHeadlessUniversalCheckoutListener.kt
CHANGED
|
@@ -4,6 +4,7 @@ import com.facebook.react.bridge.Arguments
|
|
|
4
4
|
import com.facebook.react.bridge.Callback
|
|
5
5
|
import com.facebook.react.bridge.Promise
|
|
6
6
|
import com.primerioreactnative.datamodels.*
|
|
7
|
+
import com.primerioreactnative.extensions.*
|
|
7
8
|
import com.primerioreactnative.extensions.toPrimerCheckoutDataRN
|
|
8
9
|
import com.primerioreactnative.extensions.toPrimerClientSessionRN
|
|
9
10
|
import com.primerioreactnative.extensions.toPrimerPaymentMethodDataRN
|
|
@@ -18,6 +19,8 @@ import io.primer.android.components.domain.core.models.PrimerHeadlessUniversalCh
|
|
|
18
19
|
import io.primer.android.domain.PrimerCheckoutData
|
|
19
20
|
import io.primer.android.domain.action.models.PrimerClientSession
|
|
20
21
|
import io.primer.android.domain.error.models.PrimerError
|
|
22
|
+
import io.primer.android.domain.payments.additionalInfo.MultibancoCheckoutAdditionalInfo
|
|
23
|
+
import io.primer.android.domain.payments.additionalInfo.PrimerCheckoutAdditionalInfo
|
|
21
24
|
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodData
|
|
22
25
|
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodTokenData
|
|
23
26
|
import kotlinx.serialization.encodeToString
|
|
@@ -79,7 +82,11 @@ class PrimerRNHeadlessUniversalCheckoutListener : PrimerHeadlessUniversalCheckou
|
|
|
79
82
|
if (implementedRNCallbacks?.isOnCheckoutCompleteImplemented == true) {
|
|
80
83
|
sendEvent?.invoke(
|
|
81
84
|
PrimerHeadlessUniversalCheckoutEvent.ON_CHECKOUT_COMPLETE.eventName,
|
|
82
|
-
JSONObject(Json.encodeToString(checkoutData.toPrimerCheckoutDataRN()))
|
|
85
|
+
JSONObject(Json.encodeToString(checkoutData.toPrimerCheckoutDataRN())).apply {
|
|
86
|
+
val additionalInfoJson = optJSONObject(Keys.ADDITIONAL_INFO)
|
|
87
|
+
additionalInfoJson?.remove("type")
|
|
88
|
+
putOpt(Keys.ADDITIONAL_INFO, additionalInfoJson)
|
|
89
|
+
}
|
|
83
90
|
)
|
|
84
91
|
} else {
|
|
85
92
|
sendError?.invoke(
|
|
@@ -180,6 +187,22 @@ class PrimerRNHeadlessUniversalCheckoutListener : PrimerHeadlessUniversalCheckou
|
|
|
180
187
|
}
|
|
181
188
|
}
|
|
182
189
|
|
|
190
|
+
override fun onResumePending(additionalInfo: PrimerCheckoutAdditionalInfo?) {
|
|
191
|
+
if (implementedRNCallbacks?.isOnResumePendingImplemented == true) {
|
|
192
|
+
if (additionalInfo is MultibancoCheckoutAdditionalInfo) {
|
|
193
|
+
sendEvent?.invoke(
|
|
194
|
+
PrimerEvents.ON_RESUME_PENDING.eventName,
|
|
195
|
+
JSONObject(Json.encodeToString(additionalInfo.toCheckoutAdditionalInfoRN()))
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
} else {
|
|
199
|
+
sendError?.invoke(
|
|
200
|
+
ErrorTypeRN.NativeBridgeFailed
|
|
201
|
+
errorTo "Callback [onResumePending] should be implemented."
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
183
206
|
override fun onFailed(
|
|
184
207
|
error: PrimerError,
|
|
185
208
|
checkoutData: PrimerCheckoutData?,
|
package/android/src/main/java/com/primerioreactnative/datamodels/PrimerCheckoutAdditionalInfoRN.kt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.primerioreactnative.datamodels
|
|
2
|
+
|
|
3
|
+
import kotlinx.serialization.Serializable
|
|
4
|
+
|
|
5
|
+
@Serializable
|
|
6
|
+
sealed class PrimerCheckoutAdditionalInfoRN
|
|
7
|
+
|
|
8
|
+
@Serializable
|
|
9
|
+
data class MultibancoCheckoutAdditionalInfoRN(
|
|
10
|
+
val expiresAt: String,
|
|
11
|
+
val reference: String,
|
|
12
|
+
val entity: String,
|
|
13
|
+
) : PrimerCheckoutAdditionalInfoRN()
|
|
@@ -3,7 +3,10 @@ package com.primerioreactnative.datamodels
|
|
|
3
3
|
import kotlinx.serialization.Serializable
|
|
4
4
|
|
|
5
5
|
@Serializable
|
|
6
|
-
data class PrimerCheckoutDataRN(
|
|
6
|
+
data class PrimerCheckoutDataRN(
|
|
7
|
+
val payment: PrimerPaymentRN,
|
|
8
|
+
val additionalInfo: PrimerCheckoutAdditionalInfoRN? = null
|
|
9
|
+
)
|
|
7
10
|
|
|
8
11
|
@Serializable
|
|
9
12
|
data class PrimerPaymentRN(
|
package/android/src/main/java/com/primerioreactnative/datamodels/PrimerPaymentInstrumentTokenRN.kt
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package com.primerioreactnative.datamodels
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import io.primer.android.data.tokenization.models
|
|
3
|
+
import com.primerioreactnative.extensions.toPaymentInstrumentDataRN
|
|
4
|
+
import io.primer.android.data.tokenization.models.*
|
|
5
5
|
import io.primer.android.domain.tokenization.models.PrimerPaymentMethodTokenData
|
|
6
6
|
import kotlinx.serialization.Serializable
|
|
7
7
|
|
|
@@ -22,7 +22,7 @@ data class PrimerPaymentInstrumentTokenRN(
|
|
|
22
22
|
)
|
|
23
23
|
|
|
24
24
|
@Serializable
|
|
25
|
-
data class ThreeDSAuthenticationData
|
|
25
|
+
data class ThreeDSAuthenticationData(
|
|
26
26
|
val responseCode: String?,
|
|
27
27
|
val reasonCode: String?,
|
|
28
28
|
val reasonText: String?,
|
|
@@ -30,6 +30,52 @@ data class PrimerPaymentInstrumentTokenRN(
|
|
|
30
30
|
val challengeIssued: Boolean?,
|
|
31
31
|
)
|
|
32
32
|
|
|
33
|
+
@Serializable
|
|
34
|
+
data class PaymentInstrumentData(
|
|
35
|
+
val network: String? = null,
|
|
36
|
+
val cardholderName: String? = null,
|
|
37
|
+
val first6Digits: Int? = null,
|
|
38
|
+
val last4Digits: Int? = null,
|
|
39
|
+
val expirationMonth: Int? = null,
|
|
40
|
+
val expirationYear: Int? = null,
|
|
41
|
+
val gocardlessMandateId: String? = null,
|
|
42
|
+
val externalPayerInfo: ExternalPayerInfo? = null,
|
|
43
|
+
val klarnaCustomerToken: String? = null,
|
|
44
|
+
val sessionData: SessionData? = null,
|
|
45
|
+
// apaya
|
|
46
|
+
val mx: String? = null,
|
|
47
|
+
val mnc: Int? = null,
|
|
48
|
+
val mcc: Int? = null,
|
|
49
|
+
val hashedIdentifier: String? = null,
|
|
50
|
+
val currencyCode: String? = null,
|
|
51
|
+
val productId: String? = null,
|
|
52
|
+
// async
|
|
53
|
+
val paymentMethodType: String? = null,
|
|
54
|
+
// bin
|
|
55
|
+
val binData: BinData? = null,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
@Serializable
|
|
59
|
+
data class ExternalPayerInfo(
|
|
60
|
+
val email: String,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
@Serializable
|
|
64
|
+
data class BinData(
|
|
65
|
+
val network: String? = null,
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
@Serializable
|
|
69
|
+
data class SessionData(
|
|
70
|
+
val recurringDescription: String? = null,
|
|
71
|
+
val billingAddress: BillingAddress? = null,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
@Serializable
|
|
75
|
+
data class BillingAddress(
|
|
76
|
+
val email: String,
|
|
77
|
+
)
|
|
78
|
+
|
|
33
79
|
companion object {
|
|
34
80
|
fun fromPaymentMethodToken(token: PrimerPaymentMethodTokenData): PrimerPaymentInstrumentTokenRN {
|
|
35
81
|
return PrimerPaymentInstrumentTokenRN(
|
|
@@ -37,7 +83,7 @@ data class PrimerPaymentInstrumentTokenRN(
|
|
|
37
83
|
token.analyticsId,
|
|
38
84
|
token.tokenType,
|
|
39
85
|
token.paymentInstrumentType,
|
|
40
|
-
token.paymentInstrumentData,
|
|
86
|
+
token.paymentInstrumentData?.toPaymentInstrumentDataRN(),
|
|
41
87
|
)
|
|
42
88
|
}
|
|
43
89
|
}
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
package com.primerioreactnative.datamodels
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import
|
|
3
|
+
import com.primerioreactnative.extensions.toLocale
|
|
4
|
+
import com.primerioreactnative.extensions.toPrimerDebugOptions
|
|
5
|
+
import com.primerioreactnative.extensions.toPrimerPaymentMethodOptions
|
|
6
|
+
import com.primerioreactnative.extensions.toPrimerUIOptions
|
|
7
|
+
import io.primer.android.data.settings.GooglePayButtonStyle
|
|
8
|
+
import io.primer.android.data.settings.PrimerPaymentHandling
|
|
9
|
+
import io.primer.android.data.settings.PrimerSettings
|
|
5
10
|
import kotlinx.serialization.SerialName
|
|
6
11
|
import kotlinx.serialization.Serializable
|
|
7
|
-
import java.util.*
|
|
8
12
|
|
|
9
13
|
@Serializable
|
|
10
14
|
data class PrimerSettingsRN(
|
|
11
15
|
var paymentHandling: PrimerPaymentHandling = PrimerPaymentHandling.AUTO,
|
|
12
16
|
var localeData: LocaleSettingsRN = LocaleSettingsRN(),
|
|
13
17
|
var paymentMethodOptions: PrimerPaymentMethodOptionsRN = PrimerPaymentMethodOptionsRN(),
|
|
14
|
-
var uiOptions:
|
|
15
|
-
var debugOptions:
|
|
18
|
+
var uiOptions: PrimerUIOptionsRN = PrimerUIOptionsRN(),
|
|
19
|
+
var debugOptions: PrimerDebugOptionsRN = PrimerDebugOptionsRN(),
|
|
16
20
|
)
|
|
17
21
|
|
|
18
22
|
@Serializable
|
|
@@ -21,43 +25,74 @@ data class LocaleSettingsRN(
|
|
|
21
25
|
val localeCode: String? = null
|
|
22
26
|
)
|
|
23
27
|
|
|
24
|
-
fun LocaleSettingsRN.toLocale(): Locale {
|
|
25
|
-
return when {
|
|
26
|
-
languageCode == null -> Locale.getDefault()
|
|
27
|
-
localeCode == null -> Locale(languageCode)
|
|
28
|
-
else -> Locale(languageCode, localeCode)
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
28
|
@Serializable
|
|
33
29
|
data class PrimerPaymentMethodOptionsRN(
|
|
34
30
|
@SerialName("android")
|
|
35
31
|
val androidSettingsRN: AndroidSettingsRN = AndroidSettingsRN(),
|
|
36
|
-
var cardPaymentOptions:
|
|
37
|
-
var googlePayOptions:
|
|
38
|
-
var klarnaOptions:
|
|
39
|
-
var apayaOptions:
|
|
40
|
-
var goCardlessOptions:
|
|
32
|
+
var cardPaymentOptions: PrimerCardPaymentOptionsRN = PrimerCardPaymentOptionsRN(),
|
|
33
|
+
var googlePayOptions: PrimerGooglePayOptionsRN = PrimerGooglePayOptionsRN(),
|
|
34
|
+
var klarnaOptions: PrimerKlarnaOptionsRN = PrimerKlarnaOptionsRN(),
|
|
35
|
+
var apayaOptions: PrimerApayaOptionsRN = PrimerApayaOptionsRN(),
|
|
36
|
+
var goCardlessOptions: PrimerGoCardlessOptionsRN = PrimerGoCardlessOptionsRN()
|
|
41
37
|
)
|
|
42
38
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
39
|
+
@Serializable
|
|
40
|
+
data class AndroidSettingsRN(val redirectScheme: String? = null)
|
|
41
|
+
|
|
42
|
+
@Serializable
|
|
43
|
+
data class PrimerUIOptionsRN(
|
|
44
|
+
var isInitScreenEnabled: Boolean = true,
|
|
45
|
+
var isSuccessScreenEnabled: Boolean = true,
|
|
46
|
+
var isErrorScreenEnabled: Boolean = true,
|
|
50
47
|
)
|
|
51
48
|
|
|
52
49
|
@Serializable
|
|
53
|
-
data class
|
|
50
|
+
data class PrimerDebugOptionsRN(val is3DSSanityCheckEnabled: Boolean = true)
|
|
51
|
+
|
|
52
|
+
@Serializable
|
|
53
|
+
data class PrimerCardPaymentOptionsRN(
|
|
54
|
+
var is3DSOnVaultingEnabled: Boolean = true
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
@Serializable
|
|
58
|
+
data class PrimerGooglePayOptionsRN(
|
|
59
|
+
var merchantName: String? = null,
|
|
60
|
+
var allowedCardNetworks: List<String> = listOf(
|
|
61
|
+
"AMEX",
|
|
62
|
+
"DISCOVER",
|
|
63
|
+
"JCB",
|
|
64
|
+
"MASTERCARD",
|
|
65
|
+
"VISA"
|
|
66
|
+
),
|
|
67
|
+
var buttonStyle: GooglePayButtonStyle = GooglePayButtonStyle.BLACK,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
@Serializable
|
|
71
|
+
data class PrimerKlarnaOptionsRN(
|
|
72
|
+
var recurringPaymentDescription: String? = null,
|
|
73
|
+
@Deprecated("This property is deprecated and will be removed in future release.")
|
|
74
|
+
var webViewTitle: String? = null,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
@Serializable
|
|
78
|
+
@Deprecated("This class is deprecated and will be removed in future release.")
|
|
79
|
+
data class PrimerApayaOptionsRN(
|
|
80
|
+
var webViewTitle: String? = null,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
@Serializable
|
|
84
|
+
@Deprecated("This class is deprecated and will be removed in future release.")
|
|
85
|
+
data class PrimerGoCardlessOptionsRN(
|
|
86
|
+
var businessName: String? = null,
|
|
87
|
+
var businessAddress: String? = null,
|
|
88
|
+
)
|
|
54
89
|
|
|
55
90
|
fun PrimerSettingsRN.toPrimerSettings() = PrimerSettings(
|
|
56
91
|
paymentHandling,
|
|
57
92
|
localeData.toLocale(),
|
|
58
93
|
paymentMethodOptions.toPrimerPaymentMethodOptions(),
|
|
59
|
-
uiOptions,
|
|
60
|
-
debugOptions
|
|
94
|
+
uiOptions.toPrimerUIOptions(),
|
|
95
|
+
debugOptions.toPrimerDebugOptions()
|
|
61
96
|
)
|
|
62
97
|
|
|
63
98
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.primerioreactnative.extensions
|
|
2
|
+
|
|
3
|
+
import com.primerioreactnative.datamodels.LocaleSettingsRN
|
|
4
|
+
import java.util.Locale
|
|
5
|
+
|
|
6
|
+
internal fun LocaleSettingsRN.toLocale(): Locale {
|
|
7
|
+
return when {
|
|
8
|
+
languageCode == null -> Locale.getDefault()
|
|
9
|
+
localeCode == null -> Locale(languageCode)
|
|
10
|
+
else -> Locale(languageCode, localeCode)
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package com.primerioreactnative.extensions
|
|
2
|
+
|
|
3
|
+
import com.primerioreactnative.datamodels.PrimerPaymentInstrumentTokenRN
|
|
4
|
+
import io.primer.android.data.tokenization.models.PaymentInstrumentData
|
|
5
|
+
|
|
6
|
+
internal fun PaymentInstrumentData.toPaymentInstrumentDataRN() =
|
|
7
|
+
PrimerPaymentInstrumentTokenRN.PaymentInstrumentData(
|
|
8
|
+
network,
|
|
9
|
+
cardholderName,
|
|
10
|
+
first6Digits,
|
|
11
|
+
last4Digits,
|
|
12
|
+
expirationMonth,
|
|
13
|
+
expirationYear,
|
|
14
|
+
gocardlessMandateId,
|
|
15
|
+
externalPayerInfo?.email?.let { PrimerPaymentInstrumentTokenRN.ExternalPayerInfo(it) },
|
|
16
|
+
klarnaCustomerToken,
|
|
17
|
+
sessionData?.let {
|
|
18
|
+
PrimerPaymentInstrumentTokenRN.SessionData(
|
|
19
|
+
it.recurringDescription,
|
|
20
|
+
it.billingAddress?.let { PrimerPaymentInstrumentTokenRN.BillingAddress(it.email) })
|
|
21
|
+
},
|
|
22
|
+
mx, mnc, mcc, hashedIdentifier, currencyCode, productId, paymentMethodType,
|
|
23
|
+
binData?.let { PrimerPaymentInstrumentTokenRN.BinData(it.network) }
|
|
24
|
+
)
|
package/android/src/main/java/com/primerioreactnative/extensions/PrimerCheckoutAdditionalInfo.kt
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
package com.primerioreactnative.extensions
|
|
2
|
+
|
|
3
|
+
import com.primerioreactnative.datamodels.MultibancoCheckoutAdditionalInfoRN
|
|
4
|
+
import io.primer.android.domain.payments.additionalInfo.MultibancoCheckoutAdditionalInfo
|
|
5
|
+
import io.primer.android.domain.payments.additionalInfo.PrimerCheckoutAdditionalInfo
|
|
6
|
+
|
|
7
|
+
internal fun PrimerCheckoutAdditionalInfo.toCheckoutAdditionalInfoRN() = when (this) {
|
|
8
|
+
is MultibancoCheckoutAdditionalInfo ->
|
|
9
|
+
MultibancoCheckoutAdditionalInfoRN(expiresAt, reference, entity)
|
|
10
|
+
else -> null
|
|
11
|
+
}
|
|
12
|
+
|
|
@@ -4,4 +4,4 @@ import com.primerioreactnative.datamodels.PrimerCheckoutDataRN
|
|
|
4
4
|
import io.primer.android.domain.PrimerCheckoutData
|
|
5
5
|
|
|
6
6
|
internal fun PrimerCheckoutData.toPrimerCheckoutDataRN() =
|
|
7
|
-
PrimerCheckoutDataRN(payment.toPrimerPaymentRN())
|
|
7
|
+
PrimerCheckoutDataRN(payment.toPrimerPaymentRN(), additionalInfo?.toCheckoutAdditionalInfoRN())
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
package com.primerioreactnative.extensions
|
|
2
|
+
|
|
3
|
+
import com.primerioreactnative.datamodels.PrimerDebugOptionsRN
|
|
4
|
+
import io.primer.android.data.settings.PrimerDebugOptions
|
|
5
|
+
|
|
6
|
+
internal fun PrimerDebugOptionsRN.toPrimerDebugOptions() =
|
|
7
|
+
PrimerDebugOptions(is3DSSanityCheckEnabled)
|
package/android/src/main/java/com/primerioreactnative/extensions/PrimerPaymentMethodOptionsRN.kt
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.primerioreactnative.extensions
|
|
2
|
+
|
|
3
|
+
import com.primerioreactnative.datamodels.*
|
|
4
|
+
import io.primer.android.data.settings.*
|
|
5
|
+
|
|
6
|
+
fun PrimerPaymentMethodOptionsRN.toPrimerPaymentMethodOptions() = PrimerPaymentMethodOptions(
|
|
7
|
+
androidSettingsRN.redirectScheme,
|
|
8
|
+
cardPaymentOptions.toPrimerCardPaymentOptions(),
|
|
9
|
+
googlePayOptions.toPrimerGooglePayOptions(),
|
|
10
|
+
klarnaOptions.toPrimerKlarnaOptions(),
|
|
11
|
+
apayaOptions.toPrimerApayaOptions(),
|
|
12
|
+
goCardlessOptions.toPrimerGoCardlessOptions()
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
fun PrimerCardPaymentOptionsRN.toPrimerCardPaymentOptions() =
|
|
16
|
+
PrimerCardPaymentOptions(is3DSOnVaultingEnabled)
|
|
17
|
+
|
|
18
|
+
fun PrimerGooglePayOptionsRN.toPrimerGooglePayOptions() =
|
|
19
|
+
PrimerGooglePayOptions(merchantName, allowedCardNetworks, buttonStyle)
|
|
20
|
+
|
|
21
|
+
fun PrimerKlarnaOptionsRN.toPrimerKlarnaOptions() =
|
|
22
|
+
PrimerKlarnaOptions(recurringPaymentDescription, webViewTitle)
|
|
23
|
+
|
|
24
|
+
fun PrimerApayaOptionsRN.toPrimerApayaOptions() = PrimerApayaOptions(webViewTitle)
|
|
25
|
+
|
|
26
|
+
fun PrimerGoCardlessOptionsRN.toPrimerGoCardlessOptions() =
|
|
27
|
+
PrimerGoCardlessOptions(businessName, businessAddress)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package com.primerioreactnative.extensions
|
|
2
|
+
|
|
3
|
+
import com.primerioreactnative.datamodels.PrimerUIOptionsRN
|
|
4
|
+
import io.primer.android.ui.settings.PrimerTheme
|
|
5
|
+
import io.primer.android.ui.settings.PrimerUIOptions
|
|
6
|
+
|
|
7
|
+
internal fun PrimerUIOptionsRN.toPrimerUIOptions() =
|
|
8
|
+
PrimerUIOptions(
|
|
9
|
+
isInitScreenEnabled,
|
|
10
|
+
isSuccessScreenEnabled,
|
|
11
|
+
isErrorScreenEnabled,
|
|
12
|
+
PrimerTheme.build()
|
|
13
|
+
)
|
|
@@ -19,6 +19,8 @@ data class PrimerHeadlessUniversalCheckoutImplementedRNCallbacks(
|
|
|
19
19
|
val isOnTokenizeSuccessImplemented: Boolean? = null,
|
|
20
20
|
@SerialName("onResumeSuccess")
|
|
21
21
|
val isOnResumeSuccessImplemented: Boolean? = null,
|
|
22
|
+
@SerialName("onResumePending")
|
|
23
|
+
val isOnResumePendingImplemented: Boolean? = null,
|
|
22
24
|
@SerialName("onHUCTokenizeStart")
|
|
23
25
|
val isOnHUCTokenizeStartsImplemented: Boolean? = null,
|
|
24
26
|
@SerialName("onHUCPrepareStart")
|
|
@@ -21,4 +21,6 @@ data class PrimerImplementedRNCallbacks(
|
|
|
21
21
|
val isOnTokenizeSuccessImplemented: Boolean? = null,
|
|
22
22
|
@SerialName("onResumeSuccess")
|
|
23
23
|
val isOnResumeSuccessImplemented: Boolean? = null,
|
|
24
|
+
@SerialName("onResumePending")
|
|
25
|
+
val isOnResumePendingImplemented: Boolean? = null,
|
|
24
26
|
)
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import Foundation
|
|
9
9
|
|
|
10
10
|
internal struct ImplementedRNCallbacks: Decodable {
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
internal var isOnCheckoutCompleteImplemented: Bool = false
|
|
13
13
|
internal var isOnBeforeClientSessionUpdateImplemented: Bool = false
|
|
14
14
|
internal var isOnClientSessionUpdateImplemented: Bool = false
|
|
@@ -17,11 +17,12 @@ internal struct ImplementedRNCallbacks: Decodable {
|
|
|
17
17
|
internal var isOnDismissImplemented: Bool = false
|
|
18
18
|
internal var isOnTokenizeSuccessImplemented: Bool = false
|
|
19
19
|
internal var isOnResumeSuccessImplemented: Bool = false
|
|
20
|
+
internal var isOnResumePendingImplemented: Bool = false
|
|
20
21
|
internal var isOnHUCTokenizeStartImplemented: Bool = false
|
|
21
22
|
internal var isOnHUCPrepareStartImplemented: Bool = false
|
|
22
23
|
internal var isOnHUCAvailablePaymentMethodsLoadedImplemented: Bool = false
|
|
23
24
|
internal var isOnHUCPaymentMethodShowImplemented: Bool = false
|
|
24
|
-
|
|
25
|
+
|
|
25
26
|
enum CodingKeys: String, CodingKey {
|
|
26
27
|
case isOnCheckoutCompleteImplemented = "onCheckoutComplete"
|
|
27
28
|
case isOnBeforeClientSessionUpdateImplemented = "onBeforeClientSessionUpdate"
|
|
@@ -31,12 +32,13 @@ internal struct ImplementedRNCallbacks: Decodable {
|
|
|
31
32
|
case isOnDismissImplemented = "onDismiss"
|
|
32
33
|
case isOnTokenizeSuccessImplemented = "onTokenizeSuccess"
|
|
33
34
|
case isOnResumeSuccessImplemented = "onResumeSuccess"
|
|
35
|
+
case isOnResumePendingImplemented = "onResumePending"
|
|
34
36
|
case isOnHUCTokenizeStartImplemented = "onHUCTokenizeStart"
|
|
35
37
|
case isOnHUCPrepareStartImplemented = "onHUCPrepareStart"
|
|
36
38
|
case isOnHUCAvailablePaymentMethodsLoadedImplemented = "onHUCAvailablePaymentMethodsLoaded"
|
|
37
39
|
case isOnHUCPaymentMethodShowImplemented = "onHUCPaymentMethodShow"
|
|
38
40
|
}
|
|
39
|
-
|
|
41
|
+
|
|
40
42
|
init(from decoder: Decoder) throws {
|
|
41
43
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
42
44
|
|
|
@@ -48,6 +50,7 @@ internal struct ImplementedRNCallbacks: Decodable {
|
|
|
48
50
|
self.isOnDismissImplemented = (try? container.decode(Bool?.self, forKey: .isOnDismissImplemented)) ?? false
|
|
49
51
|
self.isOnTokenizeSuccessImplemented = (try? container.decode(Bool?.self, forKey: .isOnTokenizeSuccessImplemented)) ?? false
|
|
50
52
|
self.isOnResumeSuccessImplemented = (try? container.decode(Bool?.self, forKey: .isOnResumeSuccessImplemented)) ?? false
|
|
53
|
+
self.isOnResumePendingImplemented = (try? container.decode(Bool?.self, forKey: .isOnResumePendingImplemented)) ?? false
|
|
51
54
|
self.isOnHUCTokenizeStartImplemented = (try? container.decode(Bool?.self, forKey: .isOnHUCTokenizeStartImplemented)) ?? false
|
|
52
55
|
self.isOnHUCPrepareStartImplemented = (try? container.decode(Bool?.self, forKey: .isOnHUCPrepareStartImplemented)) ?? false
|
|
53
56
|
self.isOnHUCAvailablePaymentMethodsLoadedImplemented = (try? container.decode(Bool?.self, forKey: .isOnHUCAvailablePaymentMethodsLoadedImplemented)) ?? false
|
|
@@ -17,6 +17,7 @@ enum PrimerHeadlessUniversalCheckoutEvents: Int, CaseIterable {
|
|
|
17
17
|
case onHUCPaymentMethodShow
|
|
18
18
|
case onTokenizeSuccess
|
|
19
19
|
case onResumeSuccess
|
|
20
|
+
case onResumePending
|
|
20
21
|
case onBeforePaymentCreate
|
|
21
22
|
case onBeforeClientSessionUpdate
|
|
22
23
|
case onClientSessionUpdate
|
|
@@ -35,6 +36,8 @@ enum PrimerHeadlessUniversalCheckoutEvents: Int, CaseIterable {
|
|
|
35
36
|
return "onTokenizeSuccess"
|
|
36
37
|
case .onResumeSuccess:
|
|
37
38
|
return "onResumeSuccess"
|
|
39
|
+
case .onResumePending:
|
|
40
|
+
return "onResumePending"
|
|
38
41
|
case .onBeforePaymentCreate:
|
|
39
42
|
return "onBeforePaymentCreate"
|
|
40
43
|
case .onBeforeClientSessionUpdate:
|
|
@@ -398,6 +401,25 @@ extension RNTPrimerHeadlessUniversalCheckout: PrimerHeadlessUniversalCheckoutDel
|
|
|
398
401
|
}
|
|
399
402
|
}
|
|
400
403
|
}
|
|
404
|
+
|
|
405
|
+
func primerHeadlessUniversalCheckoutDidEnterResumePendingWithPaymentAdditionalInfo(_ additionalInfo: PrimerCheckoutAdditionalInfo?) {
|
|
406
|
+
DispatchQueue.main.async {
|
|
407
|
+
if self.implementedRNCallbacks?.isOnResumePendingImplemented == true {
|
|
408
|
+
do {
|
|
409
|
+
let checkoutAdditionalInfo = try JSONEncoder().encode(additionalInfo)
|
|
410
|
+
let checkoutAdditionalInfoJson = try JSONSerialization.jsonObject(with: checkoutAdditionalInfo, options: .allowFragments)
|
|
411
|
+
self.sendEvent(withName: PrimerHeadlessUniversalCheckoutEvents.onResumePending.stringValue, body: checkoutAdditionalInfoJson)
|
|
412
|
+
} catch {
|
|
413
|
+
let checkoutData = PrimerCheckoutData(payment: nil, additionalInfo: additionalInfo)
|
|
414
|
+
self.handleRNBridgeError(error, checkoutData: checkoutData, stopOnDebug: true)
|
|
415
|
+
}
|
|
416
|
+
} else {
|
|
417
|
+
let err = NSError(domain: "native-bridge", code: 1, userInfo: [NSLocalizedDescriptionKey: "Callback [onResumePending] should be implemented."])
|
|
418
|
+
let checkoutData = PrimerCheckoutData(payment: nil, additionalInfo: additionalInfo)
|
|
419
|
+
self.handleRNBridgeError(err, checkoutData: checkoutData, stopOnDebug: false)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
401
423
|
|
|
402
424
|
func primerHeadlessUniversalCheckoutClientSessionWillUpdate() {
|
|
403
425
|
if self.implementedRNCallbacks?.isOnBeforeClientSessionUpdateImplemented == true {
|
|
@@ -405,7 +427,7 @@ extension RNTPrimerHeadlessUniversalCheckout: PrimerHeadlessUniversalCheckoutDel
|
|
|
405
427
|
self.sendEvent(withName: PrimerHeadlessUniversalCheckoutEvents.onBeforeClientSessionUpdate.stringValue, body: nil)
|
|
406
428
|
}
|
|
407
429
|
} else {
|
|
408
|
-
//
|
|
430
|
+
// React Native app hasn't implemented this callback, ignore.
|
|
409
431
|
}
|
|
410
432
|
}
|
|
411
433
|
|