react-native-tpay 1.3.12 → 1.3.14
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/ios/Source/Configuration/TransactionConfiguration.swift +33 -32
- package/ios/Source/Model/Domain/BankPayment.swift +0 -1
- package/ios/Source/Model/Domain/BlikPayment.swift +0 -1
- package/ios/Source/Model/Domain/CardPayment.swift +0 -1
- package/ios/Source/Model/Domain/DigitalWalletPayment.swift +0 -1
- package/ios/Source/Model/Domain/PayPoPayment.swift +0 -1
- package/ios/Source/Model/Domain/SingleTransaction.swift +11 -0
- package/ios/Source/Model/Domain/TokenisationData.swift +0 -7
- package/ios/Source/TpaySDK.swift +4 -2
- package/package.json +1 -1
- package/react-native-tpay.podspec +1 -1
|
@@ -11,27 +11,34 @@ final class TransactionConfiguration {
|
|
|
11
11
|
|
|
12
12
|
// MARK: - API
|
|
13
13
|
|
|
14
|
-
static func single(transactionConfiguration: String) ->
|
|
15
|
-
guard let
|
|
16
|
-
let singleTransaction = try? JSONDecoder().decode(T.SingleTransaction.self, from:
|
|
14
|
+
static func single(transactionConfiguration: String) -> SingleTransaction? {
|
|
15
|
+
guard let transactionData = transactionConfiguration.data(using: .utf8),
|
|
16
|
+
let singleTransaction = try? JSONDecoder().decode(T.SingleTransaction.self, from: transactionData) else {
|
|
17
17
|
return nil
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
|
|
20
21
|
let payerContext = makeTransactionPayerContext(from: singleTransaction)
|
|
21
|
-
let
|
|
22
|
+
let callbacks = makeCallbacksConfiguration(from: singleTransaction.notifications)
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
let baseTransaction = Tpay.SingleTransaction(amount: singleTransaction.amount, description: singleTransaction.description, hiddenDescription: singleTransaction.hiddenDescription, payerContext: payerContext)
|
|
25
|
+
let wrappedSingleTransaction = SingleTransaction(singleTransaction: baseTransaction, callbacks: callbacks)
|
|
26
|
+
return wrappedSingleTransaction;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
static func cardTokenTransaction(transactionConfiguration: String) ->
|
|
27
|
-
guard let
|
|
28
|
-
let tokenPayment = try? JSONDecoder().decode(T.TokenPayment.self, from:
|
|
29
|
+
static func cardTokenTransaction(transactionConfiguration: String) -> SingleTransaction? {
|
|
30
|
+
guard let transactionData = transactionConfiguration.data(using: .utf8),
|
|
31
|
+
let tokenPayment = try? JSONDecoder().decode(T.TokenPayment.self, from: transactionData) else {
|
|
29
32
|
return nil
|
|
30
33
|
}
|
|
34
|
+
|
|
31
35
|
let payerContext = makeTokenPayerContext(from: tokenPayment)
|
|
32
|
-
let notification = makeNotification(from: tokenPayment.notifications)
|
|
33
36
|
|
|
34
|
-
|
|
37
|
+
let callbacks = makeCallbacksConfiguration(from: tokenPayment.notifications)
|
|
38
|
+
|
|
39
|
+
let baseTransaction = Tpay.SingleTransaction(amount: tokenPayment.amount, description: tokenPayment.description, hiddenDescription: tokenPayment.hiddenDescription, payerContext: payerContext)
|
|
40
|
+
let wrappedSingleTransaction = SingleTransaction(singleTransaction: baseTransaction, callbacks: callbacks)
|
|
41
|
+
return wrappedSingleTransaction;
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
static func addCard(tokenisationConfiguration: String) -> TokenizationData? {
|
|
@@ -53,7 +60,6 @@ final class TransactionConfiguration {
|
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
let callbacks = makeCallbacksConfiguration(from: cardPayment.callbacks)
|
|
56
|
-
let notification = makeNotification(from: cardPayment.callbacks.notifications)
|
|
57
63
|
|
|
58
64
|
let card = cardPayment.creditCard.flatMap { creditCard -> Headless.Models.Card? in
|
|
59
65
|
Headless.Models.Card(number: creditCard.number, expiryDate: .init(month: creditCard.expiryDate.month, year: creditCard.expiryDate.year), securityCode: creditCard.securityCode, shouldTokenize: creditCard.config.shouldSave)
|
|
@@ -70,8 +76,7 @@ final class TransactionConfiguration {
|
|
|
70
76
|
paymentChannel: paymentChannel,
|
|
71
77
|
card: card,
|
|
72
78
|
cardToken: cardToken,
|
|
73
|
-
callbacks: callbacks
|
|
74
|
-
notification: notification
|
|
79
|
+
callbacks: callbacks
|
|
75
80
|
)
|
|
76
81
|
}
|
|
77
82
|
|
|
@@ -84,7 +89,6 @@ final class TransactionConfiguration {
|
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
let callbacks = makeCallbacksConfiguration(from: blikPayment.callbacks)
|
|
87
|
-
let notification = makeNotification(from: blikPayment.callbacks.notifications)
|
|
88
92
|
|
|
89
93
|
return .init(amount: blikPayment.paymentDetails.amount,
|
|
90
94
|
description: blikPayment.paymentDetails.description,
|
|
@@ -93,8 +97,7 @@ final class TransactionConfiguration {
|
|
|
93
97
|
token: blikPayment.code,
|
|
94
98
|
alias: blikPayment.alias?.value,
|
|
95
99
|
paymentChannel: paymentChannel,
|
|
96
|
-
callbacks: callbacks
|
|
97
|
-
notification: notification
|
|
100
|
+
callbacks: callbacks
|
|
98
101
|
)
|
|
99
102
|
}
|
|
100
103
|
|
|
@@ -110,15 +113,13 @@ final class TransactionConfiguration {
|
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
let callbacks = makeCallbacksConfiguration(from: bankPayment.callbacks)
|
|
113
|
-
let notification = makeNotification(from: bankPayment.callbacks.notifications)
|
|
114
116
|
|
|
115
117
|
return .init(amount: bankPayment.paymentDetails.amount,
|
|
116
118
|
description: bankPayment.paymentDetails.description,
|
|
117
119
|
hiddenDescription: bankPayment.paymentDetails.hiddenDescription,
|
|
118
120
|
payerContext: .init(payer: payer),
|
|
119
121
|
paymentChannel: paymentChannel,
|
|
120
|
-
callbacks: callbacks
|
|
121
|
-
notification: notification
|
|
122
|
+
callbacks: callbacks
|
|
122
123
|
)
|
|
123
124
|
}
|
|
124
125
|
|
|
@@ -131,7 +132,6 @@ final class TransactionConfiguration {
|
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
let callbacks = makeCallbacksConfiguration(from: digitalWalletPayment.callbacks)
|
|
134
|
-
let notification = makeNotification(from: digitalWalletPayment.callbacks.notifications)
|
|
135
135
|
|
|
136
136
|
return .init(amount: digitalWalletPayment.paymentDetails.amount,
|
|
137
137
|
description: digitalWalletPayment.paymentDetails.description,
|
|
@@ -139,8 +139,7 @@ final class TransactionConfiguration {
|
|
|
139
139
|
payerContext: .init(payer: payer),
|
|
140
140
|
paymentChannel: paymentChannel,
|
|
141
141
|
token: digitalWalletPayment.applePayToken,
|
|
142
|
-
callbacks: callbacks
|
|
143
|
-
notification: notification
|
|
142
|
+
callbacks: callbacks
|
|
144
143
|
)
|
|
145
144
|
}
|
|
146
145
|
|
|
@@ -153,15 +152,13 @@ final class TransactionConfiguration {
|
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
let callbacks = makeCallbacksConfiguration(from: payPoPayment.callbacks)
|
|
156
|
-
let notification = makeNotification(from: payPoPayment.callbacks.notifications)
|
|
157
155
|
|
|
158
156
|
return .init(amount: payPoPayment.paymentDetails.amount,
|
|
159
157
|
description: payPoPayment.paymentDetails.description,
|
|
160
158
|
hiddenDescription: payPoPayment.paymentDetails.hiddenDescription,
|
|
161
159
|
payerContext: .init(payer: payer),
|
|
162
160
|
paymentChannel: paymentChannel,
|
|
163
|
-
callbacks: callbacks
|
|
164
|
-
notification: notification
|
|
161
|
+
callbacks: callbacks
|
|
165
162
|
)
|
|
166
163
|
}
|
|
167
164
|
|
|
@@ -228,7 +225,17 @@ final class TransactionConfiguration {
|
|
|
228
225
|
private static func makeCallbacksConfiguration(from callbacks: T.Callbacks) -> CallbacksConfiguration {
|
|
229
226
|
return .init(successRedirectUrl: URL(string: callbacks.redirects?.successUrl ?? Defaults.successRedirectUrl.absoluteString) ?? Defaults.successRedirectUrl,
|
|
230
227
|
errorRedirectUrl: URL(string: callbacks.redirects?.errorUrl ?? Defaults.errorRedirectUrl.absoluteString) ?? Defaults.errorRedirectUrl,
|
|
231
|
-
notificationsUrl: callbacks.notifications.flatMap { URL(string: $0.url) }
|
|
228
|
+
notificationsUrl: callbacks.notifications.flatMap { URL(string: $0.url) },
|
|
229
|
+
notificationEmail: callbacks.notifications.flatMap { $0.email }
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
private static func makeCallbacksConfiguration(from notifications: T.Callbacks.Notifications?) -> CallbacksConfiguration {
|
|
234
|
+
return .init(successRedirectUrl: URL(string: Defaults.successRedirectUrl.absoluteString) ?? Defaults.successRedirectUrl,
|
|
235
|
+
errorRedirectUrl: URL(string: Defaults.errorRedirectUrl.absoluteString) ?? Defaults.errorRedirectUrl,
|
|
236
|
+
notificationsUrl: notifications.flatMap { URL(string: $0.url) },
|
|
237
|
+
notificationEmail: notifications.flatMap { $0.email }
|
|
238
|
+
)
|
|
232
239
|
}
|
|
233
240
|
|
|
234
241
|
private static func makeCardBrand(from brand: String) -> CardToken.Brand {
|
|
@@ -241,10 +248,4 @@ final class TransactionConfiguration {
|
|
|
241
248
|
return CardToken.Brand.other(brand)
|
|
242
249
|
}
|
|
243
250
|
}
|
|
244
|
-
|
|
245
|
-
private static func makeNotification(from notifications: T.Callbacks.Notifications?) -> Tpay.NotificationConfiguration? {
|
|
246
|
-
|
|
247
|
-
guard let notifications = notifications else { return nil }
|
|
248
|
-
return Tpay.NotificationConfiguration(url: URL(string: notifications.url), email: notifications.email)
|
|
249
|
-
}
|
|
250
251
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Tpay
|
|
2
|
+
|
|
3
|
+
struct SingleTransaction: Transaction {
|
|
4
|
+
let singleTransaction: Tpay.SingleTransaction
|
|
5
|
+
let callbacks: CallbacksConfiguration
|
|
6
|
+
|
|
7
|
+
var amount: Double { singleTransaction.amount }
|
|
8
|
+
var description: String { singleTransaction.description }
|
|
9
|
+
var hiddenDescription: String? { singleTransaction.hiddenDescription }
|
|
10
|
+
var payerContext: PayerContext? { singleTransaction.payerContext }
|
|
11
|
+
}
|
package/ios/Source/TpaySDK.swift
CHANGED
|
@@ -72,7 +72,8 @@ final class TpayRNModule: NSObject, RCTBridgeModule {
|
|
|
72
72
|
|
|
73
73
|
DispatchQueue.main.async { [weak self] in
|
|
74
74
|
do {
|
|
75
|
-
try
|
|
75
|
+
try TpayModule.configure(callbacks: singleTransaction.callbacks)
|
|
76
|
+
try self?.paymentPresentation.presentPayment(for: singleTransaction.singleTransaction)
|
|
76
77
|
} catch {
|
|
77
78
|
safeResolve(ConfigurationResult.configurationFailure(error: error).toJson())
|
|
78
79
|
}
|
|
@@ -89,7 +90,8 @@ final class TpayRNModule: NSObject, RCTBridgeModule {
|
|
|
89
90
|
|
|
90
91
|
DispatchQueue.main.async { [weak self] in
|
|
91
92
|
do {
|
|
92
|
-
try
|
|
93
|
+
try TpayModule.configure(callbacks: singleTransaction.callbacks)
|
|
94
|
+
try self?.tokenCardPresentation.presentPayment(for: singleTransaction.singleTransaction)
|
|
93
95
|
} catch {
|
|
94
96
|
resolve(ConfigurationResult.configurationFailure(error: error).toJson())
|
|
95
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-tpay",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.14",
|
|
4
4
|
"description": "The Tpay SDK empowers your app to seamlessly integrate Tpay’s payment functionalities, providing a comprehensive and developer-friendly solution for managing payments.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|