react-native-payengine 2.0.9 → 2.0.11

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 (75) hide show
  1. package/README.md +5 -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 +26 -35
  7. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +2 -1
  8. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Info.plist +0 -0
  9. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.abi.json +187 -38
  10. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface +1 -1
  11. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.private.swiftinterface-e +1 -1
  12. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface +1 -1
  13. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios.swiftinterface-e +1 -1
  14. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/PayEngineSDK +0 -0
  15. package/ios/PayEngineSDK.xcframework/ios-arm64/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
  16. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Headers/PayEngineSDK-Swift.h +4 -2
  17. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Info.plist +0 -0
  18. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.abi.json +187 -38
  19. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +1 -1
  20. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface-e +1 -1
  21. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +1 -1
  22. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface-e +1 -1
  23. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +187 -38
  24. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +1 -1
  25. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface-e +1 -1
  26. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +1 -1
  27. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/Modules/PayEngineSDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface-e +1 -1
  28. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/PayEngineSDK +0 -0
  29. package/ios/PayEngineSDK.xcframework/ios-arm64_x86_64-simulator/PayEngineSDK.framework/VGSCollectSDK_VGSCollectSDK.bundle/Assets.car +0 -0
  30. package/ios/Sources/Classes/ApplePay/RNPEApplePayButton.swift +75 -9
  31. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js +11 -1
  32. package/lib/commonjs/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  33. package/lib/commonjs/components/v2/ApplePay/PEApplePayContact.js +2 -0
  34. package/lib/commonjs/components/v2/ApplePay/PEApplePayContact.js.map +1 -0
  35. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js +2 -0
  36. package/lib/commonjs/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -0
  37. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js +9 -3
  38. package/lib/commonjs/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  39. package/lib/commonjs/components/v2/PayEngineNative.js +19 -1
  40. package/lib/commonjs/components/v2/PayEngineNative.js.map +1 -1
  41. package/lib/commonjs/index.js +8 -0
  42. package/lib/commonjs/index.js.map +1 -1
  43. package/lib/commonjs/interfaces/index.js +12 -0
  44. package/lib/commonjs/interfaces/index.js.map +1 -1
  45. package/lib/module/components/v2/ApplePay/PEApplePayButton.js +11 -1
  46. package/lib/module/components/v2/ApplePay/PEApplePayButton.js.map +1 -1
  47. package/lib/module/components/v2/ApplePay/PEApplePayContact.js +2 -0
  48. package/lib/module/components/v2/ApplePay/PEApplePayContact.js.map +1 -0
  49. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js +2 -0
  50. package/lib/module/components/v2/GooglePay/PEGooglePayAddress.js.map +1 -0
  51. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js +9 -3
  52. package/lib/module/components/v2/GooglePay/PEGooglePayButton.js.map +1 -1
  53. package/lib/module/components/v2/PayEngineNative.js +18 -1
  54. package/lib/module/components/v2/PayEngineNative.js.map +1 -1
  55. package/lib/module/index.js +2 -1
  56. package/lib/module/index.js.map +1 -1
  57. package/lib/module/interfaces/index.js +5 -0
  58. package/lib/module/interfaces/index.js.map +1 -1
  59. package/lib/typescript/components/v2/ApplePay/PEApplePayButton.d.ts +2 -1
  60. package/lib/typescript/components/v2/ApplePay/PEApplePayContact.d.ts +14 -0
  61. package/lib/typescript/components/v2/GooglePay/PEGooglePayAddress.d.ts +11 -0
  62. package/lib/typescript/components/v2/GooglePay/PEGooglePayButton.d.ts +2 -1
  63. package/lib/typescript/components/v2/PayEngineNative.d.ts +7 -0
  64. package/lib/typescript/index.d.ts +4 -1
  65. package/lib/typescript/interfaces/index.d.ts +4 -0
  66. package/package.json +1 -1
  67. package/src/components/v2/ApplePay/PEApplePayButton.tsx +13 -3
  68. package/src/components/v2/ApplePay/PEApplePayContact.ts +14 -0
  69. package/src/components/v2/GooglePay/PEGooglePayAddress.ts +11 -0
  70. package/src/components/v2/GooglePay/PEGooglePayButton.tsx +9 -4
  71. package/src/components/v2/PayEngineNative.tsx +16 -1
  72. package/src/index.tsx +6 -2
  73. package/src/interfaces/index.ts +5 -0
  74. package/android/payment-sdk-debug-1.0.3.aar +0 -0
  75. package/android/payment-sdk-release-1.0.3.aar +0 -0
package/README.md CHANGED
@@ -156,7 +156,8 @@ import {
156
156
  PEPaymentRequest,
157
157
  PayEngineNative,
158
158
  PayEngineUtils,
159
- RNPEContactField
159
+ RNPEContactField,
160
+ PayProvider
160
161
  } from 'react-native-payengine';
161
162
  import axios from 'axios';
162
163
 
@@ -167,7 +168,7 @@ const ApplePayScreen = () => {
167
168
  React.useEffect(() => {
168
169
  const checkSupport = async () => {
169
170
  try {
170
- const isSupported = await PayEngineNative.isPlatformPaySupported(
171
+ const isSupported = await PayEngineNative.userCanPay(PayProvider.applePay,
171
172
  MERCHANT_ID
172
173
  );
173
174
  console.log('isSupported', isSupported);
@@ -249,6 +250,7 @@ import {
249
250
  PEGooglePayButton,
250
251
  PEPaymentRequest,
251
252
  PayEngineNative,
253
+ PayProvider
252
254
  } from 'react-native-payengine';
253
255
 
254
256
  const GooglePayScreen = () => {
@@ -258,7 +260,7 @@ const GooglePayScreen = () => {
258
260
  React.useEffect(() => {
259
261
  const checkSupport = async () => {
260
262
  try {
261
- const isSupported = await PayEngineNative.isPlatformPaySupported(
263
+ const isSupported = await PayEngineNative.userCanPay(PayProvider.googlePay,
262
264
  MERCHANT_ID
263
265
  );
264
266
  console.log('isSupported', isSupported);
@@ -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,52 +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
35
  val paymentRequest = rnPaymentRequest.toSDKRequest()
46
36
  Log.d("TEST", "Decoded ${Gson().toJson(paymentRequest)}")
47
37
  this.paymentRequest = paymentRequest
48
- this.merchantId = rnPaymentRequest.merchantId
49
38
 
50
39
  this.setupView()
51
40
  }
52
41
 
53
- internal fun setupView() {
54
- Log.d("TEST", "setupView is called")
55
- // if (amount == null || merchantId == null) return
56
- if (paymentRequest == null) {
57
- Log.d("TEST", "setupView is called but stopped here")
58
- return
42
+ private fun setupView() {
43
+ if (RNPayEngineNative.googlePay == null) {
44
+ throw Exception("userCanPay must be called before rendering button")
59
45
  }
60
46
 
61
- this.activity?.let {
62
- RNPayEngineNative.instance?.createGooglePay(it, this.merchantId!!) {
63
- if (it is PEGooglePayStatus.Eligible) {
64
- val googlepay = it.googlePayInstance
65
- RNPayEngineNative.googlePay = googlepay
47
+ val googlePay = RNPayEngineNative.googlePay!!
66
48
 
67
- googlepay.delegate = this
68
- googlepay.setupGooglePayButton(this.paymentRequest!!) {
69
- if (it != null) {
70
- this.addView(it)
71
- } else {
72
- this.paymentFailure(Error("Google pay is not available"))
73
- }
74
- }
75
- } else if (it is PEGooglePayStatus.NotEligible) {
76
- this.paymentFailure(Error("Google pay is not available: ${it.error}"))
77
- }
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"))
78
55
  }
79
56
  }
80
57
  }
@@ -97,10 +74,24 @@ class RNPEGooglePayButton(private val context: ThemedReactContext, private val a
97
74
  .emit(RNPEEvents.ON_GOOGLE_PAY_DISMISS, params)
98
75
  }
99
76
 
100
- override fun paymentTokenDidReturn(token: String) {
77
+ override fun paymentTokenDidReturn(
78
+ token: String,
79
+ metadata: Map<String, Any>?,
80
+ billingAddress: PEAddress?,
81
+ shippingAddress: PEAddress?
82
+ ) {
101
83
  Log.d("PE", "paymentTokenDidReturn: $token")
102
84
  val params = Arguments.createMap().apply {
103
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
+ }
104
95
  }
105
96
  context
106
97
  .getJSModule(RCTDeviceEventEmitter::class.java)
@@ -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