liqpay-nestjs 0.3.2 → 0.3.4

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.
Files changed (42) hide show
  1. package/dist/core/__devtypes/documented/checkout.callback.d.ts +2 -2
  2. package/dist/core/__devtypes/documented/payment-status.response.d.ts +1 -1
  3. package/dist/core/clients/payments.client.d.ts +9 -14
  4. package/dist/core/clients/payments.client.js +22 -7
  5. package/dist/core/types/checkout/{checkout-callback.schema.d.ts → checkout.callback.d.ts} +96 -16
  6. package/dist/core/types/checkout/checkout.callback.js +366 -0
  7. package/dist/core/types/checkout/{checkout-request.d.ts → checkout.request.d.ts} +45 -17
  8. package/dist/core/types/checkout/{checkout-request.js → checkout.request.js} +50 -19
  9. package/dist/core/types/checkout/index.d.ts +2 -2
  10. package/dist/core/types/checkout/index.js +2 -2
  11. package/dist/core/types/common/enums/action.schema.d.ts +36 -3
  12. package/dist/core/types/common/enums/action.schema.js +109 -3
  13. package/dist/core/types/common/enums/card-token-action.schema.d.ts +7 -0
  14. package/dist/core/types/common/enums/card-token-action.schema.js +8 -0
  15. package/dist/core/types/common/enums/invoice-units-action.schema.d.ts +6 -0
  16. package/dist/core/types/common/enums/invoice-units-action.schema.js +11 -0
  17. package/dist/core/types/common/index.d.ts +1 -0
  18. package/dist/core/types/common/index.js +1 -0
  19. package/dist/core/types/error/{error-response.schema.d.ts → error.response.d.ts} +6 -0
  20. package/dist/core/types/error/{error-response.schema.js → error.response.js} +13 -0
  21. package/dist/core/types/error/index.d.ts +1 -1
  22. package/dist/core/types/error/index.js +1 -1
  23. package/dist/core/types/payment-status/index.d.ts +2 -2
  24. package/dist/core/types/payment-status/index.js +2 -2
  25. package/dist/core/types/payment-status/payment-status.request.d.ts +38 -0
  26. package/dist/core/types/payment-status/payment-status.request.js +23 -0
  27. package/dist/core/types/payment-status/{payment-status-response.schema.d.ts → payment-status.response.d.ts} +108 -18
  28. package/dist/core/types/payment-status/payment-status.response.js +341 -0
  29. package/dist/core/utils/transformers.util.d.ts +1 -0
  30. package/dist/core/utils/transformers.util.js +7 -1
  31. package/dist/index.d.ts +10 -9
  32. package/dist/index.js +8 -23
  33. package/dist/nest/services/payments.service.d.ts +8 -13
  34. package/dist/nest/services/payments.service.js +4 -4
  35. package/dist/nest/services/webhooks.service.d.ts +4 -4
  36. package/package.json +1 -1
  37. package/dist/core/types/checkout/checkout-callback.schema.js +0 -93
  38. package/dist/core/types/payment-status/payment-status-request.schema.d.ts +0 -45
  39. package/dist/core/types/payment-status/payment-status-request.schema.js +0 -19
  40. package/dist/core/types/payment-status/payment-status-response.schema.js +0 -87
  41. /package/dist/core/{url.type.d.ts → types/common/url.type.d.ts} +0 -0
  42. /package/dist/core/{url.type.js → types/common/url.type.js} +0 -0
@@ -110,7 +110,7 @@ export interface CheckoutCallback {
110
110
  /**
111
111
  * `Order_id` of payment in the LiqPay system
112
112
  */
113
- _order_id: string;
113
+ liqpay_order_id: string;
114
114
  /**
115
115
  * Code that represents whether 3D-Secure verification was performed during payment. Possible values:
116
116
  * - `5` - the transaction was completed with 3DS (the issuer and acquirer support 3D-Secure technology)
@@ -172,7 +172,7 @@ export interface CheckoutCallback {
172
172
  */
173
173
  sender_card_country: string;
174
174
  /**
175
- * Sender's card
175
+ * Sender's card mask
176
176
  */
177
177
  sender_card_mask2: string;
178
178
  /**
@@ -113,7 +113,7 @@ export interface PaymentStatusResponse {
113
113
  /**
114
114
  * `Order_id` of payment in the LiqPay system
115
115
  */
116
- _order_id: string;
116
+ liqpay_order_id: string;
117
117
  /**
118
118
  * Payment in installments sign
119
119
  */
@@ -1,14 +1,15 @@
1
1
  import { Result } from '../types/base';
2
2
  import { CheckoutInput } from '../types/checkout';
3
- import { Action } from '../types/common/enums';
4
- import { PaymentStatusResponse } from '../types/payment-status';
3
+ import { CheckoutAction } from '../types/common/enums';
4
+ import { PaymentStatusInput, PaymentStatusResponse } from '../types/payment-status';
5
5
  import { UtilsClient } from './utils.client';
6
6
  export declare class PaymentsClient {
7
7
  private readonly utils;
8
8
  constructor(utils: UtilsClient);
9
9
  private prepare;
10
10
  private buildUrl;
11
- pay(payload: CheckoutInput): {
11
+ private checkout;
12
+ getCheckoutUrl(payload: CheckoutInput): {
12
13
  url: string;
13
14
  data: string;
14
15
  signature: string;
@@ -16,8 +17,6 @@ export declare class PaymentsClient {
16
17
  currency: "USD" | "EUR" | "UAH";
17
18
  description: string;
18
19
  orderId: string;
19
- cardToken?: string | undefined;
20
- ip?: string | undefined;
21
20
  fiscalData?: {
22
21
  items?: ({
23
22
  amount: number;
@@ -108,7 +107,7 @@ export declare class PaymentsClient {
108
107
  productUrl?: string | undefined;
109
108
  version: import("../types/common/enums").LiqPayVersion;
110
109
  publicKey: string;
111
- action: Action;
110
+ action: CheckoutAction;
112
111
  };
113
112
  hold(payload: CheckoutInput): {
114
113
  url: string;
@@ -118,8 +117,6 @@ export declare class PaymentsClient {
118
117
  currency: "USD" | "EUR" | "UAH";
119
118
  description: string;
120
119
  orderId: string;
121
- cardToken?: string | undefined;
122
- ip?: string | undefined;
123
120
  fiscalData?: {
124
121
  items?: ({
125
122
  amount: number;
@@ -210,7 +207,7 @@ export declare class PaymentsClient {
210
207
  productUrl?: string | undefined;
211
208
  version: import("../types/common/enums").LiqPayVersion;
212
209
  publicKey: string;
213
- action: Action;
210
+ action: CheckoutAction;
214
211
  };
215
212
  subscribe(payload: CheckoutInput): {
216
213
  url: string;
@@ -220,8 +217,6 @@ export declare class PaymentsClient {
220
217
  currency: "USD" | "EUR" | "UAH";
221
218
  description: string;
222
219
  orderId: string;
223
- cardToken?: string | undefined;
224
- ip?: string | undefined;
225
220
  fiscalData?: {
226
221
  items?: ({
227
222
  amount: number;
@@ -312,8 +307,8 @@ export declare class PaymentsClient {
312
307
  productUrl?: string | undefined;
313
308
  version: import("../types/common/enums").LiqPayVersion;
314
309
  publicKey: string;
315
- action: Action;
310
+ action: CheckoutAction;
316
311
  };
317
- getPayButton(payload: CheckoutInput, buttonText?: string, buttonColor?: string): string;
318
- getStatus(orderId: string): Promise<Result<PaymentStatusResponse>>;
312
+ getCheckoutButton(payload: CheckoutInput, buttonText?: string, buttonColor?: string): string;
313
+ getStatus(payload: PaymentStatusInput): Promise<Result<PaymentStatusResponse>>;
319
314
  }
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PaymentsClient = void 0;
4
4
  const checkout_1 = require("../types/checkout");
5
+ const common_1 = require("../types/common");
5
6
  const payment_status_1 = require("../types/payment-status");
6
- const url_type_1 = require("../url.type");
7
7
  class PaymentsClient {
8
8
  utils;
9
9
  constructor(utils) {
@@ -23,9 +23,18 @@ class PaymentsClient {
23
23
  return { fullfilled, data, signature };
24
24
  }
25
25
  buildUrl(data, signature) {
26
- return `${url_type_1.CHECKOUT_URL}?data=${data}&signature=${signature}`;
26
+ return `${common_1.CHECKOUT_URL}?data=${data}&signature=${signature}`;
27
27
  }
28
- pay(payload) {
28
+ checkout(payload, action) {
29
+ const { fullfilled, data, signature } = this.prepare(payload, action);
30
+ return {
31
+ ...fullfilled,
32
+ url: this.buildUrl(data, signature),
33
+ data,
34
+ signature,
35
+ };
36
+ }
37
+ getCheckoutUrl(payload) {
29
38
  const { fullfilled, data, signature } = this.prepare(payload, 'pay');
30
39
  return {
31
40
  ...fullfilled,
@@ -55,10 +64,10 @@ class PaymentsClient {
55
64
  signature,
56
65
  };
57
66
  }
58
- getPayButton(payload, buttonText = 'Pay', buttonColor = '#77CC5D') {
67
+ getCheckoutButton(payload, buttonText = 'Pay', buttonColor = '#77CC5D') {
59
68
  const { data, signature } = this.prepare(payload, 'pay');
60
69
  return `
61
- <form method="POST" action="${url_type_1.CHECKOUT_URL}" accept-charset="utf-8">
70
+ <form method="POST" action="${common_1.CHECKOUT_URL}" accept-charset="utf-8">
62
71
  <input type="hidden" name="data" value="${data}" />
63
72
  <input type="hidden" name="signature" value="${signature}" />
64
73
  <script type="text/javascript" src="https://static.liqpay.ua/libjs/sdk_button.js"></script>
@@ -66,8 +75,14 @@ class PaymentsClient {
66
75
  </form>
67
76
  `;
68
77
  }
69
- async getStatus(orderId) {
70
- return await this.utils.call({ action: 'status', orderId }, payment_status_1.RawPaymentStatusRequestSchema, payment_status_1.PaymentStatusResponseSchema, url_type_1.REQUEST_URL);
78
+ async getStatus(payload) {
79
+ const request = {
80
+ ...payload,
81
+ action: 'status',
82
+ version: 7,
83
+ publicKey: this.utils.publicKey,
84
+ };
85
+ return await this.utils.call(request, payment_status_1.RawPaymentStatusRequestSchema, payment_status_1.PaymentStatusResponseSchema, common_1.REQUEST_URL);
71
86
  }
72
87
  }
73
88
  exports.PaymentsClient = PaymentsClient;
@@ -1,8 +1,11 @@
1
1
  import { z } from 'zod';
2
+ /**
3
+ * Contract of decoded format of API parameters received in a request from LiqPay after payment
4
+ */
2
5
  export declare const RawCheckoutCallbackSchema: z.ZodObject<{
3
6
  version: z.ZodOptional<z.ZodNumber>;
4
7
  public_key: z.ZodOptional<z.ZodString>;
5
- acq_id: z.ZodOptional<z.ZodNumber>;
8
+ acq_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
6
9
  action: z.ZodOptional<z.ZodString>;
7
10
  agent_commission: z.ZodOptional<z.ZodNumber>;
8
11
  amount: z.ZodOptional<z.ZodNumber>;
@@ -27,10 +30,10 @@ export declare const RawCheckoutCallbackSchema: z.ZodObject<{
27
30
  info: z.ZodOptional<z.ZodString>;
28
31
  ip: z.ZodOptional<z.ZodString>;
29
32
  is_3ds: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
30
- _order_id: z.ZodOptional<z.ZodString>;
33
+ liqpay_order_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
31
34
  mpi_eci: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
32
- order_id: z.ZodOptional<z.ZodString>;
33
- payment_id: z.ZodOptional<z.ZodNumber>;
35
+ order_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
36
+ payment_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
34
37
  paytype: z.ZodOptional<z.ZodString>;
35
38
  receiver_commission: z.ZodOptional<z.ZodNumber>;
36
39
  redirect_to: z.ZodOptional<z.ZodString>;
@@ -60,10 +63,13 @@ export declare const RawCheckoutCallbackSchema: z.ZodObject<{
60
63
  verifycode: z.ZodOptional<z.ZodString>;
61
64
  }, z.core.$strip>;
62
65
  export type RawCheckoutCallback = z.infer<typeof RawCheckoutCallbackSchema>;
66
+ /**
67
+ * Contract of decoded format of API parameters received in a request from LiqPay after payment
68
+ */
63
69
  export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
64
70
  version: z.ZodOptional<z.ZodNumber>;
65
71
  public_key: z.ZodOptional<z.ZodString>;
66
- acq_id: z.ZodOptional<z.ZodNumber>;
72
+ acq_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
67
73
  action: z.ZodOptional<z.ZodString>;
68
74
  agent_commission: z.ZodOptional<z.ZodNumber>;
69
75
  amount: z.ZodOptional<z.ZodNumber>;
@@ -88,10 +94,10 @@ export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
88
94
  info: z.ZodOptional<z.ZodString>;
89
95
  ip: z.ZodOptional<z.ZodString>;
90
96
  is_3ds: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodBoolean]>>;
91
- _order_id: z.ZodOptional<z.ZodString>;
97
+ liqpay_order_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
92
98
  mpi_eci: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
93
- order_id: z.ZodOptional<z.ZodString>;
94
- payment_id: z.ZodOptional<z.ZodNumber>;
99
+ order_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
100
+ payment_id: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
95
101
  paytype: z.ZodOptional<z.ZodString>;
96
102
  receiver_commission: z.ZodOptional<z.ZodNumber>;
97
103
  redirect_to: z.ZodOptional<z.ZodString>;
@@ -120,22 +126,95 @@ export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
120
126
  refund_amount: z.ZodOptional<z.ZodNumber>;
121
127
  verifycode: z.ZodOptional<z.ZodString>;
122
128
  }, z.core.$strip>, z.ZodTransform<Partial<{
129
+ /**
130
+ * API version. Current value is `7`
131
+ */
123
132
  version: 7 | undefined;
133
+ /**
134
+ * Acquirer ID
135
+ */
124
136
  acqId: string | undefined;
125
- action: "pay" | "paytoken" | "hold" | "paysplit" | "subscribe" | "paydonate" | "auth" | "regular" | "status" | undefined;
137
+ /**
138
+ * Operation type. Possible values:
139
+ * - `pay` - payment
140
+ * - `hold` - blocking of funds on the sender's account
141
+ * - `subscribe` - creation of a regular payment
142
+ * - `regular` - regular payment
143
+ */
144
+ action: "pay" | "hold" | "subscribe" | "regular" | undefined;
145
+ /**
146
+ * Date of debiting funds
147
+ */
126
148
  completionDate: Date | undefined;
149
+ /**
150
+ * Payment creation date
151
+ */
127
152
  createDate: Date | undefined;
153
+ /**
154
+ * Payment currency
155
+ */
128
156
  currency: "USD" | "EUR" | "UAH" | undefined;
157
+ /**
158
+ * Transaction currency credit
159
+ */
129
160
  currencyCredit: "USD" | "EUR" | "UAH" | undefined;
161
+ /**
162
+ * Transaction currency debit
163
+ */
130
164
  currencyDebit: "USD" | "EUR" | "UAH" | undefined;
165
+ /**
166
+ * Payment completion/change date
167
+ */
131
168
  endDate: Date | undefined;
169
+ /**
170
+ * Error code
171
+ */
132
172
  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;
173
+ /**
174
+ * Represents whether 3D-Secure verification was performed during payment. Possible values: `true` - the transaction went through with 3DS verification, `false` - the transaction went through without 3DS verification
175
+ */
133
176
  is3ds: boolean | undefined;
177
+ /**
178
+ * `Order_id` of payment in the LiqPay system
179
+ */
180
+ liqpayOrderId: string | undefined;
181
+ /**
182
+ * Code that represents whether 3D-Secure verification was performed during payment. Possible values:
183
+ * - `5` - the transaction was completed with 3DS (the issuer and acquirer support 3D-Secure technology)
184
+ * - `6` - the payer's card issuer does not support 3D-Secure technology
185
+ * - `7` - the transaction was completed without 3D-Secure
186
+ */
134
187
  mpiEci: "5" | "6" | "7" | undefined;
188
+ /**
189
+ * Payment `OrderId`
190
+ */
191
+ orderId: string | undefined;
192
+ /**
193
+ * Payment ID in the LiqPay system
194
+ */
135
195
  paymentId: string | undefined;
136
- paytype: "apay" | "gpay" | "card" | "privat24" | "masterpass" | "moment_part" | "paypart" | "cash" | "invoice" | "qr" | undefined;
196
+ /**
197
+ * Payment method. Possible values:
198
+ * - `card` - payment by card
199
+ * - `privat24` - through the Privat24 account
200
+ * - `masterpass` - through the Masterpass account
201
+ * - `moment_part` - installment
202
+ * - `cash` - by cash
203
+ * - `invoice` - invoice to e-mail
204
+ * - `qr` - by scanning qr code
205
+ */
206
+ paytype: "card" | "privat24" | "masterpass" | "moment_part" | "cash" | "invoice" | "qr" | undefined;
207
+ /**
208
+ * Date of last payment refund
209
+ */
137
210
  refundDateLast: Date | undefined;
211
+ /**
212
+ * Payment status
213
+ */
138
214
  status: "error" | "failure" | "reversed" | "subscribed" | "success" | "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;
215
+ /**
216
+ * An additional payment status indicating that the current payment is reserved for a refund on your store. Possible values: `true` - the payment is reserved for a refund
217
+ */
139
218
  waitReserveStatus: boolean | undefined;
140
219
  publicKey?: string | undefined;
141
220
  agentCommission?: number | undefined;
@@ -153,8 +232,6 @@ export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
153
232
  errDescription?: string | undefined;
154
233
  info?: string | undefined;
155
234
  ip?: string | undefined;
156
- OrderId?: string | undefined;
157
- orderId?: string | undefined;
158
235
  receiverCommission?: number | undefined;
159
236
  redirectTo?: string | undefined;
160
237
  rrnCredit?: string | undefined;
@@ -181,7 +258,7 @@ export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
181
258
  }>, {
182
259
  version?: number | undefined;
183
260
  public_key?: string | undefined;
184
- acq_id?: number | undefined;
261
+ acq_id?: string | number | undefined;
185
262
  action?: string | undefined;
186
263
  agent_commission?: number | undefined;
187
264
  amount?: number | undefined;
@@ -206,10 +283,10 @@ export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
206
283
  info?: string | undefined;
207
284
  ip?: string | undefined;
208
285
  is_3ds?: string | boolean | undefined;
209
- _order_id?: string | undefined;
286
+ liqpay_order_id?: string | number | undefined;
210
287
  mpi_eci?: string | number | undefined;
211
- order_id?: string | undefined;
212
- payment_id?: number | undefined;
288
+ order_id?: string | number | undefined;
289
+ payment_id?: string | number | undefined;
213
290
  paytype?: string | undefined;
214
291
  receiver_commission?: number | undefined;
215
292
  redirect_to?: string | undefined;
@@ -238,4 +315,7 @@ export declare const CheckoutCallbackSchema: z.ZodPipe<z.ZodObject<{
238
315
  refund_amount?: number | undefined;
239
316
  verifycode?: string | undefined;
240
317
  }>>;
318
+ /**
319
+ * Contract of decoded format of API parameters received in a request from LiqPay after payment
320
+ */
241
321
  export type CheckoutCallback = z.infer<typeof CheckoutCallbackSchema>;