liqpay-nestjs 0.2.4 → 0.2.6
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/core/{types → __devtypes}/undocumented/split-rule.d.ts +1 -1
- package/dist/core/clients/index.d.ts +4 -0
- package/dist/core/clients/index.js +20 -0
- package/dist/core/clients/liqpay.client.d.ts +7 -0
- package/dist/core/clients/liqpay.client.js +16 -0
- package/dist/core/clients/payments.client.d.ts +16 -0
- package/dist/core/clients/payments.client.js +49 -0
- package/dist/core/clients/utils.client.d.ts +20 -0
- package/dist/core/clients/utils.client.js +95 -0
- package/dist/core/clients/webhooks.client.d.ts +8 -0
- package/dist/core/clients/webhooks.client.js +14 -0
- package/dist/core/{schemas → types}/checkout/checkout-callback.schema.d.ts +1 -1
- package/dist/core/{schemas → types}/checkout/checkout-request.schema.d.ts +3 -3
- package/dist/core/{schemas → types}/checkout/checkout-request.schema.js +1 -1
- package/dist/core/{schemas → types}/payment-status/payment-status-request.schema.d.ts +3 -3
- package/dist/core/{schemas → types}/payment-status/payment-status-request.schema.js +1 -1
- package/dist/core/{schemas → types}/payment-status/payment-status-response.schema.d.ts +1 -1
- package/dist/core/utils/is-success.util.d.ts +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -5
- package/dist/nest/liqpay.service.d.ts +3 -122
- package/dist/nest/liqpay.service.js +8 -31
- package/dist/nest/services/index.d.ts +2 -0
- package/dist/{core → nest/services}/index.js +2 -1
- package/dist/nest/services/payments.service.d.ts +160 -0
- package/dist/nest/services/payments.service.js +22 -0
- package/dist/nest/services/webhooks.service.d.ts +66 -0
- package/dist/nest/services/webhooks.service.js +13 -0
- package/package.json +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/liqpay.client.d.ts +0 -65
- package/dist/core/liqpay.client.js +0 -156
- package/dist/core/{types → __devtypes}/documented/checkout.callback.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/checkout.callback.js +0 -0
- package/dist/core/{types → __devtypes}/documented/checkout.request.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/checkout.request.js +0 -0
- package/dist/core/{types → __devtypes}/documented/detail-addenda.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/detail-addenda.js +0 -0
- package/dist/core/{types → __devtypes}/documented/envelope.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/envelope.js +0 -0
- package/dist/core/{types → __devtypes}/documented/fiscal-data.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/fiscal-data.js +0 -0
- package/dist/core/{types → __devtypes}/documented/payment-status.request.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/payment-status.request.js +0 -0
- package/dist/core/{types → __devtypes}/documented/payment-status.response.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/payment-status.response.js +0 -0
- package/dist/core/{types → __devtypes}/documented/split-rule.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/split-rule.js +0 -0
- package/dist/core/{types → __devtypes}/documented/types.d.ts +0 -0
- package/dist/core/{types → __devtypes}/documented/types.js +0 -0
- package/dist/core/{types → __devtypes}/payloads.d.ts +0 -0
- package/dist/core/{types → __devtypes}/payloads.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/checkout.callback.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/checkout.callback.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/checkout.request.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/checkout.request.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/detail-addenda.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/detail-addenda.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/envelope.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/envelope.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/fiscal-data.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/fiscal-data.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/payment-status.request.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/payment-status.request.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/payment-status.response.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/payment-status.response.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/split-rule.js +0 -0
- package/dist/core/{types → __devtypes}/undocumented/types.d.ts +0 -0
- package/dist/core/{types → __devtypes}/undocumented/types.js +0 -0
- package/dist/core/{schemas → types}/base/envelope.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/base/envelope.schema.js +0 -0
- package/dist/core/{schemas → types}/base/index.d.ts +0 -0
- package/dist/core/{schemas → types}/base/index.js +0 -0
- package/dist/core/{schemas → types}/base/request.type.d.ts +0 -0
- package/dist/core/{schemas → types}/base/request.type.js +0 -0
- package/dist/core/{schemas → types}/base/response.type.d.ts +0 -0
- package/dist/core/{schemas → types}/base/response.type.js +0 -0
- package/dist/core/{schemas → types}/checkout/checkout-callback.schema.js +0 -0
- package/dist/core/{schemas → types}/checkout/index.d.ts +0 -0
- package/dist/core/{schemas → types}/checkout/index.js +0 -0
- package/dist/core/{schemas → types}/common/detail-addenda.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/detail-addenda.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/action.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/action.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/bonus-type.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/bonus-type.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/commission-payer.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/commission-payer.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/currency.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/currency.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/error-code.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/error-code.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/index.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/index.js +0 -0
- package/dist/core/{schemas → types}/common/enums/language.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/language.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/mpi-eci.schema.d.ts +0 -0
- package/dist/core/{schemas → types}/common/enums/mpi-eci.schema.js +0 -0
- package/dist/core/{schemas → types}/common/enums/payment-status.schema.d.ts +2 -2
- /package/dist/core/{schemas → types}/common/enums/payment-status.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/enums/paytype.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/enums/paytype.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/enums/request-result.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/enums/request-result.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/enums/subscribe-period.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/enums/subscribe-period.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/enums/unit.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/enums/unit.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/enums/version.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/enums/version.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/fiscal-data.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/fiscal-data.schema.js +0 -0
- /package/dist/core/{schemas → types}/common/index.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/index.js +0 -0
- /package/dist/core/{schemas → types}/common/split-rule.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/common/split-rule.schema.js +0 -0
- /package/dist/core/{schemas → types}/error/error-response.schema.d.ts +0 -0
- /package/dist/core/{schemas → types}/error/error-response.schema.js +0 -0
- /package/dist/core/{schemas → types}/error/error.type.d.ts +0 -0
- /package/dist/core/{schemas → types}/error/error.type.js +0 -0
- /package/dist/core/{schemas → types}/error/index.d.ts +0 -0
- /package/dist/core/{schemas → types}/error/index.js +0 -0
- /package/dist/core/{schemas → types}/payment-status/index.d.ts +0 -0
- /package/dist/core/{schemas → types}/payment-status/index.js +0 -0
- /package/dist/core/{schemas → types}/payment-status/payment-status-response.schema.js +0 -0
- /package/dist/core/{constants.d.ts → url.type.d.ts} +0 -0
- /package/dist/core/{constants.js → url.type.js} +0 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./liqpay.client"), exports);
|
|
18
|
+
__exportStar(require("./payments.client"), exports);
|
|
19
|
+
__exportStar(require("./utils.client"), exports);
|
|
20
|
+
__exportStar(require("./webhooks.client"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LiqPayPaymentsClient } from './payments.client';
|
|
2
|
+
import { LiqPayWebhooksClient } from './webhooks.client';
|
|
3
|
+
export declare class LiqPayClient {
|
|
4
|
+
payments: LiqPayPaymentsClient;
|
|
5
|
+
webhooks: LiqPayWebhooksClient;
|
|
6
|
+
constructor(publicKey: string, privateKey: string, resultUrl: string, serverUrl: string);
|
|
7
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiqPayClient = void 0;
|
|
4
|
+
const payments_client_1 = require("./payments.client");
|
|
5
|
+
const utils_client_1 = require("./utils.client");
|
|
6
|
+
const webhooks_client_1 = require("./webhooks.client");
|
|
7
|
+
class LiqPayClient {
|
|
8
|
+
payments;
|
|
9
|
+
webhooks;
|
|
10
|
+
constructor(publicKey, privateKey, resultUrl, serverUrl) {
|
|
11
|
+
const utils = new utils_client_1.LiqPayUtilsClient(publicKey, privateKey, resultUrl, serverUrl);
|
|
12
|
+
this.payments = new payments_client_1.LiqPayPaymentsClient(utils);
|
|
13
|
+
this.webhooks = new webhooks_client_1.LiqPayWebhooksClient(utils);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.LiqPayClient = LiqPayClient;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { LiqPayCallResult } from '../types/base';
|
|
2
|
+
import { type LiqPayCheckoutRequest } from '../types/checkout';
|
|
3
|
+
import { LiqPayPaymentStatusResponse } from '../types/payment-status';
|
|
4
|
+
import { LiqPayUtilsClient } from './utils.client';
|
|
5
|
+
export declare class LiqPayPaymentsClient {
|
|
6
|
+
private readonly utils;
|
|
7
|
+
constructor(utils: LiqPayUtilsClient);
|
|
8
|
+
private fulfillPayload;
|
|
9
|
+
private prepareCheckout;
|
|
10
|
+
getCheckoutUrl(payload: LiqPayCheckoutRequest): string;
|
|
11
|
+
create(payload: LiqPayCheckoutRequest): LiqPayCheckoutRequest & {
|
|
12
|
+
checkoutUrl: string;
|
|
13
|
+
};
|
|
14
|
+
getCheckoutFormButton(payload: LiqPayCheckoutRequest, buttonText?: string, buttonColor?: string): string;
|
|
15
|
+
getStatus(orderId: string): Promise<LiqPayCallResult<LiqPayPaymentStatusResponse>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiqPayPaymentsClient = void 0;
|
|
4
|
+
const checkout_1 = require("../types/checkout");
|
|
5
|
+
const payment_status_1 = require("../types/payment-status");
|
|
6
|
+
const url_type_1 = require("../url.type");
|
|
7
|
+
class LiqPayPaymentsClient {
|
|
8
|
+
utils;
|
|
9
|
+
constructor(utils) {
|
|
10
|
+
this.utils = utils;
|
|
11
|
+
}
|
|
12
|
+
fulfillPayload(payload) {
|
|
13
|
+
return {
|
|
14
|
+
...payload,
|
|
15
|
+
version: 7,
|
|
16
|
+
resultUrl: payload.resultUrl ?? this.utils.resultUrl,
|
|
17
|
+
serverUrl: payload.serverUrl ?? this.utils.serverUrl,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
prepareCheckout(payload) {
|
|
21
|
+
const fullfilled = this.fulfillPayload(payload);
|
|
22
|
+
const raw = checkout_1.LiqPayRawCheckoutRequestSchema.parse(fullfilled);
|
|
23
|
+
const { data, signature } = this.utils.getCredentials(raw);
|
|
24
|
+
return { fullfilled, data, signature };
|
|
25
|
+
}
|
|
26
|
+
getCheckoutUrl(payload) {
|
|
27
|
+
const { data, signature } = this.prepareCheckout(payload);
|
|
28
|
+
return `${url_type_1.LIQPAY_CHECKOUT_URL}?data=${data}&signature=${signature}`;
|
|
29
|
+
}
|
|
30
|
+
create(payload) {
|
|
31
|
+
const fullfilled = this.fulfillPayload(payload);
|
|
32
|
+
return { ...fullfilled, checkoutUrl: this.getCheckoutUrl(fullfilled) };
|
|
33
|
+
}
|
|
34
|
+
getCheckoutFormButton(payload, buttonText = 'Pay', buttonColor = '#77CC5D') {
|
|
35
|
+
const { data, signature } = this.prepareCheckout(payload);
|
|
36
|
+
return `
|
|
37
|
+
<form method="POST" action="${url_type_1.LIQPAY_CHECKOUT_URL}" accept-charset="utf-8">
|
|
38
|
+
<input type="hidden" name="data" value="${data}" />
|
|
39
|
+
<input type="hidden" name="signature" value="${signature}" />
|
|
40
|
+
<script type="text/javascript" src="https://static.liqpay.ua/libjs/sdk_button.js"></script>
|
|
41
|
+
<sdk-button label="${buttonText}" background="${buttonColor}" onClick="submit()"></sdk-button>
|
|
42
|
+
</form>
|
|
43
|
+
`;
|
|
44
|
+
}
|
|
45
|
+
async getStatus(orderId) {
|
|
46
|
+
return await this.utils.call({ action: 'status', orderId }, payment_status_1.LiqPayRawPaymentStatusRequestSchema, payment_status_1.LiqPayPaymentStatusResponseSchema, url_type_1.LIQPAY_REQUEST_URL);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.LiqPayPaymentsClient = LiqPayPaymentsClient;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { LiqPayCallResult, LiqPayEnvelope, LiqPayRawRequest, LiqPayRequest, LiqPayResponse } from '../types/base';
|
|
3
|
+
import { LiqPayError } from '../types/error';
|
|
4
|
+
export declare class LiqPayUtilsClient {
|
|
5
|
+
readonly publicKey: string;
|
|
6
|
+
readonly privateKey: string;
|
|
7
|
+
readonly resultUrl: string;
|
|
8
|
+
readonly serverUrl: string;
|
|
9
|
+
constructor(publicKey: string, privateKey: string, resultUrl: string, serverUrl: string);
|
|
10
|
+
encodeData(data: LiqPayRawRequest): string;
|
|
11
|
+
decodeData(encodedData: string): unknown;
|
|
12
|
+
createSignature(encodedData: string): string;
|
|
13
|
+
getCredentials(data: LiqPayRawRequest): LiqPayEnvelope;
|
|
14
|
+
isValidSignature(envelope: LiqPayEnvelope): boolean;
|
|
15
|
+
createError(code: LiqPayError['code'], description: string): LiqPayCallResult<never>;
|
|
16
|
+
parseData<T>(schema: z.ZodType<T>, data: unknown): LiqPayCallResult<T>;
|
|
17
|
+
parseError(data: unknown): LiqPayCallResult<never> | null;
|
|
18
|
+
parseEnvelope<TResponse extends LiqPayResponse>(envelope: LiqPayEnvelope, schema: z.ZodType<TResponse>): LiqPayCallResult<TResponse>;
|
|
19
|
+
call<TRequest extends LiqPayRequest, TRawRequest extends LiqPayRawRequest, TResponse extends LiqPayResponse>(payload: TRequest, rawSchema: z.ZodType<TRawRequest>, responseSchema: z.ZodType<TResponse>, url: string): Promise<LiqPayCallResult<TResponse>>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiqPayUtilsClient = void 0;
|
|
4
|
+
const node_crypto_1 = require("node:crypto");
|
|
5
|
+
const error_1 = require("../types/error");
|
|
6
|
+
class LiqPayUtilsClient {
|
|
7
|
+
publicKey;
|
|
8
|
+
privateKey;
|
|
9
|
+
resultUrl;
|
|
10
|
+
serverUrl;
|
|
11
|
+
constructor(publicKey, privateKey, resultUrl, serverUrl) {
|
|
12
|
+
this.publicKey = publicKey;
|
|
13
|
+
this.privateKey = privateKey;
|
|
14
|
+
this.resultUrl = resultUrl;
|
|
15
|
+
this.serverUrl = serverUrl;
|
|
16
|
+
}
|
|
17
|
+
encodeData(data) {
|
|
18
|
+
return Buffer.from(JSON.stringify(data)).toString('base64');
|
|
19
|
+
}
|
|
20
|
+
decodeData(encodedData) {
|
|
21
|
+
return JSON.parse(Buffer.from(encodedData, 'base64').toString('utf-8'));
|
|
22
|
+
}
|
|
23
|
+
createSignature(encodedData) {
|
|
24
|
+
const signatureString = `${this.privateKey}${encodedData}${this.privateKey}`;
|
|
25
|
+
return (0, node_crypto_1.createHash)('sha3-256').update(signatureString).digest('base64');
|
|
26
|
+
}
|
|
27
|
+
getCredentials(data) {
|
|
28
|
+
const payload = {
|
|
29
|
+
...data,
|
|
30
|
+
version: 7,
|
|
31
|
+
public_key: this.publicKey,
|
|
32
|
+
};
|
|
33
|
+
const encoded = this.encodeData(payload);
|
|
34
|
+
const signature = this.createSignature(encoded);
|
|
35
|
+
return { data: encoded, signature };
|
|
36
|
+
}
|
|
37
|
+
isValidSignature(envelope) {
|
|
38
|
+
const expected = this.createSignature(envelope.data);
|
|
39
|
+
const a = Buffer.from(expected);
|
|
40
|
+
const b = Buffer.from(envelope.signature);
|
|
41
|
+
if (a.length !== b.length)
|
|
42
|
+
return false;
|
|
43
|
+
return (0, node_crypto_1.timingSafeEqual)(a, b);
|
|
44
|
+
}
|
|
45
|
+
createError(code, description) {
|
|
46
|
+
return { data: null, error: { code, description } };
|
|
47
|
+
}
|
|
48
|
+
parseData(schema, data) {
|
|
49
|
+
const error = this.parseError(data);
|
|
50
|
+
if (error)
|
|
51
|
+
return error;
|
|
52
|
+
const parsed = schema.safeParse(data);
|
|
53
|
+
if (!parsed.success)
|
|
54
|
+
return this.createError('validation_error', 'Invalid response schema');
|
|
55
|
+
return { data: parsed.data, error: null };
|
|
56
|
+
}
|
|
57
|
+
parseError(data) {
|
|
58
|
+
const parsed = error_1.LiqPayErrorResponseSchema.safeParse(data);
|
|
59
|
+
if (!parsed.success)
|
|
60
|
+
return null;
|
|
61
|
+
return this.createError(parsed.data.err_code, parsed.data.err_description);
|
|
62
|
+
}
|
|
63
|
+
parseEnvelope(envelope, schema) {
|
|
64
|
+
if (!this.isValidSignature(envelope))
|
|
65
|
+
return this.createError('invalid_signature', 'Invalid signature');
|
|
66
|
+
let rawData;
|
|
67
|
+
try {
|
|
68
|
+
rawData = this.decodeData(envelope.data);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return this.createError('decode_error', 'Failed to decode base64 data');
|
|
72
|
+
}
|
|
73
|
+
return this.parseData(schema, rawData);
|
|
74
|
+
}
|
|
75
|
+
async call(payload, rawSchema, responseSchema, url) {
|
|
76
|
+
const raw = rawSchema.parse(payload);
|
|
77
|
+
const envelope = this.getCredentials(raw);
|
|
78
|
+
const response = await fetch(url, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
81
|
+
body: new URLSearchParams(envelope),
|
|
82
|
+
});
|
|
83
|
+
if (!response.ok)
|
|
84
|
+
return this.createError('http_error', `HTTP ${response.status}`);
|
|
85
|
+
let rawData;
|
|
86
|
+
try {
|
|
87
|
+
rawData = await response.json();
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
return this.createError('invalid_response', 'Failed to parse JSON response');
|
|
91
|
+
}
|
|
92
|
+
return this.parseData(responseSchema, rawData);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.LiqPayUtilsClient = LiqPayUtilsClient;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { LiqPayCallResult, LiqPayEnvelope } from '../types/base';
|
|
2
|
+
import { LiqPayCheckoutCallback } from '../types/checkout';
|
|
3
|
+
import { LiqPayUtilsClient } from './utils.client';
|
|
4
|
+
export declare class LiqPayWebhooksClient {
|
|
5
|
+
private readonly utils;
|
|
6
|
+
constructor(utils: LiqPayUtilsClient);
|
|
7
|
+
parseCheckoutCallback(envelope: LiqPayEnvelope): LiqPayCallResult<LiqPayCheckoutCallback>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiqPayWebhooksClient = void 0;
|
|
4
|
+
const checkout_1 = require("../types/checkout");
|
|
5
|
+
class LiqPayWebhooksClient {
|
|
6
|
+
utils;
|
|
7
|
+
constructor(utils) {
|
|
8
|
+
this.utils = utils;
|
|
9
|
+
}
|
|
10
|
+
parseCheckoutCallback(envelope) {
|
|
11
|
+
return this.utils.parseEnvelope(envelope, checkout_1.LiqPayCheckoutCallbackSchema);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.LiqPayWebhooksClient = LiqPayWebhooksClient;
|
|
@@ -133,7 +133,7 @@ export declare const LiqPayCheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
|
|
|
133
133
|
mpiEci: 0 | 5 | 6 | 7 | undefined;
|
|
134
134
|
paytype: "" | "apay" | "gpay" | "card" | "privat24" | "masterpass" | "moment_part" | "paypart" | "cash" | "invoice" | "qr" | undefined;
|
|
135
135
|
refundDateLast: Date | undefined;
|
|
136
|
-
status: "" | "
|
|
136
|
+
status: "" | "error" | "success" | "failure" | "reversed" | "subscribed" | "unsubscribed" | "3ds_verify" | "captcha_verify" | "cvv_verify" | "ivr_verify" | "otp_verify" | "password_verify" | "phone_verify" | "pin_verify" | "receiver_verify" | "sender_verify" | "senderapp_verify" | "wait_qr" | "wait_sender" | "p24_verify" | "mp_verify" | "cash_wait" | "hold_wait" | "invoice_wait" | "prepared" | "processing" | "wait_accept" | "wait_card" | "wait_compensation" | "wait_lc" | "wait_reserve" | "wait_secure" | "try_again" | undefined;
|
|
137
137
|
waitReserveStatus: boolean | undefined;
|
|
138
138
|
publicKey?: string | undefined;
|
|
139
139
|
acqId?: number | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
export declare const LiqPayCheckoutRequestSchema: z.ZodObject<{
|
|
3
|
-
version: z.ZodLiteral<7
|
|
3
|
+
version: z.ZodOptional<z.ZodLiteral<7>>;
|
|
4
4
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
5
5
|
action: z.ZodEnum<{
|
|
6
6
|
pay: "pay";
|
|
@@ -133,7 +133,7 @@ export declare const LiqPayCheckoutRequestSchema: z.ZodObject<{
|
|
|
133
133
|
}, z.core.$strip>;
|
|
134
134
|
export type LiqPayCheckoutRequest = z.infer<typeof LiqPayCheckoutRequestSchema>;
|
|
135
135
|
export declare const LiqPayRawCheckoutRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
136
|
-
version: z.ZodLiteral<7
|
|
136
|
+
version: z.ZodOptional<z.ZodLiteral<7>>;
|
|
137
137
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
138
138
|
action: z.ZodEnum<{
|
|
139
139
|
pay: "pay";
|
|
@@ -322,12 +322,12 @@ export declare const LiqPayRawCheckoutRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
|
322
322
|
product_name?: string | undefined;
|
|
323
323
|
product_url?: string | undefined;
|
|
324
324
|
}, {
|
|
325
|
-
version: 7;
|
|
326
325
|
action: "pay" | "hold" | "paysplit" | "subscribe" | "paydonate" | "auth" | "regular" | "status";
|
|
327
326
|
amount: number;
|
|
328
327
|
currency: "USD" | "EUR" | "UAH";
|
|
329
328
|
description: string;
|
|
330
329
|
orderId: string;
|
|
330
|
+
version?: 7 | undefined;
|
|
331
331
|
publicKey?: string | undefined;
|
|
332
332
|
rroInfo?: {
|
|
333
333
|
items?: ({
|
|
@@ -10,7 +10,7 @@ const common_1 = require("../common");
|
|
|
10
10
|
const enums_1 = require("../common/enums");
|
|
11
11
|
exports.LiqPayCheckoutRequestSchema = zod_1.default.object({
|
|
12
12
|
// MAIN PARAMS
|
|
13
|
-
version: enums_1.LiqPayVersionSchema,
|
|
13
|
+
version: enums_1.LiqPayVersionSchema.optional(),
|
|
14
14
|
publicKey: zod_1.default.string().optional(),
|
|
15
15
|
action: enums_1.LiqPayActionSchema,
|
|
16
16
|
amount: zod_1.default.number().positive(),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import z from 'zod';
|
|
2
2
|
export declare const LiqPayPaymentStatusRequestSchema: z.ZodObject<{
|
|
3
|
-
version: z.ZodLiteral<7
|
|
3
|
+
version: z.ZodOptional<z.ZodLiteral<7>>;
|
|
4
4
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
5
5
|
action: z.ZodEnum<{
|
|
6
6
|
pay: "pay";
|
|
@@ -16,7 +16,7 @@ export declare const LiqPayPaymentStatusRequestSchema: z.ZodObject<{
|
|
|
16
16
|
}, z.core.$strip>;
|
|
17
17
|
export type LiqPayPaymentStatusRequest = z.infer<typeof LiqPayPaymentStatusRequestSchema>;
|
|
18
18
|
export declare const LiqPayRawPaymentStatusRequestSchema: z.ZodPipe<z.ZodObject<{
|
|
19
|
-
version: z.ZodLiteral<7
|
|
19
|
+
version: z.ZodOptional<z.ZodLiteral<7>>;
|
|
20
20
|
publicKey: z.ZodOptional<z.ZodString>;
|
|
21
21
|
action: z.ZodEnum<{
|
|
22
22
|
pay: "pay";
|
|
@@ -35,9 +35,9 @@ export declare const LiqPayRawPaymentStatusRequestSchema: z.ZodPipe<z.ZodObject<
|
|
|
35
35
|
order_id: string;
|
|
36
36
|
public_key?: string | undefined;
|
|
37
37
|
}, {
|
|
38
|
-
version: 7;
|
|
39
38
|
action: "pay" | "hold" | "paysplit" | "subscribe" | "paydonate" | "auth" | "regular" | "status";
|
|
40
39
|
orderId: string;
|
|
40
|
+
version?: 7 | undefined;
|
|
41
41
|
publicKey?: string | undefined;
|
|
42
42
|
}>>;
|
|
43
43
|
export type LiqPayRawPaymentStatusRequest = z.infer<typeof LiqPayRawPaymentStatusRequestSchema>;
|
|
@@ -8,7 +8,7 @@ const ts_case_convert_1 = require("ts-case-convert");
|
|
|
8
8
|
const zod_1 = __importDefault(require("zod"));
|
|
9
9
|
const enums_1 = require("../common/enums");
|
|
10
10
|
exports.LiqPayPaymentStatusRequestSchema = zod_1.default.object({
|
|
11
|
-
version: enums_1.LiqPayVersionSchema,
|
|
11
|
+
version: enums_1.LiqPayVersionSchema.optional(),
|
|
12
12
|
publicKey: zod_1.default.string().optional(),
|
|
13
13
|
action: enums_1.LiqPayActionSchema,
|
|
14
14
|
orderId: zod_1.default.string().max(255),
|
|
@@ -119,7 +119,7 @@ export declare const LiqPayPaymentStatusResponseSchema: z.ZodPipe<z.ZodObject<{
|
|
|
119
119
|
mpiEci: 0 | 5 | 6 | 7 | undefined;
|
|
120
120
|
paytype: "" | "apay" | "gpay" | "card" | "privat24" | "masterpass" | "moment_part" | "paypart" | "cash" | "invoice" | "qr" | undefined;
|
|
121
121
|
result: "" | "error" | "ok" | undefined;
|
|
122
|
-
status: "" | "
|
|
122
|
+
status: "" | "error" | "success" | "failure" | "reversed" | "subscribed" | "unsubscribed" | "3ds_verify" | "captcha_verify" | "cvv_verify" | "ivr_verify" | "otp_verify" | "password_verify" | "phone_verify" | "pin_verify" | "receiver_verify" | "sender_verify" | "senderapp_verify" | "wait_qr" | "wait_sender" | "p24_verify" | "mp_verify" | "cash_wait" | "hold_wait" | "invoice_wait" | "prepared" | "processing" | "wait_accept" | "wait_card" | "wait_compensation" | "wait_lc" | "wait_reserve" | "wait_secure" | "try_again" | undefined;
|
|
123
123
|
waitReserveStatus: boolean | undefined;
|
|
124
124
|
version: 0 | 7 | undefined;
|
|
125
125
|
acqId?: number | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export * from './core/
|
|
2
|
-
export * from './core/
|
|
3
|
-
export * from './core/
|
|
4
|
-
export * from './core/
|
|
5
|
-
export * from './core/
|
|
1
|
+
export * from './core/types/base';
|
|
2
|
+
export * from './core/types/checkout';
|
|
3
|
+
export * from './core/types/common';
|
|
4
|
+
export * from './core/types/common/enums';
|
|
5
|
+
export * from './core/types/error';
|
|
6
|
+
export * from './core/types/payment-status';
|
|
6
7
|
export * from './nest';
|
|
7
8
|
export * from './nest/constants';
|
|
8
9
|
export * from './nest/interfaces';
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./core/
|
|
18
|
-
__exportStar(require("./core/
|
|
19
|
-
__exportStar(require("./core/
|
|
20
|
-
__exportStar(require("./core/
|
|
21
|
-
__exportStar(require("./core/
|
|
17
|
+
__exportStar(require("./core/types/base"), exports);
|
|
18
|
+
__exportStar(require("./core/types/checkout"), exports);
|
|
19
|
+
__exportStar(require("./core/types/common"), exports);
|
|
20
|
+
__exportStar(require("./core/types/common/enums"), exports);
|
|
21
|
+
__exportStar(require("./core/types/error"), exports);
|
|
22
|
+
__exportStar(require("./core/types/payment-status"), exports);
|
|
22
23
|
__exportStar(require("./nest"), exports);
|
|
23
24
|
__exportStar(require("./nest/constants"), exports);
|
|
24
25
|
__exportStar(require("./nest/interfaces"), exports);
|
|
@@ -1,127 +1,8 @@
|
|
|
1
|
-
import { LiqPayEnvelope } from '../core/schemas/base';
|
|
2
|
-
import { LiqPayCheckoutRequest } from '../core/schemas/checkout';
|
|
3
1
|
import type { LiqPayOptions } from './interfaces';
|
|
2
|
+
import { LiqPayPaymentsService, LiqPayWebhooksService } from './services';
|
|
4
3
|
export declare class LiqpayService {
|
|
5
4
|
private readonly options;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
private readonly resultUrl;
|
|
9
|
-
private readonly serverUrl;
|
|
10
|
-
private readonly client;
|
|
5
|
+
readonly payments: LiqPayPaymentsService;
|
|
6
|
+
readonly webhooks: LiqPayWebhooksService;
|
|
11
7
|
constructor(options: LiqPayOptions);
|
|
12
|
-
getCheckoutUrl(payload: LiqPayCheckoutRequest): string;
|
|
13
|
-
getCheckoutForm(payload: LiqPayCheckoutRequest, buttonText?: string, buttonColor?: string): string;
|
|
14
|
-
getPaymentStatus(orderId: string): Promise<import("../core/schemas/base").LiqPayCallResult<{
|
|
15
|
-
action: "" | "pay" | "hold" | "paysplit" | "subscribe" | "paydonate" | "auth" | "regular" | "status" | undefined;
|
|
16
|
-
bonusType: "" | "bonusplus" | "discount_club" | "personal" | "promo" | undefined;
|
|
17
|
-
createDate: Date | undefined;
|
|
18
|
-
currency: "" | "USD" | "EUR" | "UAH" | undefined;
|
|
19
|
-
currencyCredit: "" | "USD" | "EUR" | "UAH" | undefined;
|
|
20
|
-
currencyDebit: "" | "USD" | "EUR" | "UAH" | undefined;
|
|
21
|
-
endDate: Date | undefined;
|
|
22
|
-
is3ds: boolean | undefined;
|
|
23
|
-
language: "" | "uk" | "en" | undefined;
|
|
24
|
-
momentPart: boolean | undefined;
|
|
25
|
-
mpiEci: 0 | 5 | 6 | 7 | undefined;
|
|
26
|
-
paytype: "" | "apay" | "gpay" | "card" | "privat24" | "masterpass" | "moment_part" | "paypart" | "cash" | "invoice" | "qr" | undefined;
|
|
27
|
-
result: "" | "error" | "ok" | undefined;
|
|
28
|
-
status: "" | "success" | "error" | "failure" | "reversed" | "subscribed" | "unsubscribed" | "3ds_verify" | "captcha_verify" | "cvv_verify" | "ivr_verify" | "otp_verify" | "password_verify" | "phone_verify" | "pin_verify" | "receiver_verify" | "sender_verify" | "senderapp_verify" | "wait_qr" | "wait_sender" | "p24_verify" | "mp_verify" | "cash_wait" | "hold_wait" | "invoice_wait" | "prepared" | "processing" | "wait_accept" | "wait_card" | "wait_compensation" | "wait_lc" | "wait_reserve" | "wait_secure" | "try_again" | undefined;
|
|
29
|
-
waitReserveStatus: boolean | undefined;
|
|
30
|
-
version: 0 | 7 | undefined;
|
|
31
|
-
acqId?: number | undefined;
|
|
32
|
-
agentCommission?: number | undefined;
|
|
33
|
-
amount?: number | undefined;
|
|
34
|
-
amountBonus?: number | undefined;
|
|
35
|
-
amountCredit?: number | undefined;
|
|
36
|
-
amountDebit?: number | undefined;
|
|
37
|
-
authcodeCredit?: string | undefined;
|
|
38
|
-
authcodeDebit?: string | undefined;
|
|
39
|
-
bonusProcent?: number | undefined;
|
|
40
|
-
cardToken?: string | undefined;
|
|
41
|
-
commissionCredit?: number | undefined;
|
|
42
|
-
commissionDebit?: number | undefined;
|
|
43
|
-
confirmPhone?: string | undefined;
|
|
44
|
-
description?: string | undefined;
|
|
45
|
-
info?: string | undefined;
|
|
46
|
-
ip?: string | undefined;
|
|
47
|
-
liqpayOrderId?: string | undefined;
|
|
48
|
-
orderId?: string | undefined;
|
|
49
|
-
paymentId?: number | undefined;
|
|
50
|
-
publicKey?: string | undefined;
|
|
51
|
-
receiverCommission?: number | undefined;
|
|
52
|
-
rrnCredit?: string | undefined;
|
|
53
|
-
rrnDebit?: string | undefined;
|
|
54
|
-
senderBonus?: number | undefined;
|
|
55
|
-
senderCardBank?: string | undefined;
|
|
56
|
-
senderCardCountry?: string | undefined;
|
|
57
|
-
senderCardMask2?: string | undefined;
|
|
58
|
-
senderIban?: string | undefined;
|
|
59
|
-
senderCardType?: string | undefined;
|
|
60
|
-
senderCommission?: number | undefined;
|
|
61
|
-
senderFirstName?: string | undefined;
|
|
62
|
-
senderLastName?: string | undefined;
|
|
63
|
-
senderPhone?: string | undefined;
|
|
64
|
-
transactionId?: number | undefined;
|
|
65
|
-
type?: string | undefined;
|
|
66
|
-
}>>;
|
|
67
|
-
parseCheckoutCallback(envelope: LiqPayEnvelope): Promise<import("../core/schemas/base").LiqPayCallResult<{
|
|
68
|
-
version: 0 | 7 | undefined;
|
|
69
|
-
action: "" | "pay" | "hold" | "paysplit" | "subscribe" | "paydonate" | "auth" | "regular" | "status" | undefined;
|
|
70
|
-
completionDate: Date | undefined;
|
|
71
|
-
createDate: Date | undefined;
|
|
72
|
-
currency: "" | "USD" | "EUR" | "UAH" | undefined;
|
|
73
|
-
currencyCredit: "" | "USD" | "EUR" | "UAH" | undefined;
|
|
74
|
-
currencyDebit: "" | "USD" | "EUR" | "UAH" | undefined;
|
|
75
|
-
endDate: Date | undefined;
|
|
76
|
-
errCode: "" | "5" | "limit" | "frod" | "decline" | "err_auth" | "err_cache" | "user_not_found" | "err_sms_send" | "err_sms_otp" | "shop_blocked" | "shop_not_active" | "invalid_signature" | "order_id_empty" | "err_shop_not_agent" | "err_card_def_notfound" | "err_no_card_token" | "err_card_liqpay_def" | "err_card_type" | "err_card_country" | "err_limit_amount" | "err_payment_amount_limit" | "amount_limit" | "payment_err_sender_card" | "payment_processing" | "err_payment_discount" | "err_wallet" | "err_get_verify_code" | "err_verify_code" | "wait_info" | "err_path" | "err_payment_cash_acq" | "err_split_amount" | "err_card_receiver_def" | "payment_err_status" | "public_key_not_found" | "payment_not_found" | "payment_not_subscribed" | "wrong_amount_currency" | "err_amount_hold" | "err_access" | "order_id_duplicate" | "err_blocked" | "err_empty" | "err_empty_phone" | "err_missing" | "err_wrong" | "err_wrong_currency" | "err_phone" | "err_card" | "err_card_bin" | "err_terminal_notfound" | "err_commission_notfound" | "err_payment_create" | "err_mpi" | "err_currency_is_not_allowed" | "err_look" | "err_mods_empty" | "payment_err_type" | "err_payment_currency" | "err_payment_exchangerates" | "err_signature" | "err_api_action" | "err_api_callback" | "err_api_ip" | "expired_phone" | "expired_3ds" | "expired_otp" | "expired_cvv" | "expired_p24" | "expired_sender" | "expired_pin" | "expired_ivr" | "expired_captcha" | "expired_password" | "expired_senderapp" | "expired_prepared" | "expired_mp" | "expired_qr" | "90" | "101" | "102" | "103" | "104" | "105" | "106" | "107" | "108" | "109" | "110" | "111" | "112" | "113" | "114" | "115" | "2903" | "2915" | "3914" | "9851" | "9852" | "9854" | "9855" | "9857" | "9859" | "9860" | "9861" | "9863" | "9867" | "9868" | "9872" | "9882" | "9886" | "9961" | "9989" | undefined;
|
|
77
|
-
is3ds: boolean | undefined;
|
|
78
|
-
mpiEci: 0 | 5 | 6 | 7 | undefined;
|
|
79
|
-
paytype: "" | "apay" | "gpay" | "card" | "privat24" | "masterpass" | "moment_part" | "paypart" | "cash" | "invoice" | "qr" | undefined;
|
|
80
|
-
refundDateLast: Date | undefined;
|
|
81
|
-
status: "" | "success" | "error" | "failure" | "reversed" | "subscribed" | "unsubscribed" | "3ds_verify" | "captcha_verify" | "cvv_verify" | "ivr_verify" | "otp_verify" | "password_verify" | "phone_verify" | "pin_verify" | "receiver_verify" | "sender_verify" | "senderapp_verify" | "wait_qr" | "wait_sender" | "p24_verify" | "mp_verify" | "cash_wait" | "hold_wait" | "invoice_wait" | "prepared" | "processing" | "wait_accept" | "wait_card" | "wait_compensation" | "wait_lc" | "wait_reserve" | "wait_secure" | "try_again" | undefined;
|
|
82
|
-
waitReserveStatus: boolean | undefined;
|
|
83
|
-
publicKey?: string | undefined;
|
|
84
|
-
acqId?: number | undefined;
|
|
85
|
-
agentCommission?: number | undefined;
|
|
86
|
-
amount?: number | undefined;
|
|
87
|
-
amountBonus?: number | undefined;
|
|
88
|
-
amountCredit?: number | undefined;
|
|
89
|
-
amountDebit?: number | undefined;
|
|
90
|
-
authcodeCredit?: string | undefined;
|
|
91
|
-
authcodeDebit?: string | undefined;
|
|
92
|
-
cardToken?: string | undefined;
|
|
93
|
-
commissionCredit?: number | undefined;
|
|
94
|
-
commissionDebit?: number | undefined;
|
|
95
|
-
customer?: string | undefined;
|
|
96
|
-
description?: string | undefined;
|
|
97
|
-
errDescription?: string | undefined;
|
|
98
|
-
info?: string | undefined;
|
|
99
|
-
ip?: string | undefined;
|
|
100
|
-
liqpayOrderId?: string | undefined;
|
|
101
|
-
orderId?: string | undefined;
|
|
102
|
-
paymentId?: number | undefined;
|
|
103
|
-
receiverCommission?: number | undefined;
|
|
104
|
-
redirectTo?: string | undefined;
|
|
105
|
-
rrnCredit?: string | undefined;
|
|
106
|
-
rrnDebit?: string | undefined;
|
|
107
|
-
senderBonus?: number | undefined;
|
|
108
|
-
senderCardBank?: string | undefined;
|
|
109
|
-
senderCardCountry?: string | undefined;
|
|
110
|
-
senderCardMask2?: string | undefined;
|
|
111
|
-
senderIban?: string | undefined;
|
|
112
|
-
senderCardType?: string | undefined;
|
|
113
|
-
senderCommission?: number | undefined;
|
|
114
|
-
senderFirstName?: string | undefined;
|
|
115
|
-
senderLastName?: string | undefined;
|
|
116
|
-
senderPhone?: string | undefined;
|
|
117
|
-
token?: string | undefined;
|
|
118
|
-
type?: string | undefined;
|
|
119
|
-
errErc?: string | undefined;
|
|
120
|
-
productCategory?: string | undefined;
|
|
121
|
-
productDescription?: string | undefined;
|
|
122
|
-
productName?: string | undefined;
|
|
123
|
-
productUrl?: string | undefined;
|
|
124
|
-
refundAmount?: number | undefined;
|
|
125
|
-
verifycode?: string | undefined;
|
|
126
|
-
}>>;
|
|
127
8
|
}
|
|
@@ -14,42 +14,19 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.LiqpayService = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
|
-
const
|
|
17
|
+
const clients_1 = require("../core/clients");
|
|
18
18
|
const constants_1 = require("./constants");
|
|
19
|
+
const services_1 = require("./services");
|
|
19
20
|
let LiqpayService = class LiqpayService {
|
|
20
21
|
options;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
resultUrl;
|
|
24
|
-
serverUrl;
|
|
25
|
-
client;
|
|
22
|
+
payments;
|
|
23
|
+
webhooks;
|
|
26
24
|
constructor(options) {
|
|
27
25
|
this.options = options;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.client = new liqpay_client_1.LiqPayClient(this.publicKey, this.privateKey);
|
|
33
|
-
}
|
|
34
|
-
getCheckoutUrl(payload) {
|
|
35
|
-
return this.client.getCheckoutUrl({
|
|
36
|
-
...payload,
|
|
37
|
-
resultUrl: payload.resultUrl ?? this.resultUrl,
|
|
38
|
-
serverUrl: payload.serverUrl ?? this.serverUrl,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
getCheckoutForm(payload, buttonText, buttonColor) {
|
|
42
|
-
return this.client.getCheckoutFormButton({
|
|
43
|
-
...payload,
|
|
44
|
-
resultUrl: payload.resultUrl ?? this.resultUrl,
|
|
45
|
-
serverUrl: payload.serverUrl ?? this.serverUrl,
|
|
46
|
-
}, buttonText, buttonColor);
|
|
47
|
-
}
|
|
48
|
-
async getPaymentStatus(orderId) {
|
|
49
|
-
return this.client.getPaymentStatus(orderId);
|
|
50
|
-
}
|
|
51
|
-
async parseCheckoutCallback(envelope) {
|
|
52
|
-
return this.client.parseCheckoutCallback(envelope);
|
|
26
|
+
const { privateKey, publicKey, resultUrl, serverUrl } = options;
|
|
27
|
+
const client = new clients_1.LiqPayClient(publicKey, privateKey, resultUrl ?? '', serverUrl ?? '');
|
|
28
|
+
this.payments = new services_1.LiqPayPaymentsService(client);
|
|
29
|
+
this.webhooks = new services_1.LiqPayWebhooksService(client);
|
|
53
30
|
}
|
|
54
31
|
};
|
|
55
32
|
exports.LiqpayService = LiqpayService;
|
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./payments.service"), exports);
|
|
18
|
+
__exportStar(require("./webhooks.service"), exports);
|