@litepos/payment 1.0.18 → 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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse, VoidResponse } from './interfaces';
2
- import type { PaymentStatus } from './types/status';
2
+ import { PaymentStatus } from './types/status';
3
3
  export declare function validateConfig(method: string, config: unknown): void;
4
4
  export declare class LitePosPayment {
5
5
  private getRoute;
package/dist/client.js CHANGED
@@ -1,10 +1,11 @@
1
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 {
2
+ import { cancelPayment as sqbCancelPayment,
3
3
  // chargeAlipay as sqbChargeAlipay, // ALPH disabled
4
4
  chargeCard as sqbChargeCard,
5
5
  // chargeWechat as sqbChargeWechat, // WCPH disabled
6
6
  queryPayment as sqbQueryPayment, refund as sqbRefund, simulateCharge as sqbSimulateCharge, simulateQuery as sqbSimulateQuery, validateConfig as validateSqbConfig, } from '@litepos/payment-shouqianba';
7
7
  import { ValidationError } from './types/error';
8
+ import { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
8
9
  import { logError, logInfo } from './utils/logger';
9
10
  const ROUTING = {
10
11
  'FIUU': {
@@ -36,8 +37,7 @@ const ROUTING = {
36
37
  query: sqbQueryPayment,
37
38
  refund: sqbRefund,
38
39
  refundQuery: sqbQueryPayment,
39
- // cancel: not in SQB docs
40
- // void: not in SQB docs
40
+ cancel: sqbCancelPayment,
41
41
  simulateCharge: sqbSimulateCharge,
42
42
  simulateQuery: (txId, s, a, c) => sqbSimulateQuery(txId, s, a, c, 'SQBP'),
43
43
  validate: validateSqbConfig,
@@ -65,11 +65,14 @@ export class LitePosPayment {
65
65
  throw new ValidationError(`Charge not supported for method: ${request.method}`, request.method);
66
66
  try {
67
67
  const response = await route.charge(request);
68
- logInfo(`${route.name}: Charge payment, Order ID ${request.orderId}, Transaction ID ${response.transactionId}, Status ${response.status}`, { request, response });
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 });
69
72
  return response;
70
73
  }
71
74
  catch (error) {
72
- logError(`${route.name}: Charge payment failed, Order ID ${request.orderId}`, { request, error });
75
+ logError(`${route.name}: Charge payment error, Order ID ${request.orderId}`, { request, error });
73
76
  throw error;
74
77
  }
75
78
  }
@@ -79,11 +82,14 @@ export class LitePosPayment {
79
82
  throw new ValidationError(`Query not supported for method: ${method}`, method);
80
83
  try {
81
84
  const response = await route.query(transactionId, config);
82
- logInfo(`${route.name}: Query payment, Transaction ID ${transactionId}, Status ${response.status}`, { transactionId, response });
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 });
83
89
  return response;
84
90
  }
85
91
  catch (error) {
86
- logError(`${route.name}: Query payment failed, Transaction ID ${transactionId}`, { transactionId, error });
92
+ logError(`${route.name}: Query payment error, Transaction ID ${transactionId}`, { transactionId, error });
87
93
  throw error;
88
94
  }
89
95
  }
@@ -93,11 +99,14 @@ export class LitePosPayment {
93
99
  throw new ValidationError(`Cancel not supported for method: ${method}`, method);
94
100
  try {
95
101
  const response = await route.cancel(transactionId, config);
96
- logInfo(`${route.name}: Cancel payment, Transaction ID ${transactionId}, Status ${response.status}`, { transactionId, response });
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 });
97
106
  return response;
98
107
  }
99
108
  catch (error) {
100
- logError(`${route.name}: Cancel payment failed, Transaction ID ${transactionId}`, { transactionId, error });
109
+ logError(`${route.name}: Cancel payment error, Transaction ID ${transactionId}`, { transactionId, error });
101
110
  throw error;
102
111
  }
103
112
  }
@@ -107,11 +116,14 @@ export class LitePosPayment {
107
116
  throw new ValidationError(`Refund not supported for method: ${method}`, method);
108
117
  try {
109
118
  const response = await route.refund(transactionId, config, amount, refundRequestNo);
110
- logInfo(`${route.name}: Refund payment, Transaction ID ${transactionId}, Refund ID ${response.refundId}, Status ${response.status}`, { transactionId, amount, response });
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 });
111
123
  return response;
112
124
  }
113
125
  catch (error) {
114
- logError(`${route.name}: Refund payment failed, Transaction ID ${transactionId}`, { transactionId, amount, error });
126
+ logError(`${route.name}: Refund error, Transaction ID ${transactionId}`, { transactionId, amount, error });
115
127
  throw error;
116
128
  }
117
129
  }
@@ -121,11 +133,14 @@ export class LitePosPayment {
121
133
  throw new ValidationError(`Void not supported for method: ${method}`, method);
122
134
  try {
123
135
  const response = await route.void(transactionId, config);
124
- logInfo(`${route.name}: Void payment, Transaction ID ${transactionId}, Void ID ${response.voidId}, Status ${response.status}`, { transactionId, response });
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 });
125
140
  return response;
126
141
  }
127
142
  catch (error) {
128
- logError(`${route.name}: Void payment failed, Transaction ID ${transactionId}`, { transactionId, error });
143
+ logError(`${route.name}: Void error, Transaction ID ${transactionId}`, { transactionId, error });
129
144
  throw error;
130
145
  }
131
146
  }
@@ -135,11 +150,14 @@ export class LitePosPayment {
135
150
  throw new ValidationError(`Refund query not supported for method: ${method}`, method);
136
151
  try {
137
152
  const response = await route.refundQuery(refundId, config);
138
- logInfo(`${route.name}: Query refund, Refund ID ${refundId}, Status ${response.status}`, { refundId, response });
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 });
139
157
  return response;
140
158
  }
141
159
  catch (error) {
142
- logError(`${route.name}: Query refund failed, Refund ID ${refundId}`, { refundId, error });
160
+ logError(`${route.name}: Query refund error, Refund ID ${refundId}`, { refundId, error });
143
161
  throw error;
144
162
  }
145
163
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@litepos/payment",
3
3
  "type": "module",
4
- "version": "1.0.18",
4
+ "version": "1.0.19",
5
5
  "description": "LitePOS payment gateway SDK - Core package",
6
6
  "author": "",
7
7
  "license": "MIT",
@@ -30,8 +30,8 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@litepos/payment-fiuu": "1.0.18",
34
- "@litepos/payment-shouqianba": "1.0.18"
33
+ "@litepos/payment-fiuu": "1.0.19",
34
+ "@litepos/payment-shouqianba": "1.0.19"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^5.9.2",