react-native-payengine 2.0.8 → 2.0.10

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 (77) hide show
  1. package/README.md +4 -3
  2. package/android/build.gradle +2 -2
  3. package/android/payment-sdk-debug-1.0.4.aar +0 -0
  4. package/android/payment-sdk-release-1.0.4.aar +0 -0
  5. package/android/src/main/java/com/reactnativepayengine/v2/RNPayEngineNative.kt +21 -0
  6. package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEGooglePayButton.kt +27 -42
  7. package/android/src/main/java/com/reactnativepayengine/v2/features/googlepay/RNPEPaymentRequest.kt +12 -0
  8. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +2 -1
  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 +187 -38
  11. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -1
  12. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +1 -1
  13. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface +1 -1
  14. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +1 -1
  15. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +0 -0
  16. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
  17. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +4 -2
  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 +187 -38
  20. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -1
  21. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +1 -1
  22. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
  23. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +1 -1
  24. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +187 -38
  25. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -1
  26. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +1 -1
  27. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -1
  28. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +1 -1
  29. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/PayEngineSDK +0 -0
  30. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
  31. package/ios/Sources/Classes/ApplePay/RNPEApplePayButton.swift +76 -9
  32. package/ios/Sources/Classes/ApplePay/RNPEApplePayPaymentRequest.swift +4 -4
  33. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +11 -1
  34. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  35. package/lib/commonjs/components/v2/ApplePay/PEApplePayContact.js +2 -0
  36. package/lib/commonjs/components/v2/ApplePay/PEApplePayContact.js.map +1 -0
  37. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js +2 -0
  38. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -0
  39. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +9 -3
  40. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  41. package/lib/commonjs/components/v2/PayEngineNative.js +19 -1
  42. package/lib/commonjs/components/v2/PayEngineNative.js.map +1 -1
  43. package/lib/commonjs/index.js +8 -0
  44. package/lib/commonjs/index.js.map +1 -1
  45. package/lib/commonjs/interfaces/index.js +12 -0
  46. package/lib/commonjs/interfaces/index.js.map +1 -1
  47. package/lib/module/components/v2/ApplePay/PEApplePayButton.js +11 -1
  48. package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  49. package/lib/module/components/v2/ApplePay/PEApplePayContact.js +2 -0
  50. package/lib/module/components/v2/ApplePay/PEApplePayContact.js.map +1 -0
  51. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js +2 -0
  52. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -0
  53. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +9 -3
  54. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  55. package/lib/module/components/v2/PayEngineNative.js +18 -1
  56. package/lib/module/components/v2/PayEngineNative.js.map +1 -1
  57. package/lib/module/index.js +2 -1
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/interfaces/index.js +5 -0
  60. package/lib/module/interfaces/index.js.map +1 -1
  61. package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +2 -1
  62. package/lib/typescript/components/v2/ApplePay/PEApplePayContact.d.ts +14 -0
  63. package/lib/typescript/components/v2/GooglePay/PEGooglePayAddress.d.ts +11 -0
  64. package/lib/typescript/components/v2/GooglePay/PEGooglePayButton.d.ts +2 -1
  65. package/lib/typescript/components/v2/PayEngineNative.d.ts +7 -0
  66. package/lib/typescript/index.d.ts +4 -1
  67. package/lib/typescript/interfaces/index.d.ts +4 -0
  68. package/package.json +1 -1
  69. package/src/components/v2/ApplePay/PEApplePayButton.tsx +13 -3
  70. package/src/components/v2/ApplePay/PEApplePayContact.ts +14 -0
  71. package/src/components/v2/GooglePay/PEGooglePayAddress.ts +11 -0
  72. package/src/components/v2/GooglePay/PEGooglePayButton.tsx +9 -4
  73. package/src/components/v2/PayEngineNative.tsx +16 -1
  74. package/src/index.tsx +6 -2
  75. package/src/interfaces/index.ts +5 -0
  76. package/android/payment-sdk-debug-1.0.3.aar +0 -0
  77. package/android/payment-sdk-release-1.0.3.aar +0 -0
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.5,
184
+ paymentAmount: 10.15,
185
+ currencyCode: 'USD',
185
186
  paymentItems: [
186
187
  {
187
- amount: 100,
188
- label: 'Test Item',
188
+ amount: 10.15,
189
+ label: 'Total Amount',
189
190
  },
190
191
  ],
191
192
  platformOptions: {
@@ -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.3.aar")
168
- releaseImplementation files("./payment-sdk-debug-1.0.3.aar")
167
+ debugImplementation files("./payment-sdk-debug-1.0.4.aar")
168
+ releaseImplementation files("./payment-sdk-debug-1.0.4.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'
@@ -9,6 +9,7 @@ import com.facebook.react.bridge.ReactMethod
9
9
  import com.facebook.react.bridge.UiThreadUtil.runOnUiThread
10
10
  import com.payengine.paymentsdk.PayEngine
11
11
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayInterface
12
+ import com.payengine.paymentsdk.features.googlepay.PEGooglePayStatus
12
13
  import com.payengine.paymentsdk.models.PEConfig
13
14
  import kotlin.concurrent.thread
14
15
 
@@ -66,6 +67,26 @@ class RNPayEngineNative: ReactContextBaseJavaModule {
66
67
  }
67
68
  }
68
69
 
70
+ @ReactMethod
71
+ fun isGooglePaySupported(merchantId: String, promise: Promise) {
72
+ Log.d("TEST", "isGooglePaySupported is called")
73
+ val currentActivity = reactApplicationContext.currentActivity
74
+ if (currentActivity == null) {
75
+ promise.reject("NO_ACTIVITY", "No activity found")
76
+ return
77
+ }
78
+
79
+ instance!!.createGooglePay(currentActivity, merchantId) {
80
+ if (it is PEGooglePayStatus.Eligible) {
81
+ googlePay = it.googlePayInstance
82
+ promise.resolve(true)
83
+ } else if (it is PEGooglePayStatus.NotEligible) {
84
+ googlePay = null
85
+ promise.reject("NOT_SUPPORTED", it.error.localizedMessage, it.error)
86
+ }
87
+ }
88
+ }
89
+
69
90
  companion object {
70
91
  var instance: PayEngine? = null
71
92
  var googlePay: PEGooglePayInterface? = null
@@ -11,13 +11,13 @@ import com.google.gson.Gson
11
11
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayDelegate
12
12
  import com.payengine.paymentsdk.features.googlepay.PEGooglePayStatus
13
13
  import com.payengine.paymentsdk.features.googlepay.nmi.GooglePayPaymentRequest
14
+ import com.payengine.paymentsdk.features.googlepay.payengine.PEAddress
14
15
  import com.reactnativepayengine.v2.RNPayEngineNative
15
16
  import com.reactnativepayengine.v2.securefields.RNPEEvents
16
17
 
17
18
  class RNPEGooglePayButton(private val context: ThemedReactContext, private val activity: Activity?): LinearLayout(context),
18
19
  PEGooglePayDelegate {
19
20
 
20
- private var merchantId: String? = null
21
21
  private var paymentRequest: GooglePayPaymentRequest? = null
22
22
 
23
23
  init {
@@ -29,58 +29,29 @@ class RNPEGooglePayButton(private val context: ThemedReactContext, private val a
29
29
  this.layoutParams = layoutParams
30
30
  }
31
31
 
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
32
  fun setPaymentRequest(text: String) {
43
33
  Log.d("TEST", "Received pm request $text")
44
34
  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
- )
35
+ val paymentRequest = rnPaymentRequest.toSDKRequest()
52
36
  Log.d("TEST", "Decoded ${Gson().toJson(paymentRequest)}")
53
37
  this.paymentRequest = paymentRequest
54
- this.merchantId = rnPaymentRequest.merchantId
55
38
 
56
39
  this.setupView()
57
40
  }
58
41
 
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
42
+ private fun setupView() {
43
+ if (RNPayEngineNative.googlePay == null) {
44
+ throw Exception("userCanPay must be called before rendering button")
65
45
  }
66
46
 
67
- this.activity?.let {
68
- RNPayEngineNative.instance?.createGooglePay(it, this.merchantId!!) {
69
- if (it is PEGooglePayStatus.Eligible) {
70
- val googlepay = it.googlePayInstance
71
- RNPayEngineNative.googlePay = googlepay
47
+ val googlePay = RNPayEngineNative.googlePay!!
72
48
 
73
- googlepay.delegate = this
74
- googlepay.setupGooglePayButton(this.paymentRequest!!) {
75
- if (it != null) {
76
- this.addView(it)
77
- } else {
78
- this.paymentFailure(Error("Google pay is not available"))
79
- }
80
- }
81
- } else if (it is PEGooglePayStatus.NotEligible) {
82
- this.paymentFailure(Error("Google pay is not available: ${it.error}"))
83
- }
49
+ googlePay.delegate = this
50
+ googlePay.setupGooglePayButton(this.paymentRequest!!) {
51
+ if (it != null) {
52
+ this.addView(it)
53
+ } else {
54
+ this.paymentFailure(Error("Google pay is not available"))
84
55
  }
85
56
  }
86
57
  }
@@ -103,10 +74,24 @@ class RNPEGooglePayButton(private val context: ThemedReactContext, private val a
103
74
  .emit(RNPEEvents.ON_GOOGLE_PAY_DISMISS, params)
104
75
  }
105
76
 
106
- override fun paymentTokenDidReturn(token: String) {
77
+ override fun paymentTokenDidReturn(
78
+ token: String,
79
+ metadata: Map<String, Any>?,
80
+ billingAddress: PEAddress?,
81
+ shippingAddress: PEAddress?
82
+ ) {
107
83
  Log.d("PE", "paymentTokenDidReturn: $token")
108
84
  val params = Arguments.createMap().apply {
109
85
  putString("token", token)
86
+ if (metadata != null) {
87
+ putString("metadata", Gson().toJson(metadata))
88
+ }
89
+ if (billingAddress != null) {
90
+ putString("billingAddress", Gson().toJson(billingAddress))
91
+ }
92
+ if (shippingAddress != null) {
93
+ putString("shippingAddress", Gson().toJson(shippingAddress))
94
+ }
110
95
  }
111
96
  context
112
97
  .getJSModule(RCTDeviceEventEmitter::class.java)
@@ -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
  }
@@ -446,13 +446,14 @@ SWIFT_CLASS("_TtC12PayEngineSDK10PEApplePay")
446
446
  - (void)paymentAuthorizationViewController:(PKPaymentAuthorizationViewController * _Nonnull)controller didAuthorizePayment:(PKPayment * _Nonnull)payment completion:(void (^ _Nonnull)(PKPaymentAuthorizationStatus))completion;
447
447
  @end
448
448
 
449
+ @class PKContact;
449
450
  enum PEApplePayResult : NSInteger;
450
451
 
451
452
  SWIFT_PROTOCOL("_TtP12PayEngineSDK18PEApplePayDelegate_")
452
453
  @protocol PEApplePayDelegate
453
454
  - (void)paymentErrorWithError:(NSError * _Nonnull)error;
454
455
  - (void)paymentSheetDidMDismiss;
455
- - (void)paymentTokenDidReturnWithToken:(NSString * _Nonnull)token completion:(void (^ _Nonnull)(enum PEApplePayResult))completion;
456
+ - (void)paymentTokenDidReturnWithToken:(NSString * _Nonnull)token metadata:(NSDictionary<NSString *, id> * _Nullable)metadata billingContact:(PKContact * _Nullable)billingContact shippingContact:(PKContact * _Nullable)shippingContact completion:(void (^ _Nonnull)(enum PEApplePayResult))completion;
456
457
  - (void)paymentTokenNotAvailableWithError:(NSError * _Nullable)error;
457
458
  @end
458
459