react-native-payengine 2.0.8 → 2.0.9
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/README.md +4 -3
- package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEGooglePayButton.kt +1 -7
- package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEPaymentRequest.kt +12 -0
- package/ios/Sources/Classes/ApplePay/RNPEApplePayButton.swift +1 -0
- package/ios/Sources/Classes/ApplePay/RNPEApplePayPaymentRequest.swift +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -181,11 +181,12 @@ const ApplePayScreen = () => {
|
|
|
181
181
|
|
|
182
182
|
const paymentRequest: PEPaymentRequest = {
|
|
183
183
|
merchantId: MERCHANT_ID,
|
|
184
|
-
paymentAmount: 10.
|
|
184
|
+
paymentAmount: 10.15,
|
|
185
|
+
currencyCode: 'USD',
|
|
185
186
|
paymentItems: [
|
|
186
187
|
{
|
|
187
|
-
amount:
|
|
188
|
-
label: '
|
|
188
|
+
amount: 10.15,
|
|
189
|
+
label: 'Total Amount',
|
|
189
190
|
},
|
|
190
191
|
],
|
|
191
192
|
platformOptions: {
|
package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEGooglePayButton.kt
CHANGED
|
@@ -42,13 +42,7 @@ class RNPEGooglePayButton(private val context: ThemedReactContext, private val a
|
|
|
42
42
|
fun setPaymentRequest(text: String) {
|
|
43
43
|
Log.d("TEST", "Received pm request $text")
|
|
44
44
|
val rnPaymentRequest = Gson().fromJson(text, RNPEPaymentRequest::class.java)
|
|
45
|
-
val paymentRequest =
|
|
46
|
-
paymentAmount = rnPaymentRequest.paymentAmount,
|
|
47
|
-
billingAddressRequired = rnPaymentRequest.billingAddressRequired,
|
|
48
|
-
billingAddressParameters = rnPaymentRequest.billingAddressParameters,
|
|
49
|
-
shippingAddressRequired = rnPaymentRequest.shippingAddressRequired,
|
|
50
|
-
shippingAddressParameters = rnPaymentRequest.shippingAddressParameters
|
|
51
|
-
)
|
|
45
|
+
val paymentRequest = rnPaymentRequest.toSDKRequest()
|
|
52
46
|
Log.d("TEST", "Decoded ${Gson().toJson(paymentRequest)}")
|
|
53
47
|
this.paymentRequest = paymentRequest
|
|
54
48
|
this.merchantId = rnPaymentRequest.merchantId
|
package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEPaymentRequest.kt
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package com.reactnativepayengine.v2.features.googlepay
|
|
2
2
|
|
|
3
|
+
import com.payengine.paymentsdk.features.googlepay.nmi.GooglePayPaymentRequest
|
|
3
4
|
import org.json.JSONObject
|
|
4
5
|
|
|
5
6
|
data class RNPEPaymentItem(
|
|
@@ -17,4 +18,15 @@ data class RNPEPaymentRequest(
|
|
|
17
18
|
var billingAddressParameters: JSONObject? = null,
|
|
18
19
|
var shippingAddressParameters: JSONObject? = null
|
|
19
20
|
) {
|
|
21
|
+
|
|
22
|
+
fun toSDKRequest(): GooglePayPaymentRequest {
|
|
23
|
+
val paymentRequest = GooglePayPaymentRequest(
|
|
24
|
+
paymentAmount = this.paymentAmount,
|
|
25
|
+
billingAddressRequired = this.billingAddressRequired,
|
|
26
|
+
billingAddressParameters = this.billingAddressParameters,
|
|
27
|
+
shippingAddressRequired = this.shippingAddressRequired,
|
|
28
|
+
shippingAddressParameters = this.shippingAddressParameters
|
|
29
|
+
)
|
|
30
|
+
return paymentRequest
|
|
31
|
+
}
|
|
20
32
|
}
|
|
@@ -41,6 +41,7 @@ class RNPEApplePayButton: UIView {
|
|
|
41
41
|
debugPrint("Unable to render apple pay button: Missing payment request")
|
|
42
42
|
return
|
|
43
43
|
}
|
|
44
|
+
debugPrint("Payment request: \(paymentRequest)")
|
|
44
45
|
|
|
45
46
|
if let paymentRequest: RNPEApplePayPaymentRequest = try? JSONDecoder().decode(RNPEApplePayPaymentRequest.self, from: paymentRequest.data(using: .utf8)!) {
|
|
46
47
|
let pePaymentRequest = paymentRequest.toNative()
|
|
@@ -11,20 +11,20 @@ import PayEngineSDK
|
|
|
11
11
|
|
|
12
12
|
public struct RNPEApplePayPaymentRequest: Codable {
|
|
13
13
|
var paymentAmount: Double
|
|
14
|
-
var currencyCode: String
|
|
14
|
+
var currencyCode: String?
|
|
15
15
|
var paymentItems: [RNPEApplePayPaymentSummaryItem]
|
|
16
16
|
var requiredBillingContactFields: Set<RNPEContactField>? = []
|
|
17
17
|
var requiredShippingContactFields: Set<RNPEContactField>? = []
|
|
18
18
|
|
|
19
19
|
init(
|
|
20
20
|
paymentAmount: Double,
|
|
21
|
-
currencyCode: String,
|
|
21
|
+
currencyCode: String? = "USD",
|
|
22
22
|
paymentItems: [RNPEApplePayPaymentSummaryItem],
|
|
23
23
|
requiredBillingContactFields: Set<RNPEContactField> = [],
|
|
24
24
|
requiredShippingContactFields: Set<RNPEContactField> = []
|
|
25
25
|
) {
|
|
26
26
|
self.paymentAmount = paymentAmount
|
|
27
|
-
self.currencyCode = currencyCode
|
|
27
|
+
self.currencyCode = currencyCode ?? "USD"
|
|
28
28
|
self.paymentItems = paymentItems
|
|
29
29
|
self.requiredBillingContactFields = requiredBillingContactFields
|
|
30
30
|
self.requiredShippingContactFields = requiredShippingContactFields
|
|
@@ -35,7 +35,7 @@ public struct RNPEApplePayPaymentRequest: Codable {
|
|
|
35
35
|
request.build(
|
|
36
36
|
paymentItems: self.paymentItems.map { $0.toNative() },
|
|
37
37
|
paymentAmount: self.paymentAmount,
|
|
38
|
-
currencyCode: self.currencyCode,
|
|
38
|
+
currencyCode: self.currencyCode ?? "USD",
|
|
39
39
|
requiredBillingContactFields: Set(self.requiredBillingContactFields?.map { $0.toNative() } ?? []),
|
|
40
40
|
requiredShippingContactFields: Set(self.requiredShippingContactFields?.map { $0.toNative() } ?? [])
|
|
41
41
|
)
|