@litepos/payment 1.0.13 → 1.0.16
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 +2 -1
- package/dist/client.js +19 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/interfaces.d.ts +11 -1
- package/dist/types/status.d.ts +5 -0
- package/dist/types/status.js +7 -0
- package/package.json +2 -2
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse } from './interfaces';
|
|
1
|
+
import type { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse, VoidResponse } from './interfaces';
|
|
2
2
|
import { PaymentStatus } from './types/status';
|
|
3
3
|
export declare function validateConfig(method: string, config: unknown): void;
|
|
4
4
|
export declare class LitePosPayment {
|
|
@@ -6,6 +6,7 @@ export declare class LitePosPayment {
|
|
|
6
6
|
queryPayment(method: string, transactionId: string, config: Record<string, unknown>): Promise<PaymentResponse>;
|
|
7
7
|
cancelPayment(method: string, transactionId: string, config: Record<string, unknown>): Promise<CancelResponse>;
|
|
8
8
|
refund(method: string, transactionId: string, config: Record<string, unknown>, amount?: number): Promise<RefundResponse>;
|
|
9
|
+
voidPayment(method: string, transactionId: string, config: Record<string, unknown>): Promise<VoidResponse>;
|
|
9
10
|
queryRefund(method: string, refundId: string, config: Record<string, unknown>): Promise<RefundResponse>;
|
|
10
11
|
simulateCharge(request: PaymentRequest): PaymentResponse;
|
|
11
12
|
simulateQuery(transactionId: string, status: PaymentStatus, amount?: number, currency?: string): PaymentResponse;
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cancelPayment as cancelFiuuPayment, chargeCard, chargeQrCode, queryPayment, refund, validateConfig as validateFiuuConfig } from '@litepos/payment-fiuu';
|
|
1
|
+
import { cancelPayment as cancelFiuuPayment, chargeCard, chargeQrCode, queryPayment, refund, validateConfig as validateFiuuConfig, voidPayment as voidFiuuPayment } from '@litepos/payment-fiuu';
|
|
2
2
|
import { ValidationError } from './types/error';
|
|
3
3
|
import { PaymentStatus } from './types/status';
|
|
4
4
|
import { logError, logInfo } from './utils/logger';
|
|
@@ -23,6 +23,10 @@ const CANCEL_ROUTING = {
|
|
|
23
23
|
'FIUU': cancelFiuuPayment,
|
|
24
24
|
'fiuu-qrcode': cancelFiuuPayment,
|
|
25
25
|
};
|
|
26
|
+
const VOID_ROUTING = {
|
|
27
|
+
'FIUU': voidFiuuPayment,
|
|
28
|
+
'fiuu-qrcode': voidFiuuPayment,
|
|
29
|
+
};
|
|
26
30
|
// Config validation routing
|
|
27
31
|
const VALIDATE_ROUTING = {
|
|
28
32
|
'FIUU': validateFiuuConfig,
|
|
@@ -92,6 +96,20 @@ export class LitePosPayment {
|
|
|
92
96
|
throw error;
|
|
93
97
|
}
|
|
94
98
|
}
|
|
99
|
+
async voidPayment(method, transactionId, config) {
|
|
100
|
+
const handler = VOID_ROUTING[method];
|
|
101
|
+
if (!handler)
|
|
102
|
+
throw new ValidationError(`Payment method not supported: ${method}`, method);
|
|
103
|
+
try {
|
|
104
|
+
const response = await handler(transactionId, config);
|
|
105
|
+
logInfo(`${this.getGatewayName(method)}: Void payment, Transaction ID ${transactionId}, Void ID ${response.voidId}, Status ${response.status}`, { transactionId, response });
|
|
106
|
+
return response;
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
logError(`${this.getGatewayName(method)}: Void payment failed, Transaction ID ${transactionId}`, { transactionId, error });
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
95
113
|
async queryRefund(method, refundId, config) {
|
|
96
114
|
const handler = REFUND_QUERY_ROUTING[method];
|
|
97
115
|
if (!handler)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { LitePosPayment, validateConfig } from './client';
|
|
2
|
-
export { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse, ValidationResult, } from './interfaces';
|
|
2
|
+
export { CancelResponse, PaymentRequest, PaymentResponse, RefundResponse, ValidationResult, VoidResponse, } from './interfaces';
|
|
3
3
|
export { Simulator } from './simulator';
|
|
4
4
|
export type { PaymentConfig } from './types/config';
|
|
5
5
|
export { PaymentError, ValidationError } from './types/error';
|
|
6
|
-
export { CancelStatus, PaymentStatus, RefundStatus } from './types/status';
|
|
6
|
+
export { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
|
|
7
7
|
export { logError, logInfo } from './utils/logger';
|
package/dist/index.js
CHANGED
|
@@ -3,6 +3,6 @@ export { LitePosPayment, validateConfig } from './client';
|
|
|
3
3
|
export { Simulator } from './simulator';
|
|
4
4
|
export { PaymentError, ValidationError } from './types/error';
|
|
5
5
|
// Type exports
|
|
6
|
-
export { CancelStatus, PaymentStatus, RefundStatus } from './types/status';
|
|
6
|
+
export { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
|
|
7
7
|
// Logger exports
|
|
8
8
|
export { logError, logInfo } from './utils/logger';
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CancelStatus, PaymentStatus, RefundStatus } from './types/status';
|
|
1
|
+
import type { CancelStatus, PaymentStatus, RefundStatus, VoidStatus } from './types/status';
|
|
2
2
|
export interface PaymentRequest {
|
|
3
3
|
method: string;
|
|
4
4
|
amount: number;
|
|
@@ -35,6 +35,16 @@ export interface CancelResponse {
|
|
|
35
35
|
metadata?: Record<string, unknown>;
|
|
36
36
|
raw?: unknown;
|
|
37
37
|
}
|
|
38
|
+
export interface VoidResponse {
|
|
39
|
+
voidId: string;
|
|
40
|
+
transactionId: string;
|
|
41
|
+
status: VoidStatus;
|
|
42
|
+
amount: number;
|
|
43
|
+
currency: string;
|
|
44
|
+
voidedAt?: Date;
|
|
45
|
+
metadata?: Record<string, unknown>;
|
|
46
|
+
raw?: unknown;
|
|
47
|
+
}
|
|
38
48
|
export interface ValidationResult {
|
|
39
49
|
valid: boolean;
|
|
40
50
|
errors?: string[];
|
package/dist/types/status.d.ts
CHANGED
package/dist/types/status.js
CHANGED
|
@@ -19,3 +19,10 @@ export var CancelStatus;
|
|
|
19
19
|
CancelStatus["Success"] = "success";
|
|
20
20
|
CancelStatus["Failed"] = "failed";
|
|
21
21
|
})(CancelStatus || (CancelStatus = {}));
|
|
22
|
+
// Void status enumeration
|
|
23
|
+
export var VoidStatus;
|
|
24
|
+
(function (VoidStatus) {
|
|
25
|
+
VoidStatus["Pending"] = "pending";
|
|
26
|
+
VoidStatus["Success"] = "success";
|
|
27
|
+
VoidStatus["Failed"] = "failed";
|
|
28
|
+
})(VoidStatus || (VoidStatus = {}));
|
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.16",
|
|
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.
|
|
28
|
+
"@litepos/payment-fiuu": "1.0.16"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"typescript": "^5.9.2",
|