paynl-pos-sdk-react-native 0.0.61 → 0.0.63
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.
|
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,mm,swift}"
|
|
18
18
|
s.private_header_files = "ios/**/*.h"
|
|
19
19
|
|
|
20
|
-
s.dependency 'PayNlPOSSdkSwift', '~> 0.0.
|
|
20
|
+
s.dependency 'PayNlPOSSdkSwift', '~> 0.0.29'
|
|
21
21
|
|
|
22
22
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
23
23
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
@@ -35,7 +35,7 @@ class PayNlUtils {
|
|
|
35
35
|
val enableMifareScanning = if (params.hasKey("enableMifareScanning")) params.getBoolean("enableMifareScanning") else false
|
|
36
36
|
val enableOfflineProcessing = if (params.hasKey("enableOfflineProcessing")) params.getBoolean("enableOfflineProcessing") else false
|
|
37
37
|
val enforcePinCodeDuringOfflineProcessing = if (params.hasKey("enforcePinCodeDuringOfflineProcessing")) params.getBoolean("enforcePinCodeDuringOfflineProcessing") else false
|
|
38
|
-
val payNlCore = if (params.hasKey("payNlCore")) getCore(params.getString("payNlCore") ?: "") else PayNlCore.
|
|
38
|
+
val payNlCore = if (params.hasKey("payNlCore")) getCore(params.getString("payNlCore") ?: "") else PayNlCore.MULTI
|
|
39
39
|
|
|
40
40
|
return PayNlConfigurationBuilder()
|
|
41
41
|
.setIntegrationId(integrationId)
|
|
@@ -398,18 +398,18 @@ class PayNlUtils {
|
|
|
398
398
|
|
|
399
399
|
private fun getCore(value: String): PayNlCore {
|
|
400
400
|
if (value.isEmpty()) {
|
|
401
|
-
return PayNlCore.
|
|
401
|
+
return PayNlCore.MULTI
|
|
402
402
|
}
|
|
403
403
|
|
|
404
|
-
if (value == "
|
|
405
|
-
return PayNlCore.
|
|
404
|
+
if (value == "CPOC") {
|
|
405
|
+
return PayNlCore.CPOC
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
if (value == "ZERO") {
|
|
409
409
|
return PayNlCore.ZERO
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
return PayNlCore.
|
|
412
|
+
return PayNlCore.MULTI
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
415
|
}
|
|
@@ -1,219 +1,212 @@
|
|
|
1
|
-
//
|
|
2
|
-
// PayNlPosService.swift
|
|
3
|
-
// Pods
|
|
4
|
-
//
|
|
5
|
-
// Created by Bastiaan Verhaar on 18/03/2025.
|
|
6
|
-
//
|
|
7
|
-
|
|
8
1
|
import React
|
|
9
2
|
import PayNlPOSSdkSwift
|
|
10
3
|
|
|
11
|
-
@available(iOS
|
|
4
|
+
@available(iOS 17, *)
|
|
12
5
|
@objc public class PayNlPosService : NSObject {
|
|
13
|
-
|
|
6
|
+
@objc public static let instance = PayNlPosService()
|
|
14
7
|
|
|
15
|
-
|
|
8
|
+
private var posService: PosService
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
override init() {
|
|
11
|
+
self.posService = PosService()
|
|
12
|
+
}
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
reject("SV-0000", "UNKNOWN ERROR", PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
37
|
-
}
|
|
14
|
+
@objc public func getActivationCode(resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
15
|
+
Task {
|
|
16
|
+
do {
|
|
17
|
+
let result = try await self.posService.getActivationCode()
|
|
18
|
+
resolve([
|
|
19
|
+
"code": result.code,
|
|
20
|
+
"expiresAt": result.expiresAt.timeIntervalSince1970
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
} catch {
|
|
24
|
+
if let error = error as? PayNlSVError {
|
|
25
|
+
reject(error.code, error.description, error)
|
|
26
|
+
return
|
|
38
27
|
}
|
|
39
|
-
}
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let result = await self.posService.initSdk(configuration: PayNlConfiguation(integrationId: integrationId, core: self.getCore(value: core)))
|
|
44
|
-
switch result {
|
|
45
|
-
case .needsLogin:
|
|
46
|
-
resolve("needs_login")
|
|
47
|
-
break
|
|
48
|
-
|
|
49
|
-
case .readyForPayment:
|
|
50
|
-
resolve("ready_for_payment")
|
|
51
|
-
break
|
|
52
|
-
|
|
53
|
-
case .failed(let error):
|
|
54
|
-
reject(error.code, error.description, error)
|
|
55
|
-
break
|
|
56
|
-
|
|
57
|
-
@unknown default:
|
|
58
|
-
reject("SV-0000", "UNKNOWN ERROR", PayNlSVError.UNEXPECTED_ERROR(reason: "UNKNOWN ERROR"))
|
|
59
|
-
break
|
|
60
|
-
}
|
|
61
|
-
}
|
|
29
|
+
reject("SV-0000", "getActivationCode - UNKNOWN ERROR: " + error.localizedDescription, PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
30
|
+
}
|
|
62
31
|
}
|
|
32
|
+
}
|
|
63
33
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
34
|
+
@objc public func initSdk(integrationId: String, core: String, resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
35
|
+
Task {
|
|
36
|
+
let result = await self.posService.initSdk(configuration: PayNlConfiguation(integrationId: integrationId, core: self.getCore(value: core)))
|
|
37
|
+
switch result {
|
|
38
|
+
case .needsLogin:
|
|
39
|
+
resolve("needs_login")
|
|
40
|
+
break
|
|
41
|
+
|
|
42
|
+
case .readyForPayment:
|
|
43
|
+
resolve("ready_for_payment")
|
|
44
|
+
break
|
|
45
|
+
|
|
46
|
+
case .failed(let error):
|
|
47
|
+
reject(error.code, error.description, error)
|
|
48
|
+
break
|
|
49
|
+
|
|
50
|
+
@unknown default:
|
|
51
|
+
reject("SV-0000", "initSdk - UNKNOWN ERROR", PayNlSVError.UNEXPECTED_ERROR(reason: "UNKNOWN ERROR"))
|
|
52
|
+
break
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
69
56
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
57
|
+
@objc public func loginViaCredentials(aCode: String, serviceCode: String, serviceSecret: String, resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
58
|
+
Task {
|
|
59
|
+
do {
|
|
60
|
+
try await self.posService.loginViaCredentials(aCode: aCode, serviceCode: serviceCode, serviceSecret: serviceSecret)
|
|
61
|
+
resolve(nil)
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
} catch {
|
|
64
|
+
if let error = error as? PayNlSVError {
|
|
65
|
+
reject(error.code, error.description, error)
|
|
66
|
+
return
|
|
78
67
|
}
|
|
68
|
+
|
|
69
|
+
reject("SV-0000", "loginViaCredentials - UNKNOWN ERROR: " + error.localizedDescription, PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
70
|
+
}
|
|
79
71
|
}
|
|
72
|
+
}
|
|
80
73
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
reject("SV-0000", "UNKNOWN ERROR", PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
93
|
-
}
|
|
74
|
+
@objc public func loginViaCode(pin: String, resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
75
|
+
Task {
|
|
76
|
+
do {
|
|
77
|
+
try await self.posService.loginViaCode(pin: pin)
|
|
78
|
+
resolve(nil)
|
|
79
|
+
} catch {
|
|
80
|
+
if let error = error as? PayNlSVError {
|
|
81
|
+
reject(error.code, error.description, error)
|
|
82
|
+
return
|
|
94
83
|
}
|
|
84
|
+
|
|
85
|
+
reject("SV-0000", "loginViaCode - UNKNOWN ERROR: " + error.localizedDescription, PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
86
|
+
}
|
|
95
87
|
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@objc public func startPayment(transactionJson: NSDictionary, serviceJson: NSDictionary?, resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
91
|
+
Task {
|
|
92
|
+
do {
|
|
93
|
+
let transaction = try JSONDecoder().decode(PayNlTransaction.self, from: JSONSerialization.data(withJSONObject: transactionJson))
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
let transaction = try JSONDecoder().decode(PayNlTransaction.self, from: JSONSerialization.data(withJSONObject: transactionJson))
|
|
101
|
-
|
|
102
|
-
var service: PayNlTransactionService? = nil
|
|
103
|
-
if let serviceJson = serviceJson {
|
|
104
|
-
service = try JSONDecoder().decode(PayNlTransactionService.self, from: JSONSerialization.data(withJSONObject: serviceJson))
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
let result = try await self.posService.startPayment(transaction: transaction, service: service)
|
|
108
|
-
resolve([
|
|
109
|
-
"statusAction": result.statusAction.rawValue,
|
|
110
|
-
"transactionId": result.transactionId,
|
|
111
|
-
"payerMessage": result.payerMessage,
|
|
112
|
-
"orderId": result.orderId,
|
|
113
|
-
"reference": result.reference,
|
|
114
|
-
"ticket": result.ticket
|
|
115
|
-
])
|
|
116
|
-
|
|
117
|
-
} catch {
|
|
118
|
-
if let error = error as? PayNlSVError {
|
|
119
|
-
reject(error.code, error.description, error)
|
|
120
|
-
return
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
reject("SV-0000", "UNKNOWN ERROR", PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
124
|
-
}
|
|
95
|
+
var service: PayNlTransactionService? = nil
|
|
96
|
+
if let serviceJson = serviceJson {
|
|
97
|
+
service = try JSONDecoder().decode(PayNlTransactionService.self, from: JSONSerialization.data(withJSONObject: serviceJson))
|
|
125
98
|
}
|
|
126
|
-
}
|
|
127
99
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
100
|
+
let result = try await self.posService.startPayment(transaction: transaction, service: service)
|
|
101
|
+
resolve([
|
|
102
|
+
"statusAction": result.statusAction.rawValue,
|
|
103
|
+
"transactionId": result.transactionId,
|
|
104
|
+
"payerMessage": result.payerMessage,
|
|
105
|
+
"orderId": result.orderId,
|
|
106
|
+
"reference": result.reference,
|
|
107
|
+
"ticket": result.ticket
|
|
108
|
+
])
|
|
109
|
+
|
|
110
|
+
} catch {
|
|
111
|
+
if let error = error as? PayNlSVError {
|
|
112
|
+
reject(error.code, error.description, error)
|
|
113
|
+
return
|
|
132
114
|
}
|
|
133
115
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
"service": [
|
|
144
|
-
"code": info.service.code,
|
|
145
|
-
"name": info.service.name
|
|
146
|
-
],
|
|
147
|
-
"tradeName": [
|
|
148
|
-
"code": info.tradeName.code,
|
|
149
|
-
"name": info.tradeName.name
|
|
150
|
-
]
|
|
151
|
-
]
|
|
116
|
+
reject("SV-0000", "startPayment - UNKNOWN ERROR: " + error.localizedDescription, PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@objc public func getTerminalInfo() -> NSDictionary? {
|
|
122
|
+
let info = self.posService.getTerminalInfo()
|
|
123
|
+
guard let info = info else {
|
|
124
|
+
return nil
|
|
152
125
|
}
|
|
153
126
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
127
|
+
return [
|
|
128
|
+
"terminal": [
|
|
129
|
+
"code": info.terminal.code,
|
|
130
|
+
"name": info.terminal.name
|
|
131
|
+
],
|
|
132
|
+
"merchant": [
|
|
133
|
+
"code": info.merchant.code,
|
|
134
|
+
"name": info.merchant.name
|
|
135
|
+
],
|
|
136
|
+
"service": [
|
|
137
|
+
"code": info.service.code,
|
|
138
|
+
"name": info.service.name
|
|
139
|
+
],
|
|
140
|
+
"tradeName": [
|
|
141
|
+
"code": info.tradeName.code,
|
|
142
|
+
"name": info.tradeName.name
|
|
143
|
+
]
|
|
144
|
+
]
|
|
145
|
+
}
|
|
159
146
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
"sign": currency.sign
|
|
165
|
-
]
|
|
166
|
-
} as NSArray
|
|
147
|
+
@objc public func getAllowedCurrencies() -> NSArray? {
|
|
148
|
+
let currencies = self.posService.getAllowedCurrencies()
|
|
149
|
+
guard let currencies = currencies else {
|
|
150
|
+
return nil
|
|
167
151
|
}
|
|
168
152
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
153
|
+
return currencies.map { currency in
|
|
154
|
+
return [
|
|
155
|
+
"id": currency.id,
|
|
156
|
+
"code": currency.code,
|
|
157
|
+
"sign": currency.sign
|
|
158
|
+
]
|
|
159
|
+
} as NSArray
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@objc public func sendTicket(email: String, transactionId: String, ticket: String, resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
163
|
+
Task {
|
|
164
|
+
do {
|
|
165
|
+
try await self.posService.sendTicket(email: email, transactionId: transactionId, ticket: ticket)
|
|
166
|
+
resolve(nil)
|
|
167
|
+
} catch {
|
|
168
|
+
if let error = error as? PayNlSVError {
|
|
169
|
+
reject(error.code, error.description, error)
|
|
170
|
+
return
|
|
182
171
|
}
|
|
183
|
-
}
|
|
184
172
|
|
|
185
|
-
|
|
186
|
-
|
|
173
|
+
reject("SV-0000", "sendTicket - UNKNOWN ERROR: " + error.localizedDescription, PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
174
|
+
}
|
|
187
175
|
}
|
|
176
|
+
}
|
|
188
177
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
178
|
+
@objc public func logout() {
|
|
179
|
+
self.posService.logout()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
@objc public func sendLogs(resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
|
|
183
|
+
Task {
|
|
184
|
+
do {
|
|
185
|
+
try await self.posService.sendLogs()
|
|
186
|
+
resolve(nil)
|
|
187
|
+
} catch {
|
|
188
|
+
if let error = error as? PayNlSVError {
|
|
189
|
+
reject(error.code, error.description, error)
|
|
190
|
+
return
|
|
202
191
|
}
|
|
192
|
+
|
|
193
|
+
reject("SV-0000", "sendLogs - UNKNOWN ERROR: " + error.localizedDescription, PayNlSVError.UNEXPECTED_ERROR(reason: error.localizedDescription))
|
|
194
|
+
}
|
|
203
195
|
}
|
|
196
|
+
}
|
|
204
197
|
|
|
205
198
|
@objc public func setConfiguration(integrationId: String, core: String) {
|
|
206
199
|
self.posService.setConfiguration(configuration: PayNlConfiguation(integrationId: integrationId, core: self.getCore(value: core)))
|
|
207
200
|
}
|
|
208
201
|
|
|
209
202
|
private func getCore(value: String?) -> PayNlPOSSdkSwift.PayNlCore {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
203
|
+
switch value {
|
|
204
|
+
case "ZERO":
|
|
205
|
+
return PayNlCore.ZERO
|
|
206
|
+
case "CPOC":
|
|
207
|
+
return PayNlCore.CPOC
|
|
208
|
+
default:
|
|
209
|
+
return PayNlCore.MULTI
|
|
210
|
+
}
|
|
211
|
+
}
|
|
219
212
|
}
|