react-native-payengine 2.0.5 → 2.0.8

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.
Files changed (60) hide show
  1. package/README.md +26 -11
  2. package/android/build.gradle +2 -2
  3. package/android/payment-sdk-debug-1.0.3.aar +0 -0
  4. package/android/payment-sdk-release-1.0.3.aar +0 -0
  5. package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEGooglePayButton.kt +33 -10
  6. package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEGooglePayButtonManager.kt +17 -7
  7. package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEPaymentRequest.kt +20 -0
  8. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +2 -2
  9. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Info.plist +0 -0
  10. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.abi.json +219 -328
  11. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +2 -14
  12. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +2 -14
  13. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
  14. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface +2 -14
  15. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +2 -14
  16. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +0 -0
  17. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +4 -4
  18. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Info.plist +0 -0
  19. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +219 -328
  20. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +2 -14
  21. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +2 -14
  22. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
  23. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +2 -14
  24. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +2 -14
  25. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +219 -328
  26. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +2 -14
  27. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +2 -14
  28. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
  29. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +2 -14
  30. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +2 -14
  31. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/PayEngineSDK +0 -0
  32. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
  33. package/ios/Sources/Classes/ApplePay/RNPEApplePayButton.swift +7 -7
  34. package/ios/Sources/Classes/ApplePay/RNPEApplePayPaymentRequest.swift +41 -2
  35. package/ios/Sources/Classes/RNPayEngineNative.swift +12 -10
  36. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +3 -1
  37. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  38. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +6 -3
  39. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  40. package/lib/commonjs/components/v2/PEPaymentRequest.js +71 -1
  41. package/lib/commonjs/components/v2/PEPaymentRequest.js.map +1 -1
  42. package/lib/commonjs/index.js +24 -0
  43. package/lib/commonjs/index.js.map +1 -1
  44. package/lib/module/components/v2/ApplePay/PEApplePayButton.js +3 -1
  45. package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  46. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +6 -3
  47. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  48. package/lib/module/components/v2/PEPaymentRequest.js +58 -0
  49. package/lib/module/components/v2/PEPaymentRequest.js.map +1 -1
  50. package/lib/module/index.js +2 -2
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/typescript/components/v2/PEPaymentRequest.d.ts +39 -1
  53. package/lib/typescript/index.d.ts +2 -2
  54. package/package.json +1 -1
  55. package/src/components/v2/ApplePay/PEApplePayButton.tsx +4 -1
  56. package/src/components/v2/GooglePay/PEGooglePayButton.tsx +9 -4
  57. package/src/components/v2/PEPaymentRequest.ts +65 -6
  58. package/src/index.tsx +6 -1
  59. package/android/payment-sdk-debug-1.0.2.aar +0 -0
  60. package/android/payment-sdk-release-1.0.2.aar +0 -0
package/README.md CHANGED
@@ -156,6 +156,7 @@ import {
156
156
  PEPaymentRequest,
157
157
  PayEngineNative,
158
158
  PayEngineUtils,
159
+ RNPEContactField
159
160
  } from 'react-native-payengine';
160
161
  import axios from 'axios';
161
162
 
@@ -178,16 +179,20 @@ const ApplePayScreen = () => {
178
179
  checkSupport();
179
180
  }, []);
180
181
 
181
- const paymentRequest = new PEPaymentRequest(<MERCHANT_ID>, 120.5, 'USD', [
182
- {
183
- amount: 100.0,
184
- label: 'Full Back Lounge Chair',
185
- },
186
- {
187
- amount: 20.5,
188
- label: 'Glass Top Oval Center Table',
189
- },
190
- ]);
182
+ const paymentRequest: PEPaymentRequest = {
183
+ merchantId: MERCHANT_ID,
184
+ paymentAmount: 10.5,
185
+ paymentItems: [
186
+ {
187
+ amount: 100,
188
+ label: 'Test Item',
189
+ },
190
+ ],
191
+ platformOptions: {
192
+ requiredBillingContactFields: [RNPEContactField.postalAddress],
193
+ requiredShippingContactFields: []
194
+ }
195
+ }
191
196
 
192
197
  const purchaseWithToken = async (token) => {
193
198
  // send the token to your server to make a purchase
@@ -264,7 +269,17 @@ const GooglePayScreen = () => {
264
269
  checkSupport();
265
270
  }, []);
266
271
 
267
- const paymentRequest = new PEPaymentRequest(<MERCHANT_ID>, 15.5);
272
+ const paymentRequest = {
273
+ paymentAmount: amount,
274
+ merchantId: MERCHANT_ID,
275
+ platformOptions: {
276
+ billingAddressRequired: true,
277
+ billingAddressParameters: {
278
+ format: 'FULL'
279
+ },
280
+ shippingAddressRequired: false
281
+ }
282
+ };
268
283
 
269
284
  const purchaseWithToken = async (token) => {
270
285
  // send the token to your server to make a purchase
@@ -164,8 +164,8 @@ dependencies {
164
164
 
165
165
  implementation files("./securefields-1.7.2-debug.aar")
166
166
 
167
- debugImplementation files("./payment-sdk-debug-1.0.2.aar")
168
- releaseImplementation files("./payment-sdk-debug-1.0.2.aar")
167
+ debugImplementation files("./payment-sdk-debug-1.0.3.aar")
168
+ releaseImplementation files("./payment-sdk-debug-1.0.3.aar")
169
169
 
170
170
  api 'com.github.Kount:kount-android-sdk:v4.3.2'
171
171
  implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
@@ -7,6 +7,7 @@ import android.widget.LinearLayout
7
7
  import com.facebook.react.bridge.Arguments
8
8
  import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
9
9
  import com.facebook.react.uimanager.ThemedReactContext
10
+ import com.google.gson.Gson
10
11
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayDelegate
11
12
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayStatus
12
13
  import com.payengine.paymentsdk.features.googlepay.nmi.GooglePayPaymentRequest
@@ -16,8 +17,8 @@ import com.reactnativepayengine.v2.securefields.RNPEEvents
16
17
  class RNPEGooglePayButton(private val context: ThemedReactContext, private val activity: Activity?): LinearLayout(context),
17
18
  PEGooglePayDelegate {
18
19
 
19
- private var amount: Double? = null
20
20
  private var merchantId: String? = null
21
+ private var paymentRequest: GooglePayPaymentRequest? = null
21
22
 
22
23
  init {
23
24
  this.orientation = VERTICAL
@@ -28,18 +29,40 @@ class RNPEGooglePayButton(private val context: ThemedReactContext, private val a
28
29
  this.layoutParams = layoutParams
29
30
  }
30
31
 
31
- fun setAmount(amount: Double) {
32
- this.amount = amount
33
- this.setupView()
34
- }
32
+ // fun setAmount(amount: Double) {
33
+ // this.amount = amount
34
+ // this.setupView()
35
+ // }
36
+ //
37
+ // fun setMerchantId(merchantId: String) {
38
+ // this.merchantId = merchantId
39
+ // this.setupView()
40
+ // }
41
+
42
+ fun setPaymentRequest(text: String) {
43
+ Log.d("TEST", "Received pm request $text")
44
+ val rnPaymentRequest = Gson().fromJson(text, RNPEPaymentRequest::class.java)
45
+ val paymentRequest = GooglePayPaymentRequest(
46
+ paymentAmount = rnPaymentRequest.paymentAmount,
47
+ billingAddressRequired = rnPaymentRequest.billingAddressRequired,
48
+ billingAddressParameters = rnPaymentRequest.billingAddressParameters,
49
+ shippingAddressRequired = rnPaymentRequest.shippingAddressRequired,
50
+ shippingAddressParameters = rnPaymentRequest.shippingAddressParameters
51
+ )
52
+ Log.d("TEST", "Decoded ${Gson().toJson(paymentRequest)}")
53
+ this.paymentRequest = paymentRequest
54
+ this.merchantId = rnPaymentRequest.merchantId
35
55
 
36
- fun setMerchantId(merchantId: String) {
37
- this.merchantId = merchantId
38
56
  this.setupView()
39
57
  }
40
58
 
41
- private fun setupView() {
42
- if (amount == null || merchantId == null) return
59
+ internal fun setupView() {
60
+ Log.d("TEST", "setupView is called")
61
+ // if (amount == null || merchantId == null) return
62
+ if (paymentRequest == null) {
63
+ Log.d("TEST", "setupView is called but stopped here")
64
+ return
65
+ }
43
66
 
44
67
  this.activity?.let {
45
68
  RNPayEngineNative.instance?.createGooglePay(it, this.merchantId!!) {
@@ -48,7 +71,7 @@ class RNPEGooglePayButton(private val context: ThemedReactContext, private val a
48
71
  RNPayEngineNative.googlePay = googlepay
49
72
 
50
73
  googlepay.delegate = this
51
- googlepay.setupGooglePayButton(GooglePayPaymentRequest(amount!!)) {
74
+ googlepay.setupGooglePayButton(this.paymentRequest!!) {
52
75
  if (it != null) {
53
76
  this.addView(it)
54
77
  } else {
@@ -13,14 +13,19 @@ import com.reactnativepayengine.v2.RNPayEngineNative
13
13
  class RNPEGooglePayButtonManager: SimpleViewManager<RNPEGooglePayButton> {
14
14
  private var context: ReactApplicationContext
15
15
 
16
- @ReactProp(name = "amount")
17
- fun setAmount(view: RNPEGooglePayButton, amount: Double) {
18
- view.setAmount(amount)
19
- }
16
+ // @ReactProp(name = "amount")
17
+ // fun setAmount(view: RNPEGooglePayButton, amount: Double) {
18
+ // view.setAmount(amount)
19
+ // }
20
+ //
21
+ // @ReactProp(name = "merchantId")
22
+ // fun setMerchantId(view: RNPEGooglePayButton, merchantId: String) {
23
+ // view.setMerchantId(merchantId)
24
+ // }
20
25
 
21
- @ReactProp(name = "merchantId")
22
- fun setMerchantId(view: RNPEGooglePayButton, merchantId: String) {
23
- view.setMerchantId(merchantId)
26
+ @ReactProp(name = "paymentRequest")
27
+ fun setPaymentRequest(view: RNPEGooglePayButton, paymentRequest: String) {
28
+ view.setPaymentRequest(paymentRequest)
24
29
  }
25
30
 
26
31
 
@@ -38,6 +43,11 @@ class RNPEGooglePayButtonManager: SimpleViewManager<RNPEGooglePayButton> {
38
43
  return RNPEGooglePayButton(reactContext, context.currentActivity)
39
44
  }
40
45
 
46
+ // override fun onAfterUpdateTransaction(view: RNPEGooglePayButton) {
47
+ // super.onAfterUpdateTransaction(view)
48
+ // view.setupView()
49
+ // }
50
+
41
51
 
42
52
  companion object {
43
53
  private const val REACT_CLASS = "RNPEGooglePayButton"
@@ -0,0 +1,20 @@
1
+ package com.reactnativepayengine.v2.features.googlepay
2
+
3
+ import org.json.JSONObject
4
+
5
+ data class RNPEPaymentItem(
6
+ val label: String,
7
+ val amount: Double,
8
+ )
9
+
10
+ data class RNPEPaymentRequest(
11
+ val merchantId: String,
12
+ val paymentAmount: Double,
13
+ val currencyCode: String,
14
+ val paymentItems: List<RNPEPaymentItem>,
15
+ var billingAddressRequired: Boolean = true,
16
+ var shippingAddressRequired: Boolean = false,
17
+ var billingAddressParameters: JSONObject? = null,
18
+ var shippingAddressParameters: JSONObject? = null
19
+ ) {
20
+ }
@@ -341,7 +341,7 @@ SWIFT_CLASS("_TtC12PayEngineSDK22ApplePayPaymentRequest")
341
341
  ///
342
342
  /// \param paymentAmount The total amount you want to collect
343
343
  ///
344
- - (void)buildWithPaymentItems:(NSArray<PKPaymentSummaryItem *> * _Nonnull)paymentItems paymentAmount:(double)paymentAmount currencyCode:(NSString * _Nonnull)currencyCode;
344
+ - (void)buildWithPaymentItems:(NSArray<PKPaymentSummaryItem *> * _Nonnull)paymentItems paymentAmount:(double)paymentAmount currencyCode:(NSString * _Nonnull)currencyCode requiredBillingContactFields:(NSSet<PKContactField> * _Nonnull)requiredBillingContactFields requiredShippingContactFields:(NSSet<PKContactField> * _Nonnull)requiredShippingContactFields;
345
345
  - (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
346
346
  @end
347
347
 
@@ -453,7 +453,7 @@ SWIFT_PROTOCOL("_TtP12PayEngineSDK18PEApplePayDelegate_")
453
453
  - (void)paymentErrorWithError:(NSError * _Nonnull)error;
454
454
  - (void)paymentSheetDidMDismiss;
455
455
  - (void)paymentTokenDidReturnWithToken:(NSString * _Nonnull)token completion:(void (^ _Nonnull)(enum PEApplePayResult))completion;
456
- - (void)paymentTokenNotAvailable;
456
+ - (void)paymentTokenNotAvailableWithError:(NSError * _Nullable)error;
457
457
  @end
458
458
 
459
459
  typedef SWIFT_ENUM(NSInteger, PEApplePayResult, open) {