@litepos/payment 1.0.16 → 1.0.19
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/dist/client.d.ts +3 -3
- package/dist/client.js +118 -190
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/sqb.d.ts +1 -0
- package/dist/sqb.js +1 -0
- package/package.json +8 -2
- package/dist/simulator.d.ts +0 -7
- package/dist/simulator.js +0 -30
package/dist/client.d.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse, V
|
|
|
2
2
|
import { PaymentStatus } from './types/status';
|
|
3
3
|
export declare function validateConfig(method: string, config: unknown): void;
|
|
4
4
|
export declare class LitePosPayment {
|
|
5
|
+
private getRoute;
|
|
5
6
|
charge(request: PaymentRequest): Promise<PaymentResponse>;
|
|
6
7
|
queryPayment(method: string, transactionId: string, config: Record<string, unknown>): Promise<PaymentResponse>;
|
|
7
8
|
cancelPayment(method: string, transactionId: string, config: Record<string, unknown>): Promise<CancelResponse>;
|
|
8
|
-
refund(method: string, transactionId: string, config: Record<string, unknown>, amount?: number): Promise<RefundResponse>;
|
|
9
|
+
refund(method: string, transactionId: string, config: Record<string, unknown>, amount?: number, refundRequestNo?: string): Promise<RefundResponse>;
|
|
9
10
|
voidPayment(method: string, transactionId: string, config: Record<string, unknown>): Promise<VoidResponse>;
|
|
10
11
|
queryRefund(method: string, refundId: string, config: Record<string, unknown>): Promise<RefundResponse>;
|
|
11
12
|
simulateCharge(request: PaymentRequest): PaymentResponse;
|
|
12
|
-
simulateQuery(transactionId: string, status: PaymentStatus, amount?: number, currency?: string): PaymentResponse;
|
|
13
|
-
private getGatewayName;
|
|
13
|
+
simulateQuery(method: string, transactionId: string, status: PaymentStatus, amount?: number, currency?: string): PaymentResponse;
|
|
14
14
|
}
|
package/dist/client.js
CHANGED
|
@@ -1,248 +1,176 @@
|
|
|
1
|
-
import { cancelPayment as cancelFiuuPayment, chargeCard, chargeQrCode, queryPayment, refund, validateConfig as validateFiuuConfig, voidPayment as voidFiuuPayment } from '@litepos/payment-fiuu';
|
|
1
|
+
import { cancelPayment as cancelFiuuPayment, chargeCard, chargeQrCode, simulateCharge as fiuuSimulateCharge, simulateQuery as fiuuSimulateQuery, queryPayment, refund, validateConfig as validateFiuuConfig, voidPayment as voidFiuuPayment, } from '@litepos/payment-fiuu';
|
|
2
|
+
import { cancelPayment as sqbCancelPayment,
|
|
3
|
+
// chargeAlipay as sqbChargeAlipay, // ALPH disabled
|
|
4
|
+
chargeCard as sqbChargeCard,
|
|
5
|
+
// chargeWechat as sqbChargeWechat, // WCPH disabled
|
|
6
|
+
queryPayment as sqbQueryPayment, refund as sqbRefund, simulateCharge as sqbSimulateCharge, simulateQuery as sqbSimulateQuery, validateConfig as validateSqbConfig, } from '@litepos/payment-shouqianba';
|
|
2
7
|
import { ValidationError } from './types/error';
|
|
3
|
-
import { PaymentStatus } from './types/status';
|
|
8
|
+
import { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
|
|
4
9
|
import { logError, logInfo } from './utils/logger';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
10
|
+
const ROUTING = {
|
|
11
|
+
'FIUU': {
|
|
12
|
+
charge: chargeCard,
|
|
13
|
+
query: queryPayment,
|
|
14
|
+
refund: refund,
|
|
15
|
+
refundQuery: queryPayment,
|
|
16
|
+
cancel: cancelFiuuPayment,
|
|
17
|
+
void: voidFiuuPayment,
|
|
18
|
+
simulateCharge: fiuuSimulateCharge,
|
|
19
|
+
simulateQuery: fiuuSimulateQuery,
|
|
20
|
+
validate: validateFiuuConfig,
|
|
21
|
+
name: 'Fiuu',
|
|
22
|
+
},
|
|
23
|
+
'fiuu-qrcode': {
|
|
24
|
+
charge: chargeQrCode,
|
|
25
|
+
query: queryPayment,
|
|
26
|
+
refund: refund,
|
|
27
|
+
refundQuery: queryPayment,
|
|
28
|
+
cancel: cancelFiuuPayment,
|
|
29
|
+
void: voidFiuuPayment,
|
|
30
|
+
simulateCharge: fiuuSimulateCharge,
|
|
31
|
+
simulateQuery: fiuuSimulateQuery,
|
|
32
|
+
validate: validateFiuuConfig,
|
|
33
|
+
name: 'Fiuu',
|
|
34
|
+
},
|
|
35
|
+
'SQBP': {
|
|
36
|
+
charge: sqbChargeCard,
|
|
37
|
+
query: sqbQueryPayment,
|
|
38
|
+
refund: sqbRefund,
|
|
39
|
+
refundQuery: sqbQueryPayment,
|
|
40
|
+
cancel: sqbCancelPayment,
|
|
41
|
+
simulateCharge: sqbSimulateCharge,
|
|
42
|
+
simulateQuery: (txId, s, a, c) => sqbSimulateQuery(txId, s, a, c, 'SQBP'),
|
|
43
|
+
validate: validateSqbConfig,
|
|
44
|
+
name: 'Shouqianba',
|
|
45
|
+
},
|
|
46
|
+
// 'WCPH': { charge: sqbChargeWechat, ... }, // WeChat Pay C扫B - disabled
|
|
47
|
+
// 'ALPH': { charge: sqbChargeAlipay, ... }, // Alipay C扫B - disabled
|
|
9
48
|
};
|
|
10
|
-
const QUERY_ROUTING = {
|
|
11
|
-
'FIUU': queryPayment,
|
|
12
|
-
'fiuu-qrcode': queryPayment,
|
|
13
|
-
};
|
|
14
|
-
const REFUND_ROUTING = {
|
|
15
|
-
'FIUU': refund,
|
|
16
|
-
'fiuu-qrcode': refund,
|
|
17
|
-
};
|
|
18
|
-
const REFUND_QUERY_ROUTING = {
|
|
19
|
-
'FIUU': queryPayment,
|
|
20
|
-
'fiuu-qrcode': queryPayment,
|
|
21
|
-
};
|
|
22
|
-
const CANCEL_ROUTING = {
|
|
23
|
-
'FIUU': cancelFiuuPayment,
|
|
24
|
-
'fiuu-qrcode': cancelFiuuPayment,
|
|
25
|
-
};
|
|
26
|
-
const VOID_ROUTING = {
|
|
27
|
-
'FIUU': voidFiuuPayment,
|
|
28
|
-
'fiuu-qrcode': voidFiuuPayment,
|
|
29
|
-
};
|
|
30
|
-
// Config validation routing
|
|
31
|
-
const VALIDATE_ROUTING = {
|
|
32
|
-
'FIUU': validateFiuuConfig,
|
|
33
|
-
'fiuu-qrcode': validateFiuuConfig,
|
|
34
|
-
};
|
|
35
|
-
// Validate payment method configuration
|
|
36
49
|
export function validateConfig(method, config) {
|
|
37
|
-
const
|
|
38
|
-
if (!
|
|
50
|
+
const route = ROUTING[method];
|
|
51
|
+
if (!route)
|
|
39
52
|
throw new ValidationError(`Payment method not supported: ${method}`, method);
|
|
40
|
-
|
|
53
|
+
route.validate(config);
|
|
41
54
|
}
|
|
42
55
|
export class LitePosPayment {
|
|
56
|
+
getRoute(method) {
|
|
57
|
+
const route = ROUTING[method];
|
|
58
|
+
if (!route)
|
|
59
|
+
throw new ValidationError(`Payment method not supported: ${method}`, method);
|
|
60
|
+
return route;
|
|
61
|
+
}
|
|
43
62
|
async charge(request) {
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
46
|
-
throw new ValidationError(`
|
|
63
|
+
const route = this.getRoute(request.method);
|
|
64
|
+
if (!route.charge)
|
|
65
|
+
throw new ValidationError(`Charge not supported for method: ${request.method}`, request.method);
|
|
47
66
|
try {
|
|
48
|
-
const response = await
|
|
49
|
-
|
|
67
|
+
const response = await route.charge(request);
|
|
68
|
+
if (response.status === PaymentStatus.Failed)
|
|
69
|
+
logError(`${route.name}: Charge payment failed, Order ID ${request.orderId}`, { request, response });
|
|
70
|
+
else
|
|
71
|
+
logInfo(`${route.name}: Charge payment, Order ID ${request.orderId}, Transaction ID ${response.transactionId}, Status ${response.status}`, { request, response });
|
|
50
72
|
return response;
|
|
51
73
|
}
|
|
52
74
|
catch (error) {
|
|
53
|
-
logError(`${
|
|
75
|
+
logError(`${route.name}: Charge payment error, Order ID ${request.orderId}`, { request, error });
|
|
54
76
|
throw error;
|
|
55
77
|
}
|
|
56
78
|
}
|
|
57
79
|
async queryPayment(method, transactionId, config) {
|
|
58
|
-
const
|
|
59
|
-
if (!
|
|
60
|
-
throw new ValidationError(`
|
|
80
|
+
const route = this.getRoute(method);
|
|
81
|
+
if (!route.query)
|
|
82
|
+
throw new ValidationError(`Query not supported for method: ${method}`, method);
|
|
61
83
|
try {
|
|
62
|
-
const response = await
|
|
63
|
-
|
|
84
|
+
const response = await route.query(transactionId, config);
|
|
85
|
+
if (response.status === PaymentStatus.Failed)
|
|
86
|
+
logError(`${route.name}: Query payment - payment failed, Transaction ID ${transactionId}`, { transactionId, response });
|
|
87
|
+
else
|
|
88
|
+
logInfo(`${route.name}: Query payment, Transaction ID ${transactionId}, Status ${response.status}`, { transactionId, response });
|
|
64
89
|
return response;
|
|
65
90
|
}
|
|
66
91
|
catch (error) {
|
|
67
|
-
logError(`${
|
|
92
|
+
logError(`${route.name}: Query payment error, Transaction ID ${transactionId}`, { transactionId, error });
|
|
68
93
|
throw error;
|
|
69
94
|
}
|
|
70
95
|
}
|
|
71
96
|
async cancelPayment(method, transactionId, config) {
|
|
72
|
-
const
|
|
73
|
-
if (!
|
|
74
|
-
throw new ValidationError(`
|
|
97
|
+
const route = this.getRoute(method);
|
|
98
|
+
if (!route.cancel)
|
|
99
|
+
throw new ValidationError(`Cancel not supported for method: ${method}`, method);
|
|
75
100
|
try {
|
|
76
|
-
const response = await
|
|
77
|
-
|
|
101
|
+
const response = await route.cancel(transactionId, config);
|
|
102
|
+
if (response.status === CancelStatus.Failed)
|
|
103
|
+
logError(`${route.name}: Cancel payment failed, Transaction ID ${transactionId}`, { transactionId, response });
|
|
104
|
+
else
|
|
105
|
+
logInfo(`${route.name}: Cancel payment, Transaction ID ${transactionId}, Status ${response.status}`, { transactionId, response });
|
|
78
106
|
return response;
|
|
79
107
|
}
|
|
80
108
|
catch (error) {
|
|
81
|
-
logError(`${
|
|
109
|
+
logError(`${route.name}: Cancel payment error, Transaction ID ${transactionId}`, { transactionId, error });
|
|
82
110
|
throw error;
|
|
83
111
|
}
|
|
84
112
|
}
|
|
85
|
-
async refund(method, transactionId, config, amount) {
|
|
86
|
-
const
|
|
87
|
-
if (!
|
|
88
|
-
throw new ValidationError(`
|
|
113
|
+
async refund(method, transactionId, config, amount, refundRequestNo) {
|
|
114
|
+
const route = this.getRoute(method);
|
|
115
|
+
if (!route.refund)
|
|
116
|
+
throw new ValidationError(`Refund not supported for method: ${method}`, method);
|
|
89
117
|
try {
|
|
90
|
-
const response = await
|
|
91
|
-
|
|
118
|
+
const response = await route.refund(transactionId, config, amount, refundRequestNo);
|
|
119
|
+
if (response.status === RefundStatus.Failed)
|
|
120
|
+
logError(`${route.name}: Refund failed, Transaction ID ${transactionId}`, { transactionId, amount, response });
|
|
121
|
+
else
|
|
122
|
+
logInfo(`${route.name}: Refund payment, Transaction ID ${transactionId}, Refund ID ${response.refundId}, Status ${response.status}`, { transactionId, amount, response });
|
|
92
123
|
return response;
|
|
93
124
|
}
|
|
94
125
|
catch (error) {
|
|
95
|
-
logError(`${
|
|
126
|
+
logError(`${route.name}: Refund error, Transaction ID ${transactionId}`, { transactionId, amount, error });
|
|
96
127
|
throw error;
|
|
97
128
|
}
|
|
98
129
|
}
|
|
99
130
|
async voidPayment(method, transactionId, config) {
|
|
100
|
-
const
|
|
101
|
-
if (!
|
|
102
|
-
throw new ValidationError(`
|
|
131
|
+
const route = this.getRoute(method);
|
|
132
|
+
if (!route.void)
|
|
133
|
+
throw new ValidationError(`Void not supported for method: ${method}`, method);
|
|
103
134
|
try {
|
|
104
|
-
const response = await
|
|
105
|
-
|
|
135
|
+
const response = await route.void(transactionId, config);
|
|
136
|
+
if (response.status === VoidStatus.Failed)
|
|
137
|
+
logError(`${route.name}: Void failed, Transaction ID ${transactionId}`, { transactionId, response });
|
|
138
|
+
else
|
|
139
|
+
logInfo(`${route.name}: Void payment, Transaction ID ${transactionId}, Void ID ${response.voidId}, Status ${response.status}`, { transactionId, response });
|
|
106
140
|
return response;
|
|
107
141
|
}
|
|
108
142
|
catch (error) {
|
|
109
|
-
logError(`${
|
|
143
|
+
logError(`${route.name}: Void error, Transaction ID ${transactionId}`, { transactionId, error });
|
|
110
144
|
throw error;
|
|
111
145
|
}
|
|
112
146
|
}
|
|
113
147
|
async queryRefund(method, refundId, config) {
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
116
|
-
throw new ValidationError(`
|
|
148
|
+
const route = this.getRoute(method);
|
|
149
|
+
if (!route.refundQuery)
|
|
150
|
+
throw new ValidationError(`Refund query not supported for method: ${method}`, method);
|
|
117
151
|
try {
|
|
118
|
-
const response = await
|
|
119
|
-
|
|
152
|
+
const response = await route.refundQuery(refundId, config);
|
|
153
|
+
if (response.status === RefundStatus.Failed)
|
|
154
|
+
logError(`${route.name}: Query refund failed, Refund ID ${refundId}`, { refundId, response });
|
|
155
|
+
else
|
|
156
|
+
logInfo(`${route.name}: Query refund, Refund ID ${refundId}, Status ${response.status}`, { refundId, response });
|
|
120
157
|
return response;
|
|
121
158
|
}
|
|
122
159
|
catch (error) {
|
|
123
|
-
logError(`${
|
|
160
|
+
logError(`${route.name}: Query refund error, Refund ID ${refundId}`, { refundId, error });
|
|
124
161
|
throw error;
|
|
125
162
|
}
|
|
126
163
|
}
|
|
127
|
-
// Simulation methods (for testing, returns mock data without calling adapters)
|
|
128
164
|
simulateCharge(request) {
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
const cardNo = isQrCode ? '' : '************2066';
|
|
134
|
-
const now = new Date();
|
|
135
|
-
const invNo = now.toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
136
|
-
return {
|
|
137
|
-
transactionId,
|
|
138
|
-
status: PaymentStatus.Pending,
|
|
139
|
-
amount: request.amount,
|
|
140
|
-
currency: request.currency,
|
|
141
|
-
qrCodeData: isQrCode ? `QR_${request.orderId}` : undefined,
|
|
142
|
-
payment_source_method: cardLabel || paymentChannel,
|
|
143
|
-
payment_source_last4: isQrCode ? '' : '2066',
|
|
144
|
-
payment_source_charge_ref: transactionId,
|
|
145
|
-
metadata: {
|
|
146
|
-
responseCode: '00',
|
|
147
|
-
responseText: 'Approved',
|
|
148
|
-
paymentChannel,
|
|
149
|
-
invNo,
|
|
150
|
-
tid: '00000001',
|
|
151
|
-
mid: '000000000000001',
|
|
152
|
-
cardNo,
|
|
153
|
-
entryMode: 'contactless',
|
|
154
|
-
cardLabel,
|
|
155
|
-
},
|
|
156
|
-
raw: {
|
|
157
|
-
transType: 'sale',
|
|
158
|
-
posId: 'SIM_POS_ID',
|
|
159
|
-
deviceId: 'SIM_DEVICE_ID',
|
|
160
|
-
referenceLabel: request.orderId.slice(0, 10),
|
|
161
|
-
apiVersion: 'v1',
|
|
162
|
-
statusCode: '00',
|
|
163
|
-
responseCode: '00',
|
|
164
|
-
responseText: 'Approved',
|
|
165
|
-
terminalSn: 'SIM_TERMINAL',
|
|
166
|
-
softwareVersion: 'Version 1.0.0',
|
|
167
|
-
transData: {
|
|
168
|
-
cardNo,
|
|
169
|
-
entryMode: 'contactless',
|
|
170
|
-
rrn: '000000000001',
|
|
171
|
-
tvr: '0000008001',
|
|
172
|
-
appCrypt: 'simulated',
|
|
173
|
-
aid: 'A0000000041010',
|
|
174
|
-
cvmType: '00',
|
|
175
|
-
cardLabel,
|
|
176
|
-
paymentChannel,
|
|
177
|
-
transAmt: request.amount.toFixed(2),
|
|
178
|
-
transDateTime: now.toISOString().slice(0, 19),
|
|
179
|
-
transId: transactionId,
|
|
180
|
-
invNo,
|
|
181
|
-
batchNo: '',
|
|
182
|
-
tid: '00000001',
|
|
183
|
-
mid: '000000000000001',
|
|
184
|
-
currency: request.currency,
|
|
185
|
-
apprCode: '000001',
|
|
186
|
-
},
|
|
187
|
-
referenceId: `SIM-${Date.now()}`,
|
|
188
|
-
signature: 'simulated',
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
simulateQuery(transactionId, status, amount = 0, currency = 'SGD') {
|
|
193
|
-
const now = new Date();
|
|
194
|
-
const invNo = now.toISOString().replace(/[-:T]/g, '').slice(0, 14);
|
|
195
|
-
return {
|
|
196
|
-
transactionId,
|
|
197
|
-
status,
|
|
198
|
-
amount,
|
|
199
|
-
currency,
|
|
200
|
-
payment_source_method: 'Mastercard',
|
|
201
|
-
payment_source_last4: '2066',
|
|
202
|
-
payment_source_charge_ref: transactionId,
|
|
203
|
-
metadata: {
|
|
204
|
-
responseCode: '00',
|
|
205
|
-
responseText: 'Approved',
|
|
206
|
-
paymentChannel: 'Mastercard',
|
|
207
|
-
invNo,
|
|
208
|
-
tid: '00000001',
|
|
209
|
-
mid: '000000000000001',
|
|
210
|
-
cardNo: '************2066',
|
|
211
|
-
entryMode: 'contactless',
|
|
212
|
-
cardLabel: 'Mastercard',
|
|
213
|
-
},
|
|
214
|
-
raw: {
|
|
215
|
-
transType: 'sale',
|
|
216
|
-
posId: 'SIM_POS_ID',
|
|
217
|
-
deviceId: 'SIM_DEVICE_ID',
|
|
218
|
-
apiVersion: 'v1',
|
|
219
|
-
statusCode: '00',
|
|
220
|
-
responseCode: '00',
|
|
221
|
-
responseText: 'Approved',
|
|
222
|
-
terminalSn: 'SIM_TERMINAL',
|
|
223
|
-
softwareVersion: 'Version 1.0.0',
|
|
224
|
-
transData: {
|
|
225
|
-
cardNo: '************2066',
|
|
226
|
-
entryMode: 'contactless',
|
|
227
|
-
rrn: '000000000001',
|
|
228
|
-
cardLabel: 'Mastercard',
|
|
229
|
-
paymentChannel: 'Mastercard',
|
|
230
|
-
transAmt: amount.toFixed(2),
|
|
231
|
-
transDateTime: now.toISOString().slice(0, 19),
|
|
232
|
-
transId: transactionId,
|
|
233
|
-
invNo,
|
|
234
|
-
tid: '00000001',
|
|
235
|
-
mid: '000000000000001',
|
|
236
|
-
currency,
|
|
237
|
-
},
|
|
238
|
-
referenceId: `SIM-${Date.now()}`,
|
|
239
|
-
signature: 'simulated',
|
|
240
|
-
},
|
|
241
|
-
};
|
|
165
|
+
const route = this.getRoute(request.method);
|
|
166
|
+
if (!route.simulateCharge)
|
|
167
|
+
throw new ValidationError(`Simulate charge not supported for method: ${request.method}`, request.method);
|
|
168
|
+
return route.simulateCharge(request);
|
|
242
169
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
170
|
+
simulateQuery(method, transactionId, status, amount = 0, currency = 'SGD') {
|
|
171
|
+
const route = this.getRoute(method);
|
|
172
|
+
if (!route.simulateQuery)
|
|
173
|
+
throw new ValidationError(`Simulate query not supported for method: ${method}`, method);
|
|
174
|
+
return route.simulateQuery(transactionId, status, amount, currency);
|
|
247
175
|
}
|
|
248
176
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { LitePosPayment, validateConfig } from './client';
|
|
2
2
|
export { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse, ValidationResult, VoidResponse, } from './interfaces';
|
|
3
|
-
export { Simulator } from './simulator';
|
|
4
3
|
export type { PaymentConfig } from './types/config';
|
|
5
4
|
export { PaymentError, ValidationError } from './types/error';
|
|
6
5
|
export { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Main exports
|
|
2
2
|
export { LitePosPayment, validateConfig } from './client';
|
|
3
|
-
export { Simulator } from './simulator';
|
|
4
3
|
export { PaymentError, ValidationError } from './types/error';
|
|
5
4
|
// Type exports
|
|
6
5
|
export { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
|
package/dist/sqb.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sqbCheckin } from '@litepos/payment-shouqianba/tools';
|
package/dist/sqb.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { sqbCheckin } from '@litepos/payment-shouqianba/tools';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@litepos/payment",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.19",
|
|
5
5
|
"description": "LitePOS payment gateway SDK - Core package",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"import": "./dist/index.js",
|
|
18
18
|
"default": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./sqb": {
|
|
21
|
+
"types": "./dist/sqb.d.ts",
|
|
22
|
+
"import": "./dist/sqb.js",
|
|
23
|
+
"default": "./dist/sqb.js"
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"main": "dist/index.js",
|
|
@@ -25,7 +30,8 @@
|
|
|
25
30
|
"dist"
|
|
26
31
|
],
|
|
27
32
|
"dependencies": {
|
|
28
|
-
"@litepos/payment-fiuu": "1.0.
|
|
33
|
+
"@litepos/payment-fiuu": "1.0.19",
|
|
34
|
+
"@litepos/payment-shouqianba": "1.0.19"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
31
37
|
"typescript": "^5.9.2",
|
package/dist/simulator.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { PaymentRequest, PaymentResponse } from './interfaces';
|
|
2
|
-
import { PaymentStatus } from './types/status';
|
|
3
|
-
export declare class Simulator {
|
|
4
|
-
private generateTransactionId;
|
|
5
|
-
simulateCharge(request: PaymentRequest): PaymentResponse;
|
|
6
|
-
simulateQuery(transactionId: string, status: PaymentStatus): PaymentResponse;
|
|
7
|
-
}
|
package/dist/simulator.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { PaymentStatus } from './types/status';
|
|
2
|
-
// Payment simulator for testing
|
|
3
|
-
export class Simulator {
|
|
4
|
-
// Generate transaction ID
|
|
5
|
-
generateTransactionId() {
|
|
6
|
-
return `txn_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
7
|
-
}
|
|
8
|
-
// Simulate charge payment
|
|
9
|
-
simulateCharge(request) {
|
|
10
|
-
return {
|
|
11
|
-
transactionId: this.generateTransactionId(),
|
|
12
|
-
status: PaymentStatus.Pending,
|
|
13
|
-
amount: request.amount,
|
|
14
|
-
currency: request.currency,
|
|
15
|
-
qrCodeData: request.method.includes('qrcode') ? `QR_${request.orderId}` : undefined,
|
|
16
|
-
metadata: request.metadata,
|
|
17
|
-
raw: { simulated: true, request },
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
// Simulate query payment
|
|
21
|
-
simulateQuery(transactionId, status) {
|
|
22
|
-
return {
|
|
23
|
-
transactionId,
|
|
24
|
-
status,
|
|
25
|
-
amount: 0,
|
|
26
|
-
currency: 'MYR',
|
|
27
|
-
raw: { simulated: true },
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|