@litepos/payment 1.0.12 → 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
@@ -108,25 +108,118 @@ export class LitePosPayment {
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) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@litepos/payment",
3
3
  "type": "module",
4
- "version": "1.0.12",
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.12"
28
+ "@litepos/payment-fiuu": "1.0.13"
29
29
  },
30
30
  "devDependencies": {
31
31
  "typescript": "^5.9.2",