@litepos/payment 1.0.11 → 1.0.13

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 CHANGED
@@ -8,6 +8,6 @@ export declare class LitePosPayment {
8
8
  refund(method: string, transactionId: string, config: Record<string, unknown>, amount?: number): Promise<RefundResponse>;
9
9
  queryRefund(method: string, refundId: string, config: Record<string, unknown>): Promise<RefundResponse>;
10
10
  simulateCharge(request: PaymentRequest): PaymentResponse;
11
- simulateQuery(transactionId: string, status: PaymentStatus): PaymentResponse;
11
+ simulateQuery(transactionId: string, status: PaymentStatus, amount?: number, currency?: string): PaymentResponse;
12
12
  private getGatewayName;
13
13
  }
package/dist/client.js CHANGED
@@ -42,11 +42,11 @@ export class LitePosPayment {
42
42
  throw new ValidationError(`Payment method not supported: ${request.method}`, request.method);
43
43
  try {
44
44
  const response = await handler(request);
45
- logInfo(`${this.getGatewayName(request.method)}: Charge payment, Order ID ${request.orderId}, Transaction ID ${response.transactionId}, Status ${response.status}`);
45
+ logInfo(`${this.getGatewayName(request.method)}: Charge payment, Order ID ${request.orderId}, Transaction ID ${response.transactionId}, Status ${response.status}`, { request, response });
46
46
  return response;
47
47
  }
48
48
  catch (error) {
49
- logError(`${this.getGatewayName(request.method)}: Charge payment failed, Order ID ${request.orderId}`, error);
49
+ logError(`${this.getGatewayName(request.method)}: Charge payment failed, Order ID ${request.orderId}`, { request, error });
50
50
  throw error;
51
51
  }
52
52
  }
@@ -56,11 +56,11 @@ export class LitePosPayment {
56
56
  throw new ValidationError(`Payment method not supported: ${method}`, method);
57
57
  try {
58
58
  const response = await handler(transactionId, config);
59
- logInfo(`${this.getGatewayName(method)}: Query payment, Transaction ID ${transactionId}, Status ${response.status}`);
59
+ logInfo(`${this.getGatewayName(method)}: Query payment, Transaction ID ${transactionId}, Status ${response.status}`, { transactionId, response });
60
60
  return response;
61
61
  }
62
62
  catch (error) {
63
- logError(`${this.getGatewayName(method)}: Query payment failed, Transaction ID ${transactionId}`, error);
63
+ logError(`${this.getGatewayName(method)}: Query payment failed, Transaction ID ${transactionId}`, { transactionId, error });
64
64
  throw error;
65
65
  }
66
66
  }
@@ -70,11 +70,11 @@ export class LitePosPayment {
70
70
  throw new ValidationError(`Payment method not supported: ${method}`, method);
71
71
  try {
72
72
  const response = await handler(transactionId, config);
73
- logInfo(`${this.getGatewayName(method)}: Cancel payment, Transaction ID ${transactionId}, Status ${response.status}`);
73
+ logInfo(`${this.getGatewayName(method)}: Cancel payment, Transaction ID ${transactionId}, Status ${response.status}`, { transactionId, response });
74
74
  return response;
75
75
  }
76
76
  catch (error) {
77
- logError(`${this.getGatewayName(method)}: Cancel payment failed, Transaction ID ${transactionId}`, error);
77
+ logError(`${this.getGatewayName(method)}: Cancel payment failed, Transaction ID ${transactionId}`, { transactionId, error });
78
78
  throw error;
79
79
  }
80
80
  }
@@ -84,11 +84,11 @@ export class LitePosPayment {
84
84
  throw new ValidationError(`Payment method not supported: ${method}`, method);
85
85
  try {
86
86
  const response = await handler(transactionId, config, amount);
87
- logInfo(`${this.getGatewayName(method)}: Refund payment, Transaction ID ${transactionId}, Refund ID ${response.refundId}, Status ${response.status}`);
87
+ logInfo(`${this.getGatewayName(method)}: Refund payment, Transaction ID ${transactionId}, Refund ID ${response.refundId}, Status ${response.status}`, { transactionId, amount, response });
88
88
  return response;
89
89
  }
90
90
  catch (error) {
91
- logError(`${this.getGatewayName(method)}: Refund payment failed, Transaction ID ${transactionId}`, error);
91
+ logError(`${this.getGatewayName(method)}: Refund payment failed, Transaction ID ${transactionId}`, { transactionId, amount, error });
92
92
  throw error;
93
93
  }
94
94
  }
@@ -98,35 +98,128 @@ export class LitePosPayment {
98
98
  throw new ValidationError(`Payment method not supported: ${method}`, method);
99
99
  try {
100
100
  const response = await handler(refundId, config);
101
- logInfo(`${this.getGatewayName(method)}: Query refund, Refund ID ${refundId}, Status ${response.status}`);
101
+ logInfo(`${this.getGatewayName(method)}: Query refund, Refund ID ${refundId}, Status ${response.status}`, { refundId, response });
102
102
  return response;
103
103
  }
104
104
  catch (error) {
105
- logError(`${this.getGatewayName(method)}: Query refund failed, Refund ID ${refundId}`, error);
105
+ logError(`${this.getGatewayName(method)}: Query refund failed, Refund ID ${refundId}`, { refundId, error });
106
106
  throw error;
107
107
  }
108
108
  }
109
109
  // Simulation methods (for testing, returns mock data without calling adapters)
110
110
  simulateCharge(request) {
111
- const transactionId = `SIM-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
111
+ const transactionId = `SIM-${Date.now()}`;
112
+ const isQrCode = request.method.includes('qrcode');
113
+ const paymentChannel = isQrCode ? (request.metadata?.paymentChannel || 'tng') : 'Mastercard';
114
+ const cardLabel = isQrCode ? '' : 'Mastercard';
115
+ const cardNo = isQrCode ? '' : '************2066';
116
+ const now = new Date();
117
+ const invNo = now.toISOString().replace(/[-:T]/g, '').slice(0, 14);
112
118
  return {
113
119
  transactionId,
114
120
  status: PaymentStatus.Pending,
115
121
  amount: request.amount,
116
122
  currency: request.currency,
117
- qrCodeData: request.method.includes('qrcode') ? `QR_${request.orderId}` : undefined,
118
- metadata: { simulated: true, ...request.metadata },
119
- raw: { simulated: true, request },
123
+ qrCodeData: isQrCode ? `QR_${request.orderId}` : undefined,
124
+ payment_source_method: cardLabel || paymentChannel,
125
+ payment_source_last4: isQrCode ? '' : '2066',
126
+ payment_source_charge_ref: transactionId,
127
+ metadata: {
128
+ responseCode: '00',
129
+ responseText: 'Approved',
130
+ paymentChannel,
131
+ invNo,
132
+ tid: '00000001',
133
+ mid: '000000000000001',
134
+ cardNo,
135
+ entryMode: 'contactless',
136
+ cardLabel,
137
+ },
138
+ raw: {
139
+ transType: 'sale',
140
+ posId: 'SIM_POS_ID',
141
+ deviceId: 'SIM_DEVICE_ID',
142
+ referenceLabel: request.orderId.slice(0, 10),
143
+ apiVersion: 'v1',
144
+ statusCode: '00',
145
+ responseCode: '00',
146
+ responseText: 'Approved',
147
+ terminalSn: 'SIM_TERMINAL',
148
+ softwareVersion: 'Version 1.0.0',
149
+ transData: {
150
+ cardNo,
151
+ entryMode: 'contactless',
152
+ rrn: '000000000001',
153
+ tvr: '0000008001',
154
+ appCrypt: 'simulated',
155
+ aid: 'A0000000041010',
156
+ cvmType: '00',
157
+ cardLabel,
158
+ paymentChannel,
159
+ transAmt: request.amount.toFixed(2),
160
+ transDateTime: now.toISOString().slice(0, 19),
161
+ transId: transactionId,
162
+ invNo,
163
+ batchNo: '',
164
+ tid: '00000001',
165
+ mid: '000000000000001',
166
+ currency: request.currency,
167
+ apprCode: '000001',
168
+ },
169
+ referenceId: `SIM-${Date.now()}`,
170
+ signature: 'simulated',
171
+ },
120
172
  };
121
173
  }
122
- simulateQuery(transactionId, status) {
174
+ simulateQuery(transactionId, status, amount = 0, currency = 'SGD') {
175
+ const now = new Date();
176
+ const invNo = now.toISOString().replace(/[-:T]/g, '').slice(0, 14);
123
177
  return {
124
178
  transactionId,
125
179
  status,
126
- amount: 0,
127
- currency: 'MYR',
128
- metadata: { simulated: true },
129
- raw: { simulated: true },
180
+ amount,
181
+ currency,
182
+ payment_source_method: 'Mastercard',
183
+ payment_source_last4: '2066',
184
+ payment_source_charge_ref: transactionId,
185
+ metadata: {
186
+ responseCode: '00',
187
+ responseText: 'Approved',
188
+ paymentChannel: 'Mastercard',
189
+ invNo,
190
+ tid: '00000001',
191
+ mid: '000000000000001',
192
+ cardNo: '************2066',
193
+ entryMode: 'contactless',
194
+ cardLabel: 'Mastercard',
195
+ },
196
+ raw: {
197
+ transType: 'sale',
198
+ posId: 'SIM_POS_ID',
199
+ deviceId: 'SIM_DEVICE_ID',
200
+ apiVersion: 'v1',
201
+ statusCode: '00',
202
+ responseCode: '00',
203
+ responseText: 'Approved',
204
+ terminalSn: 'SIM_TERMINAL',
205
+ softwareVersion: 'Version 1.0.0',
206
+ transData: {
207
+ cardNo: '************2066',
208
+ entryMode: 'contactless',
209
+ rrn: '000000000001',
210
+ cardLabel: 'Mastercard',
211
+ paymentChannel: 'Mastercard',
212
+ transAmt: amount.toFixed(2),
213
+ transDateTime: now.toISOString().slice(0, 19),
214
+ transId: transactionId,
215
+ invNo,
216
+ tid: '00000001',
217
+ mid: '000000000000001',
218
+ currency,
219
+ },
220
+ referenceId: `SIM-${Date.now()}`,
221
+ signature: 'simulated',
222
+ },
130
223
  };
131
224
  }
132
225
  getGatewayName(method) {
@@ -13,6 +13,9 @@ export interface PaymentResponse {
13
13
  amount: number;
14
14
  currency: string;
15
15
  qrCodeData?: string;
16
+ payment_source_method?: string;
17
+ payment_source_last4?: string;
18
+ payment_source_charge_ref?: string;
16
19
  metadata?: Record<string, unknown>;
17
20
  raw?: unknown;
18
21
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@litepos/payment",
3
3
  "type": "module",
4
- "version": "1.0.11",
4
+ "version": "1.0.13",
5
5
  "description": "LitePOS payment gateway SDK - Core package",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@litepos/payment-fiuu": "1.0.11"
28
+ "@litepos/payment-fiuu": "1.0.13"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.9.2",