@primer-io/react-native 2.21.0 → 2.21.1

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.
@@ -68,21 +68,42 @@ class PrimerRNHeadlessUniversalCheckoutListener : PrimerHeadlessUniversalCheckou
68
68
  override fun onPreparationStarted(paymentMethodType: String) {
69
69
  sendEvent?.invoke(
70
70
  PrimerHeadlessUniversalCheckoutEvent.ON_PREPARE_START.eventName,
71
- JSONObject(Json.encodeToString(PrimerPaymentMethodDataRN(paymentMethodType)))
71
+ JSONObject(
72
+ Json.encodeToString(
73
+ PrimerPaymentMethodDataRN(
74
+ paymentMethodType = paymentMethodType,
75
+ paymentMethod = paymentMethodType
76
+ )
77
+ )
78
+ )
72
79
  )
73
80
  }
74
81
 
75
82
  override fun onPaymentMethodShowed(paymentMethodType: String) {
76
83
  sendEvent?.invoke(
77
84
  PrimerHeadlessUniversalCheckoutEvent.ON_PAYMENT_METHOD_SHOW.eventName,
78
- JSONObject(Json.encodeToString(PrimerPaymentMethodDataRN(paymentMethodType)))
85
+ JSONObject(
86
+ Json.encodeToString(
87
+ PrimerPaymentMethodDataRN(
88
+ paymentMethodType = paymentMethodType,
89
+ paymentMethod = paymentMethodType
90
+ )
91
+ )
92
+ )
79
93
  )
80
94
  }
81
95
 
82
96
  override fun onTokenizationStarted(paymentMethodType: String) {
83
97
  sendEvent?.invoke(
84
98
  PrimerHeadlessUniversalCheckoutEvent.ON_TOKENIZE_START.eventName,
85
- JSONObject(Json.encodeToString(PrimerPaymentMethodDataRN(paymentMethodType)))
99
+ JSONObject(
100
+ Json.encodeToString(
101
+ PrimerPaymentMethodDataRN(
102
+ paymentMethodType = paymentMethodType,
103
+ paymentMethod = paymentMethodType
104
+ )
105
+ )
106
+ )
86
107
  )
87
108
  }
88
109
 
@@ -3,4 +3,4 @@ package com.primerioreactnative.datamodels
3
3
  import kotlinx.serialization.Serializable
4
4
 
5
5
  @Serializable
6
- data class PrimerPaymentMethodDataRN(val paymentMethodType: String)
6
+ data class PrimerPaymentMethodDataRN(val paymentMethodType: String, val paymentMethod: String)
@@ -4,4 +4,4 @@ import com.primerioreactnative.datamodels.PrimerPaymentMethodDataRN
4
4
  import io.primer.android.domain.tokenization.models.PrimerPaymentMethodData
5
5
 
6
6
  internal fun PrimerPaymentMethodData.toPrimerPaymentMethodDataRN() =
7
- PrimerPaymentMethodDataRN(paymentMethodType)
7
+ PrimerPaymentMethodDataRN(paymentMethodType, paymentMethodType)
@@ -450,7 +450,9 @@ extension RNTPrimerHeadlessUniversalCheckout: PrimerHeadlessUniversalCheckoutDel
450
450
  }
451
451
 
452
452
  do {
453
- let checkoutPaymentmethodJson = try data.toJsonObject()
453
+ let checkoutPaymentmethodJson = try data
454
+ .toPrimerCheckoutPaymentMethodDataRN()
455
+ .toJsonObject()
454
456
  self.sendEvent(
455
457
  withName: rnCallbackName,
456
458
  body: checkoutPaymentmethodJson)
@@ -0,0 +1,21 @@
1
+ //
2
+ // PrimerCheckoutPaymentMethodData+RN.swift
3
+ // primer-io-react-native
4
+ //
5
+ // Created by Niall Quinn on 19/03/24.
6
+ //
7
+
8
+ import Foundation
9
+ import PrimerSDK
10
+
11
+ extension PrimerCheckoutPaymentMethodData {
12
+ func toPrimerCheckoutPaymentMethodDataRN() -> PrimerCheckoutPaymentMethodDataRN {
13
+ PrimerCheckoutPaymentMethodDataRN(paymentMethodType: self.paymentMethodType,
14
+ paymentMethod: self.paymentMethodType.type)
15
+ }
16
+ }
17
+
18
+ struct PrimerCheckoutPaymentMethodDataRN: Codable {
19
+ let paymentMethodType: PrimerCheckoutPaymentMethodType
20
+ let paymentMethod: String
21
+ }
@@ -348,6 +348,7 @@ extension RNTPrimer: PrimerDelegate {
348
348
 
349
349
 
350
350
  func primerWillCreatePaymentWithData(_ data: PrimerCheckoutPaymentMethodData, decisionHandler: @escaping (PrimerPaymentCreationDecision) -> Void) {
351
+
351
352
  if self.implementedRNCallbacks?.isOnBeforePaymentCreateImplemented == true {
352
353
  self.primerWillCreatePaymentWithDataDecisionHandler = { errorMessage in
353
354
  DispatchQueue.main.async {
@@ -361,8 +362,9 @@ extension RNTPrimer: PrimerDelegate {
361
362
 
362
363
  DispatchQueue.main.async {
363
364
  do {
364
- let checkoutPaymentmethodData = try JSONEncoder().encode(data)
365
- let checkoutPaymentmethodJson = try JSONSerialization.jsonObject(with: checkoutPaymentmethodData, options: .allowFragments)
365
+ let checkoutPaymentmethodJson = try data
366
+ .toPrimerCheckoutPaymentMethodDataRN()
367
+ .toJsonObject()
366
368
  self.sendEvent(withName: PrimerEvents.onBeforePaymentCreate.stringValue, body: checkoutPaymentmethodJson)
367
369
  } catch {
368
370
  self.handleRNBridgeError(error, checkoutData: nil, stopOnDebug: true)
@@ -1,2 +1,2 @@
1
1
  // swiftlint:disable:next identifier_name
2
- public let PrimerReactNativeSDKVersion = "2.21.0"
2
+ public let PrimerReactNativeSDKVersion = "2.21.1"
@@ -1,6 +1,7 @@
1
1
  export declare type PrimerCheckoutPaymentMethodData = IPrimerCheckoutPaymentMethodData;
2
2
  interface IPrimerCheckoutPaymentMethodData {
3
3
  paymentMethodType: string;
4
+ paymentMethod: string;
4
5
  }
5
6
  export {};
6
7
  //# sourceMappingURL=PrimerCheckoutPaymentMethodData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrimerCheckoutPaymentMethodData.d.ts","sourceRoot":"","sources":["../../../src/models/PrimerCheckoutPaymentMethodData.ts"],"names":[],"mappings":"AAAA,oBAAY,+BAA+B,GAAG,gCAAgC,CAAC;AAE/E,UAAU,gCAAgC;IACtC,iBAAiB,EAAE,MAAM,CAAC;CAC7B"}
1
+ {"version":3,"file":"PrimerCheckoutPaymentMethodData.d.ts","sourceRoot":"","sources":["../../../src/models/PrimerCheckoutPaymentMethodData.ts"],"names":[],"mappings":"AAAA,oBAAY,+BAA+B,GAAG,gCAAgC,CAAC;AAE/E,UAAU,gCAAgC;IAItC,iBAAiB,EAAE,MAAM,CAAC;IAE1B,aAAa,EAAE,MAAM,CAAC;CACzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primer-io/react-native",
3
- "version": "2.21.0",
3
+ "version": "2.21.1",
4
4
  "description": "Primer SDK for RN",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -1,5 +1,10 @@
1
1
  export type PrimerCheckoutPaymentMethodData = IPrimerCheckoutPaymentMethodData;
2
2
 
3
3
  interface IPrimerCheckoutPaymentMethodData {
4
+ /*
5
+ * @deprecated use paymentMethod field instead
6
+ */
4
7
  paymentMethodType: string;
5
- }
8
+
9
+ paymentMethod: string;
10
+ }