platform-types 1.10.856 → 1.10.858

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.
@@ -1,5 +1,5 @@
1
1
  declare global {
2
- type EntityAuditEntity = 'PLAN' | 'STORE' | 'PAYMENT' | 'ORDER' | 'MERCADOPAGO' | 'INVOICE' | 'SUBSCRIPTION' | 'USER' | 'CUSTOMER' | 'INTEGRATION' | 'PLATFORM';
2
+ type EntityAuditEntity = 'PLAN' | 'STORE' | 'PAYMENT' | 'ORDER' | 'MERCADOPAGO' | 'INVOICE' | 'SUBSCRIPTION' | 'USER' | 'CUSTOMER' | 'INTEGRATION' | 'PLATFORM' | 'MSG_PACK';
3
3
  /** Existing business fields with independently projected public metadata. */
4
4
  interface EntityAuditHttpEntry {
5
5
  entity: EntityAuditEntity;
@@ -0,0 +1,181 @@
1
+ /**
2
+ * Online cuenta-corriente payment — a signed-in storefront buyer pays open
3
+ * debits of their own ledger through the store's Mercado Pago Checkout Pro.
4
+ *
5
+ * Available while `Ecommerce.config.onlineBalancePayment` reads `true` on the
6
+ * public store frame: that key carries the VERDICT there (the stored switch AND
7
+ * the `customerAccounts` module on AND Mercado Pago linked AND a peso ledger),
8
+ * never the stored value alone.
9
+ *
10
+ * Which debits can be paid, and in what shape:
11
+ *
12
+ * - `prefix` — the OLDEST open debits, in the order {@link OpenAccountDebitsResponse}
13
+ * lists them, from the first one on, with no gap. The payment credits the
14
+ * customer, and an unstamped credit settles debits oldest-first, so any
15
+ * other selection would settle debits the buyer did not pick.
16
+ * - `order` — exactly one debit linked to an order; the payment credits that
17
+ * order and settles its debit.
18
+ *
19
+ * The amount is always the server's: the remaining balance of the selection,
20
+ * whole. No partial payment of a debit, no free amount, pesos only.
21
+ *
22
+ * ⚠️ Not offered, ever: a refund-in-transit debit (`RIT#…`), and a debit whose
23
+ * order carries a factura de crédito electrónica MiPyME (FCE, `CbteTipo`
24
+ * 201–213 that ARCA did not reject) — collected outside this flow. An orderless
25
+ * debit cannot be tied to a voucher, so it is offered whatever was invoiced.
26
+ *
27
+ * The document the buyer gets is a non-fiscal «Comprobante de pago»
28
+ * numbered `CPG-{n}` per store (`receiptNo`), never a «Recibo».
29
+ */
30
+ declare global {
31
+ /** One of {@link BALANCE_ATTEMPT_MODES}. */
32
+ type BalanceAttemptMode = (typeof BALANCE_ATTEMPT_MODES)[number];
33
+ /**
34
+ * One of {@link BALANCE_ATTEMPT_STATES}.
35
+ *
36
+ * - `created` — the checkout exists; nothing paid yet.
37
+ * - `pending` — a payment was made and Mercado Pago has not decided it.
38
+ * - `rejected` — the last payment was rejected. NOT terminal: Checkout Pro
39
+ * lets the buyer retry inside the same checkout until `expiresAt`.
40
+ * - `approved` — the payment was approved and credited to the ledger;
41
+ * `receiptNo` and `paidAt` are set.
42
+ * - `expired` — `expiresAt` passed with nothing approved. Nothing else
43
+ * changes: no order is cancelled and no ledger row is written.
44
+ * - `resolution` — money landed that was not credited on its own (an amount
45
+ * other than the one frozen at the start, a payment after the checkout
46
+ * expired). The store reviews it; show it as under review.
47
+ * - `refunded` — the approved payment was refunded in Mercado Pago. The
48
+ * credit stays on the ledger until the store reverses it.
49
+ * - `charged_back` — the approved payment was charged back. Same as
50
+ * `refunded` for the ledger.
51
+ */
52
+ type BalanceAttemptState = (typeof BALANCE_ATTEMPT_STATES)[number];
53
+ /** One of {@link BALANCE_PAYMENT_ERROR_CODES}. */
54
+ type BalancePaymentErrorCode = (typeof BALANCE_PAYMENT_ERROR_CODES)[number];
55
+ /**
56
+ * Web `GET /account?mode=open-debits` — every other query key is ignored.
57
+ * The caller's own ledger (the token's customer), allocated by the shared
58
+ * allocator (`allocateAccountLedger`).
59
+ */
60
+ interface WebAccountOpenDebitsQuery {
61
+ mode: 'open-debits';
62
+ }
63
+ /** One open debit the buyer may pay online. Amounts are decimal units of `ledgerCurrency`. */
64
+ interface OpenAccountDebit {
65
+ /** The ACCOUNT row's id (`ACC#{orderId}` for an order's debit, a UUID for a manual one) — what a start sends. */
66
+ accountId: string;
67
+ /** Absent on an orderless debit, which only a `prefix` start can pay. */
68
+ orderId?: string;
69
+ /** `YYYYMMDD` ledger day of the debit. */
70
+ dated: number;
71
+ /** `YYYYMMDD` due day stamped on the row; absent means unspecified. */
72
+ dueDate?: number;
73
+ /** The row's own text, verbatim. */
74
+ details?: string;
75
+ /** The debit as written. */
76
+ original: number;
77
+ /** What is still owed on it — the amount a start charges for it. Always above zero. */
78
+ remaining: number;
79
+ }
80
+ /** `data` of web `GET /account?mode=open-debits`. */
81
+ interface OpenAccountDebitsResponse {
82
+ /**
83
+ * The payable open debits, OLDEST FIRST in allocation order (when each was
84
+ * written, `createdAt` — not `dated`, which a backdated row bends). A
85
+ * `prefix` start names the first N of them.
86
+ */
87
+ debits: OpenAccountDebit[];
88
+ /**
89
+ * How many leading entries of `debits` a `prefix` start may cover: the run
90
+ * before the first open debit that cannot be paid online. Every entry after
91
+ * it can only be paid on its own, as `mode: 'order'`, and an orderless one
92
+ * after it not at all. Equals `debits.length` when nothing blocks.
93
+ */
94
+ prefixLength: number;
95
+ /** The ledger's catalog id (`ars`). Every amount here is in it. */
96
+ ledgerCurrency: string;
97
+ /**
98
+ * The whole ledger's balance, sign as `Customer.balance`: positive is owed
99
+ * by the customer, negative is credit the store holds for them.
100
+ */
101
+ balance: number;
102
+ }
103
+ /**
104
+ * Web `POST /payments/balance-attempts` body. Any other key — an amount
105
+ * included — is dropped by the parse: the server prices the selection.
106
+ */
107
+ interface StartBalanceAttemptRequest {
108
+ /** 1–{@link BALANCE_ATTEMPT_MAX_DEBITS} distinct `OpenAccountDebit.accountId`s; exactly one for `order`. */
109
+ accountIds: string[];
110
+ mode: BalanceAttemptMode;
111
+ }
112
+ /** `data` of web `POST /payments/balance-attempts`. */
113
+ interface StartBalanceAttemptResponse {
114
+ /** `BAT-{customerId}-{seq}`. */
115
+ attemptId: string;
116
+ /** The Mercado Pago checkout URL to send the buyer to. */
117
+ redirectUrl: string;
118
+ /** ISO 8601. After it the checkout no longer takes a payment. */
119
+ expiresAt: string;
120
+ /** Decimal pesos — what the checkout charges, computed by the server. */
121
+ amount: number;
122
+ }
123
+ /** `data` of `409 BALANCE_SELECTION_STALE`: the fresh payable list, as `GET /account?mode=open-debits` answers it. */
124
+ interface BalanceSelectionStaleData {
125
+ debits: OpenAccountDebit[];
126
+ prefixLength: number;
127
+ }
128
+ /** `data` of web `GET /payments/balance-attempts/{attemptId}` — the caller's own attempt only. */
129
+ interface BalanceAttemptView {
130
+ state: BalanceAttemptState;
131
+ /** Decimal pesos, frozen at the start. */
132
+ amount: number;
133
+ /** Unix ms the payment was approved. Set with `approved`. */
134
+ paidAt?: number;
135
+ /** The «Comprobante de pago» number, `CPG-{n}`. Set with `approved`. */
136
+ receiptNo?: string;
137
+ /** The debits the start priced, as sent. */
138
+ accountIds: string[];
139
+ }
140
+ /**
141
+ * `data` of the `balancePaymentAttempt` socket frame — sent to the attempt's
142
+ * OWN customer (`wsPostCustomer`) once per committed state move. Ids and the
143
+ * state only: re-read `GET /payments/balance-attempts/{attemptId}` for the
144
+ * rest. An approval also sends the existing `account` frame (the customer row
145
+ * with its new balance).
146
+ */
147
+ interface BalancePaymentAttemptFrameData {
148
+ attemptId: string;
149
+ state: BalanceAttemptState;
150
+ /** The «Comprobante de pago» number, `CPG-{n}`. Set from `approved` on. */
151
+ receiptNo?: string;
152
+ }
153
+ }
154
+ /** Every `mode` of {@link StartBalanceAttemptRequest}. */
155
+ export declare const BALANCE_ATTEMPT_MODES: readonly ["prefix", "order"];
156
+ /** Every {@link BalanceAttemptState}. */
157
+ export declare const BALANCE_ATTEMPT_STATES: readonly ["created", "pending", "rejected", "approved", "expired", "resolution", "refunded", "charged_back"];
158
+ /** The most debits one start may name. */
159
+ export declare const BALANCE_ATTEMPT_MAX_DEBITS = 50;
160
+ /**
161
+ * The refusals of the balance-payment routes, beside the shared ones they reuse
162
+ * (`PAYMENT_PROVIDER_NOT_CONNECTED` 412, `PAYMENT_PROVIDER_TOKEN_EXPIRED` 412,
163
+ * `MP_PREFERENCE_CREATE_FAILED` 502, `PLATFORM_INTEGRATION_DISABLED` 503,
164
+ * `CUSTOMER_LEDGER_TRUNCATED` 503, `VALIDATION_FAILED` 400):
165
+ *
166
+ * - `BALANCE_PAYMENT_DISABLED` · 403 — the store does not take online balance
167
+ * payments: the switch is off or the `customerAccounts` module is. On
168
+ * `GET /account?mode=open-debits` also when Mercado Pago is not linked or the
169
+ * ledger is not in pesos (the start answers those 412 / 422).
170
+ * - `BALANCE_CURRENCY_UNSUPPORTED` · 422 — the ledger is not in pesos.
171
+ * - `BALANCE_SELECTION_STALE` · 409 — a selected debit is not among the payable
172
+ * open debits any more (paid meanwhile, or never offered); `data` is
173
+ * {@link BalanceSelectionStaleData}.
174
+ * - `BALANCE_SELECTION_NOT_PREFIX` · 409 — every debit is payable, but not in
175
+ * this shape: `prefix` — not the first N of the list, or past `prefixLength`;
176
+ * `order` — an orderless debit, or not the oldest open debit of its order.
177
+ * - `BALANCE_NOTHING_OWED` · 409 — the selection owes nothing.
178
+ * - `BALANCE_ATTEMPT_NOT_FOUND` · 404 — no such attempt of the caller's.
179
+ */
180
+ export declare const BALANCE_PAYMENT_ERROR_CODES: readonly ["BALANCE_PAYMENT_DISABLED", "BALANCE_CURRENCY_UNSUPPORTED", "BALANCE_SELECTION_STALE", "BALANCE_SELECTION_NOT_PREFIX", "BALANCE_NOTHING_OWED", "BALANCE_ATTEMPT_NOT_FOUND"];
181
+ export {};
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Online cuenta-corriente payment — a signed-in storefront buyer pays open
3
+ * debits of their own ledger through the store's Mercado Pago Checkout Pro.
4
+ *
5
+ * Available while `Ecommerce.config.onlineBalancePayment` reads `true` on the
6
+ * public store frame: that key carries the VERDICT there (the stored switch AND
7
+ * the `customerAccounts` module on AND Mercado Pago linked AND a peso ledger),
8
+ * never the stored value alone.
9
+ *
10
+ * Which debits can be paid, and in what shape:
11
+ *
12
+ * - `prefix` — the OLDEST open debits, in the order {@link OpenAccountDebitsResponse}
13
+ * lists them, from the first one on, with no gap. The payment credits the
14
+ * customer, and an unstamped credit settles debits oldest-first, so any
15
+ * other selection would settle debits the buyer did not pick.
16
+ * - `order` — exactly one debit linked to an order; the payment credits that
17
+ * order and settles its debit.
18
+ *
19
+ * The amount is always the server's: the remaining balance of the selection,
20
+ * whole. No partial payment of a debit, no free amount, pesos only.
21
+ *
22
+ * ⚠️ Not offered, ever: a refund-in-transit debit (`RIT#…`), and a debit whose
23
+ * order carries a factura de crédito electrónica MiPyME (FCE, `CbteTipo`
24
+ * 201–213 that ARCA did not reject) — collected outside this flow. An orderless
25
+ * debit cannot be tied to a voucher, so it is offered whatever was invoiced.
26
+ *
27
+ * The document the buyer gets is a non-fiscal «Comprobante de pago»
28
+ * numbered `CPG-{n}` per store (`receiptNo`), never a «Recibo».
29
+ */
30
+ /** Every `mode` of {@link StartBalanceAttemptRequest}. */
31
+ export const BALANCE_ATTEMPT_MODES = ['prefix', 'order'];
32
+ /** Every {@link BalanceAttemptState}. */
33
+ export const BALANCE_ATTEMPT_STATES = [
34
+ 'created',
35
+ 'pending',
36
+ 'rejected',
37
+ 'approved',
38
+ 'expired',
39
+ 'resolution',
40
+ 'refunded',
41
+ 'charged_back',
42
+ ];
43
+ /** The most debits one start may name. */
44
+ export const BALANCE_ATTEMPT_MAX_DEBITS = 50;
45
+ /**
46
+ * The refusals of the balance-payment routes, beside the shared ones they reuse
47
+ * (`PAYMENT_PROVIDER_NOT_CONNECTED` 412, `PAYMENT_PROVIDER_TOKEN_EXPIRED` 412,
48
+ * `MP_PREFERENCE_CREATE_FAILED` 502, `PLATFORM_INTEGRATION_DISABLED` 503,
49
+ * `CUSTOMER_LEDGER_TRUNCATED` 503, `VALIDATION_FAILED` 400):
50
+ *
51
+ * - `BALANCE_PAYMENT_DISABLED` · 403 — the store does not take online balance
52
+ * payments: the switch is off or the `customerAccounts` module is. On
53
+ * `GET /account?mode=open-debits` also when Mercado Pago is not linked or the
54
+ * ledger is not in pesos (the start answers those 412 / 422).
55
+ * - `BALANCE_CURRENCY_UNSUPPORTED` · 422 — the ledger is not in pesos.
56
+ * - `BALANCE_SELECTION_STALE` · 409 — a selected debit is not among the payable
57
+ * open debits any more (paid meanwhile, or never offered); `data` is
58
+ * {@link BalanceSelectionStaleData}.
59
+ * - `BALANCE_SELECTION_NOT_PREFIX` · 409 — every debit is payable, but not in
60
+ * this shape: `prefix` — not the first N of the list, or past `prefixLength`;
61
+ * `order` — an orderless debit, or not the oldest open debit of its order.
62
+ * - `BALANCE_NOTHING_OWED` · 409 — the selection owes nothing.
63
+ * - `BALANCE_ATTEMPT_NOT_FOUND` · 404 — no such attempt of the caller's.
64
+ */
65
+ export const BALANCE_PAYMENT_ERROR_CODES = [
66
+ 'BALANCE_PAYMENT_DISABLED',
67
+ 'BALANCE_CURRENCY_UNSUPPORTED',
68
+ 'BALANCE_SELECTION_STALE',
69
+ 'BALANCE_SELECTION_NOT_PREFIX',
70
+ 'BALANCE_NOTHING_OWED',
71
+ 'BALANCE_ATTEMPT_NOT_FOUND',
72
+ ];
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ /**
3
+ * Online cuenta-corriente payment — a signed-in storefront buyer pays open
4
+ * debits of their own ledger through the store's Mercado Pago Checkout Pro.
5
+ *
6
+ * Available while `Ecommerce.config.onlineBalancePayment` reads `true` on the
7
+ * public store frame: that key carries the VERDICT there (the stored switch AND
8
+ * the `customerAccounts` module on AND Mercado Pago linked AND a peso ledger),
9
+ * never the stored value alone.
10
+ *
11
+ * Which debits can be paid, and in what shape:
12
+ *
13
+ * - `prefix` — the OLDEST open debits, in the order {@link OpenAccountDebitsResponse}
14
+ * lists them, from the first one on, with no gap. The payment credits the
15
+ * customer, and an unstamped credit settles debits oldest-first, so any
16
+ * other selection would settle debits the buyer did not pick.
17
+ * - `order` — exactly one debit linked to an order; the payment credits that
18
+ * order and settles its debit.
19
+ *
20
+ * The amount is always the server's: the remaining balance of the selection,
21
+ * whole. No partial payment of a debit, no free amount, pesos only.
22
+ *
23
+ * ⚠️ Not offered, ever: a refund-in-transit debit (`RIT#…`), and a debit whose
24
+ * order carries a factura de crédito electrónica MiPyME (FCE, `CbteTipo`
25
+ * 201–213 that ARCA did not reject) — collected outside this flow. An orderless
26
+ * debit cannot be tied to a voucher, so it is offered whatever was invoiced.
27
+ *
28
+ * The document the buyer gets is a non-fiscal «Comprobante de pago»
29
+ * numbered `CPG-{n}` per store (`receiptNo`), never a «Recibo».
30
+ */
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ exports.BALANCE_PAYMENT_ERROR_CODES = exports.BALANCE_ATTEMPT_MAX_DEBITS = exports.BALANCE_ATTEMPT_STATES = exports.BALANCE_ATTEMPT_MODES = void 0;
33
+ /** Every `mode` of {@link StartBalanceAttemptRequest}. */
34
+ exports.BALANCE_ATTEMPT_MODES = ['prefix', 'order'];
35
+ /** Every {@link BalanceAttemptState}. */
36
+ exports.BALANCE_ATTEMPT_STATES = [
37
+ 'created',
38
+ 'pending',
39
+ 'rejected',
40
+ 'approved',
41
+ 'expired',
42
+ 'resolution',
43
+ 'refunded',
44
+ 'charged_back',
45
+ ];
46
+ /** The most debits one start may name. */
47
+ exports.BALANCE_ATTEMPT_MAX_DEBITS = 50;
48
+ /**
49
+ * The refusals of the balance-payment routes, beside the shared ones they reuse
50
+ * (`PAYMENT_PROVIDER_NOT_CONNECTED` 412, `PAYMENT_PROVIDER_TOKEN_EXPIRED` 412,
51
+ * `MP_PREFERENCE_CREATE_FAILED` 502, `PLATFORM_INTEGRATION_DISABLED` 503,
52
+ * `CUSTOMER_LEDGER_TRUNCATED` 503, `VALIDATION_FAILED` 400):
53
+ *
54
+ * - `BALANCE_PAYMENT_DISABLED` · 403 — the store does not take online balance
55
+ * payments: the switch is off or the `customerAccounts` module is. On
56
+ * `GET /account?mode=open-debits` also when Mercado Pago is not linked or the
57
+ * ledger is not in pesos (the start answers those 412 / 422).
58
+ * - `BALANCE_CURRENCY_UNSUPPORTED` · 422 — the ledger is not in pesos.
59
+ * - `BALANCE_SELECTION_STALE` · 409 — a selected debit is not among the payable
60
+ * open debits any more (paid meanwhile, or never offered); `data` is
61
+ * {@link BalanceSelectionStaleData}.
62
+ * - `BALANCE_SELECTION_NOT_PREFIX` · 409 — every debit is payable, but not in
63
+ * this shape: `prefix` — not the first N of the list, or past `prefixLength`;
64
+ * `order` — an orderless debit, or not the oldest open debit of its order.
65
+ * - `BALANCE_NOTHING_OWED` · 409 — the selection owes nothing.
66
+ * - `BALANCE_ATTEMPT_NOT_FOUND` · 404 — no such attempt of the caller's.
67
+ */
68
+ exports.BALANCE_PAYMENT_ERROR_CODES = [
69
+ 'BALANCE_PAYMENT_DISABLED',
70
+ 'BALANCE_CURRENCY_UNSUPPORTED',
71
+ 'BALANCE_SELECTION_STALE',
72
+ 'BALANCE_SELECTION_NOT_PREFIX',
73
+ 'BALANCE_NOTHING_OWED',
74
+ 'BALANCE_ATTEMPT_NOT_FOUND',
75
+ ];
package/dist/cjs/index.js CHANGED
@@ -32,6 +32,7 @@ __exportStar(require("./audit.js"), exports);
32
32
  __exportStar(require("./auditEnvelope.js"), exports);
33
33
  __exportStar(require("./attendance.js"), exports);
34
34
  __exportStar(require("./auth.js"), exports);
35
+ __exportStar(require("./balancePayment.js"), exports);
35
36
  __exportStar(require("./basket.js"), exports);
36
37
  __exportStar(require("./attributes.js"), exports);
37
38
  __exportStar(require("./brands.js"), exports);
@@ -8,7 +8,7 @@
8
8
  * modification, or distribution is strictly prohibited.
9
9
  */
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.STORE_MESSAGE_SKIP_REASONS = exports.STORE_MESSAGE_STATUSES = exports.MESSAGE_DELIVERY_STAMPS = exports.MESSAGE_LEDGER_KINDS = exports.MESSAGE_CREDITS_PER_CHANNEL = exports.MESSAGE_ALLOWANCE_UNLIMITED = exports.SMS_FALLBACK_CREDITS = exports.WHATSAPP_MESSAGE_CREDITS = exports.MESSAGE_LEDGER_OPERATOR_ONLY_FIELDS = void 0;
11
+ exports.STORE_MESSAGE_SKIP_REASONS = exports.STORE_MESSAGE_STATUSES = exports.MESSAGE_DELIVERY_STAMPS = exports.MESSAGE_PACK_CURRENCY = exports.MESSAGE_LEDGER_KINDS = exports.MESSAGE_CREDITS_PER_CHANNEL = exports.MESSAGE_ALLOWANCE_UNLIMITED = exports.SMS_FALLBACK_CREDITS = exports.WHATSAPP_MESSAGE_CREDITS = exports.MESSAGE_LEDGER_OPERATOR_ONLY_FIELDS = void 0;
12
12
  /**
13
13
  * Fields a store's own ledger read drops from an `adjustment` entry: it is a
14
14
  * platform operator act, and its `actor`, `reason` and `refId` (the
@@ -41,7 +41,10 @@ exports.MESSAGE_LEDGER_KINDS = [
41
41
  'allowance-grant',
42
42
  'purchase',
43
43
  'adjustment',
44
+ 'reversal',
44
45
  ];
46
+ /** `MessagePack.currency` — the only one a pack is sold in. */
47
+ exports.MESSAGE_PACK_CURRENCY = 'ARS';
45
48
  exports.MESSAGE_DELIVERY_STAMPS = [
46
49
  'delivered',
47
50
  'read',
@@ -6,7 +6,7 @@ exports.WEB_NOTIFICATIONS_MAX_LIMIT = exports.CUSTOMER_NOTIFICATION_TYPES = expo
6
6
  // legacy opt-ins and explicit channel maps remain source data on USER rows.
7
7
  // Addressed ERROR / ML_FACTURADOR_COLLISION / ML_SELLER_SWITCHED /
8
8
  // ML_CONNECTION_BROKEN / MENTION / CUSTOMER_PENDING_APPROVAL /
9
- // PAYMENT_ATTEMPT_RESOLUTION / CUSTOMER_WHOLESALE_REQUEST / STOREFRONT_QUOTE_REQUEST /
9
+ // PAYMENT_ATTEMPT_RESOLUTION / BALANCE_PAID_ONLINE / CUSTOMER_WHOLESALE_REQUEST / STOREFRONT_QUOTE_REQUEST /
10
10
  // SERVICE_QUOTE_DECIDED /
11
11
  // REFUND_OBLIGATION_OVERDUE / MESSAGE_CREDITS_LOW / MESSAGE_SKIPPED_NO_CREDITS do not select a
12
12
  // producer subscriber audience;
@@ -202,6 +202,18 @@ var NotificationTypeEnum;
202
202
  * re-opens rings again.
203
203
  */
204
204
  NotificationTypeEnum["PAYMENT_ATTEMPT_RESOLUTION"] = "PAYMENT_ATTEMPT_RESOLUTION";
205
+ /**
206
+ * A signed-in buyer paid open cuenta-corriente debits online through Mercado
207
+ * Pago, and the credit landed on their ledger with its «Comprobante de pago»
208
+ * number. Carries {@link NotificationInterface.customerRef} and
209
+ * {@link NotificationInterface.balanceAttemptId} — pointers, never the buyer's
210
+ * name or contact.
211
+ *
212
+ * ⚠️ ADMIN-ONLY, as `PAYMENT_ATTEMPT_RESOLUTION`: one bell per non-disabled
213
+ * ADMIN of the store (`listActiveAdmins`), after the credit committed,
214
+ * best-effort. Its own preference key, default-on when absent; seeded nowhere.
215
+ */
216
+ NotificationTypeEnum["BALANCE_PAID_ONLINE"] = "BALANCE_PAID_ONLINE";
205
217
  /**
206
218
  * A signed-in storefront buyer asked for a wholesale account
207
219
  * (`POST /user { mode: 'wholesale-request' }`) and the request waits in the
@@ -519,6 +519,15 @@ exports.SOCKET_ACTIONS = [
519
519
  * customer broadcast. Sent once per committed state move of the attempt.
520
520
  */
521
521
  'orderPaymentAttempt',
522
+ /**
523
+ * A signed-in buyer's online cuenta-corriente payment attempt changed state.
524
+ * `data` is `BalancePaymentAttemptFrameData` (`balancePayment.ts`) — the
525
+ * attempt id, its state and, once approved, its receipt number.
526
+ *
527
+ * ⚠️ To the attempt's OWN customer only (`wsPostCustomer`), never a
528
+ * store-wide customer broadcast. Sent once per committed state move.
529
+ */
530
+ 'balancePaymentAttempt',
522
531
  /**
523
532
  * A storefront order's delivery was created or moved. `data` is
524
533
  * `OrderDeliveryFrameData` (`delivery.ts`) — the order id and the minimised
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from './audit.ts';
8
8
  export * from './auditEnvelope.ts';
9
9
  export * from './attendance.ts';
10
10
  export * from './auth.ts';
11
+ export * from './balancePayment.ts';
11
12
  export * from './basket.ts';
12
13
  export * from './attributes.ts';
13
14
  export * from './brands.ts';
package/dist/index.js CHANGED
@@ -16,6 +16,7 @@ export * from "./audit.js";
16
16
  export * from "./auditEnvelope.js";
17
17
  export * from "./attendance.js";
18
18
  export * from "./auth.js";
19
+ export * from "./balancePayment.js";
19
20
  export * from "./basket.js";
20
21
  export * from "./attributes.js";
21
22
  export * from "./brands.js";
@@ -14,8 +14,12 @@ declare global {
14
14
  * - `adjustment` — a MANAGER/SUPERVISOR correction of the bought balance,
15
15
  * either sign, with `actor` and `reason` — operator-only, with its `refId`:
16
16
  * the store's own ledger read drops them (`MESSAGE_LEDGER_OPERATOR_ONLY_FIELDS`).
17
+ * - `reversal` — a pack payment refunded or charged back: the credits its
18
+ * `purchase` added are taken back (`credits` < 0, `refId` the provider
19
+ * payment id). Credits already spent are not refused: the bought balance
20
+ * goes below zero by the rest, and only this kind can take it there.
17
21
  */
18
- type MessageLedgerKind = 'debit' | 'refund' | 'allowance-grant' | 'purchase' | 'adjustment';
22
+ type MessageLedgerKind = 'debit' | 'refund' | 'allowance-grant' | 'purchase' | 'adjustment' | 'reversal';
19
23
  /**
20
24
  * How a debited message ended, stamped on its `debit` entry by the sending
21
25
  * pipeline — the ONE field written after the entry lands. Absent means
@@ -51,7 +55,7 @@ declare global {
51
55
  /** The allowance period (`YYYY-MM`, Buenos Aires) the entry was written in. */
52
56
  period: string;
53
57
  createdAt: number;
54
- /** The reservation a `debit`/`refund` belongs to, the purchase id, or the adjustment id. */
58
+ /** The reservation a `debit`/`refund` belongs to, the purchase id, the adjustment id, or a `reversal`'s payment id. */
55
59
  refId?: string;
56
60
  /** `debit` and `refund` only. */
57
61
  noticeType?: StoreMessageNotice;
@@ -71,7 +75,12 @@ declare global {
71
75
  }
72
76
  /** The store's credits right now, the period already rolled forward when it has ended. */
73
77
  interface MessageBalanceView {
74
- /** Bought credits, never below zero. */
78
+ /**
79
+ * Bought credits. Below zero only after a pack payment was reversed when
80
+ * its credits were already spent (`reversal`): then nothing more is
81
+ * spent from it until a purchase brings it back up, and `available`
82
+ * counts it as `0`.
83
+ */
75
84
  balance: number;
76
85
  /** The current allowance period (`YYYY-MM`, Buenos Aires). */
77
86
  period: string;
@@ -80,7 +89,7 @@ declare global {
80
89
  allowanceUsed: number;
81
90
  /** `max(0, allowanceLimit - allowanceUsed)`; `-1` when unlimited. */
82
91
  allowanceLeft: number;
83
- /** `allowanceLeft + balance` — what the next messages can spend; `-1` when unlimited. */
92
+ /** `allowanceLeft + max(0, balance)` — what the next messages can spend; `-1` when unlimited. */
84
93
  available: number;
85
94
  }
86
95
  /** One page of the ledger, newest first. `cursor` present only when more may follow. */
@@ -209,6 +218,74 @@ declare global {
209
218
  serviceOrderId?: string;
210
219
  messageNotices: MessageNoticeListItem[];
211
220
  }
221
+ /**
222
+ * One message pack of the platform catalogue (`MSG_PACK` / `PACK00n`), as a
223
+ * MANAGER reads it on `GET /platform/billing/message-packs`. Prices are the
224
+ * operator's: a reprice is a `PATCH`, never a release. A pack already paid
225
+ * keeps the credits it was bought with — the checkout freezes them.
226
+ */
227
+ interface MessagePack {
228
+ /** `PACK001`, `PACK002`, … — minted on create, never reused. */
229
+ packId: string;
230
+ name: string;
231
+ /** Whole credits the pack adds to the bought balance, 1–1 000 000. */
232
+ credits: number;
233
+ /** The price in centavos, at least 1 (MercadoPago refuses a zero price). */
234
+ priceCents: number;
235
+ currency: MessagePackCurrency;
236
+ /** An inactive pack is not listed to stores and cannot be checked out. */
237
+ active: boolean;
238
+ /** Ascending order on the store's list. */
239
+ displayOrder: number;
240
+ createdAt: number;
241
+ updatedAt: number;
242
+ }
243
+ /** The only currency a pack is sold in. */
244
+ type MessagePackCurrency = 'ARS';
245
+ /** A pack as a STORE reads it (`GET /message-credits?mode=packs`): active packs only, no bookkeeping. */
246
+ interface StoreMessagePack {
247
+ packId: string;
248
+ name: string;
249
+ credits: number;
250
+ priceCents: number;
251
+ currency: MessagePackCurrency;
252
+ displayOrder: number;
253
+ }
254
+ /** `POST /platform/billing/message-packs` (managerToken). */
255
+ interface MessagePackCreateRequest {
256
+ name: string;
257
+ credits: number;
258
+ priceCents: number;
259
+ /** Defaults to `ARS`, the only value accepted. */
260
+ currency?: MessagePackCurrency;
261
+ /** Defaults to `true`. */
262
+ active?: boolean;
263
+ /** Defaults to `0`. */
264
+ displayOrder?: number;
265
+ /** 10–500 characters, no personal data — lands on the permanent `AUDIT#MSG_PACK#` row. */
266
+ reason: string;
267
+ }
268
+ /** `PATCH /platform/billing/message-packs/{packId}` (managerToken): at least one field besides `reason`. */
269
+ interface MessagePackUpdateRequest {
270
+ name?: string;
271
+ credits?: number;
272
+ priceCents?: number;
273
+ active?: boolean;
274
+ displayOrder?: number;
275
+ /** 10–500 characters, no personal data — lands on the permanent `AUDIT#MSG_PACK#` row. */
276
+ reason: string;
277
+ }
278
+ /** `POST /subscription/message-packs/checkout` (adminToken). */
279
+ interface MessagePackCheckoutRequest {
280
+ packId: string;
281
+ successUrl: string;
282
+ cancelUrl: string;
283
+ }
284
+ /** The MercadoPago Checkout the store pays the pack on; redirect to `initPoint`. */
285
+ interface MessagePackCheckoutResult {
286
+ initPoint: string;
287
+ preferenceId: string;
288
+ }
212
289
  interface MessageCreditAdjustmentResult {
213
290
  storeId: string;
214
291
  /** The `adjustment` ledger entry. */
@@ -241,7 +318,9 @@ export declare const MESSAGE_CREDITS_PER_CHANNEL: {
241
318
  readonly whatsapp: 1;
242
319
  readonly sms: 3;
243
320
  };
244
- export declare const MESSAGE_LEDGER_KINDS: readonly ["debit", "refund", "allowance-grant", "purchase", "adjustment"];
321
+ export declare const MESSAGE_LEDGER_KINDS: readonly ["debit", "refund", "allowance-grant", "purchase", "adjustment", "reversal"];
322
+ /** `MessagePack.currency` — the only one a pack is sold in. */
323
+ export declare const MESSAGE_PACK_CURRENCY: "ARS";
245
324
  export declare const MESSAGE_DELIVERY_STAMPS: readonly ["delivered", "read", "failed"];
246
325
  export declare const STORE_MESSAGE_STATUSES: readonly ["queued", "sending", "sent", "delivered", "read", "failed", "undelivered", "skipped"];
247
326
  export declare const STORE_MESSAGE_SKIP_REASONS: readonly ["switched-off", "no-consent", "no-phone", "no-credits", "not-configured", "messaging-disabled"];
package/dist/messaging.js CHANGED
@@ -38,7 +38,10 @@ export const MESSAGE_LEDGER_KINDS = [
38
38
  'allowance-grant',
39
39
  'purchase',
40
40
  'adjustment',
41
+ 'reversal',
41
42
  ];
43
+ /** `MessagePack.currency` — the only one a pack is sold in. */
44
+ export const MESSAGE_PACK_CURRENCY = 'ARS';
42
45
  export const MESSAGE_DELIVERY_STAMPS = [
43
46
  'delivered',
44
47
  'read',
@@ -178,6 +178,18 @@ export declare enum NotificationTypeEnum {
178
178
  * re-opens rings again.
179
179
  */
180
180
  PAYMENT_ATTEMPT_RESOLUTION = "PAYMENT_ATTEMPT_RESOLUTION",
181
+ /**
182
+ * A signed-in buyer paid open cuenta-corriente debits online through Mercado
183
+ * Pago, and the credit landed on their ledger with its «Comprobante de pago»
184
+ * number. Carries {@link NotificationInterface.customerRef} and
185
+ * {@link NotificationInterface.balanceAttemptId} — pointers, never the buyer's
186
+ * name or contact.
187
+ *
188
+ * ⚠️ ADMIN-ONLY, as `PAYMENT_ATTEMPT_RESOLUTION`: one bell per non-disabled
189
+ * ADMIN of the store (`listActiveAdmins`), after the credit committed,
190
+ * best-effort. Its own preference key, default-on when absent; seeded nowhere.
191
+ */
192
+ BALANCE_PAID_ONLINE = "BALANCE_PAID_ONLINE",
181
193
  /**
182
194
  * A signed-in storefront buyer asked for a wholesale account
183
195
  * (`POST /user { mode: 'wholesale-request' }`) and the request waits in the
@@ -344,6 +356,14 @@ declare global {
344
356
  /** The row's `emailVerified` at registration — `false` when the address is still unproven. */
345
357
  emailVerified: boolean;
346
358
  }
359
+ /**
360
+ * Which customer a `BALANCE_PAID_ONLINE` bell is about. A POINTER, never an
361
+ * audience — the top-level `customerId` would deliver the bell to the buyer.
362
+ * Operator surfaces only.
363
+ */
364
+ interface BalancePaidCustomerRef {
365
+ customerId: string;
366
+ }
347
367
  interface NotificationInterface {
348
368
  storeId: string;
349
369
  notificationId: string;
@@ -406,6 +426,16 @@ declare global {
406
426
  * an audience — see {@link ServiceOrderRef}. Operator surfaces only.
407
427
  */
408
428
  serviceOrderRef?: ServiceOrderRef;
429
+ /**
430
+ * `BALANCE_PAID_ONLINE` only: which customer paid. A POINTER, not an
431
+ * audience — see {@link BalancePaidCustomerRef}. Operator surfaces only.
432
+ */
433
+ customerRef?: BalancePaidCustomerRef;
434
+ /**
435
+ * `BALANCE_PAID_ONLINE` only: the online balance-payment attempt
436
+ * (`BAT-{customerId}-{seq}`). Operator surfaces only.
437
+ */
438
+ balanceAttemptId?: string;
409
439
  /** `MENTION` only: the colleague who wrote the mention (a snapshot). */
410
440
  actor?: NotificationActor;
411
441
  userId?: string;
@@ -3,7 +3,7 @@
3
3
  // legacy opt-ins and explicit channel maps remain source data on USER rows.
4
4
  // Addressed ERROR / ML_FACTURADOR_COLLISION / ML_SELLER_SWITCHED /
5
5
  // ML_CONNECTION_BROKEN / MENTION / CUSTOMER_PENDING_APPROVAL /
6
- // PAYMENT_ATTEMPT_RESOLUTION / CUSTOMER_WHOLESALE_REQUEST / STOREFRONT_QUOTE_REQUEST /
6
+ // PAYMENT_ATTEMPT_RESOLUTION / BALANCE_PAID_ONLINE / CUSTOMER_WHOLESALE_REQUEST / STOREFRONT_QUOTE_REQUEST /
7
7
  // SERVICE_QUOTE_DECIDED /
8
8
  // REFUND_OBLIGATION_OVERDUE / MESSAGE_CREDITS_LOW / MESSAGE_SKIPPED_NO_CREDITS do not select a
9
9
  // producer subscriber audience;
@@ -199,6 +199,18 @@ export var NotificationTypeEnum;
199
199
  * re-opens rings again.
200
200
  */
201
201
  NotificationTypeEnum["PAYMENT_ATTEMPT_RESOLUTION"] = "PAYMENT_ATTEMPT_RESOLUTION";
202
+ /**
203
+ * A signed-in buyer paid open cuenta-corriente debits online through Mercado
204
+ * Pago, and the credit landed on their ledger with its «Comprobante de pago»
205
+ * number. Carries {@link NotificationInterface.customerRef} and
206
+ * {@link NotificationInterface.balanceAttemptId} — pointers, never the buyer's
207
+ * name or contact.
208
+ *
209
+ * ⚠️ ADMIN-ONLY, as `PAYMENT_ATTEMPT_RESOLUTION`: one bell per non-disabled
210
+ * ADMIN of the store (`listActiveAdmins`), after the credit committed,
211
+ * best-effort. Its own preference key, default-on when absent; seeded nowhere.
212
+ */
213
+ NotificationTypeEnum["BALANCE_PAID_ONLINE"] = "BALANCE_PAID_ONLINE";
202
214
  /**
203
215
  * A signed-in storefront buyer asked for a wholesale account
204
216
  * (`POST /user { mode: 'wholesale-request' }`) and the request waits in the
package/dist/payment.d.ts CHANGED
@@ -136,6 +136,13 @@ declare global {
136
136
  externalReference?: string;
137
137
  reconciled?: boolean;
138
138
  reconcileReason?: string;
139
+ /**
140
+ * The non-fiscal «Comprobante de pago» number, `CPG-{n}`, sequential per
141
+ * store — set only on a payment a buyer made online against their cuenta
142
+ * corriente (`POST /payments/balance-attempts`), stamped with the ledger
143
+ * credit. Never a fiscal «Recibo». Absent on every other payment.
144
+ */
145
+ receiptNo?: string;
139
146
  /**
140
147
  * MercadoPago's own money breakdown, in major units of `currency`: `gross` is
141
148
  * `transaction_amount`, `net` is `transaction_details.net_received_amount`
package/dist/socket.d.ts CHANGED
@@ -26,7 +26,7 @@
26
26
  * A client must ignore actions it does not own rather than assume it
27
27
  * receives all of them.
28
28
  */
29
- export declare const SOCKET_ACTIONS: readonly ["account", "appointments", "appointmentWaitlist", "attendance", "attributes", "automation-rules", "baskets", "cart", "brands", "cash", "catalogOperation", "categories", "campaigns", "customers", "customerNote", "customerAddress", "customerContact", "deliveries", "globals", "inventory", "invoices", "literals", "loyalty", "orders", "presupuestos", "products", "promotions", "segments", "returns", "rma", "templates", "services", "service-templates", "shifts", "stores", "suppliers", "supplier-invoice", "support", "surveys", "users", "warehouses", "zones", "favorites", "webhooks", "account-delete", "baskets-delete", "cart-delete", "log-delete", "notifications", "support-message", "payment_received", "mp_payment_status_changed", "payment_linked", "payment_unlinked", "mercadopago", "mercadopago_dynamic_qr_created", "mercadopago_static_qr_created", "mp_hook_log_appended", "mp_ipn_log_appended", "orderPaymentAttempt", "orderDelivery", "paymentAttemptChanged", "orderPurchaseWithdrawal", "orderReturnRequest", "purchaseWithdrawalChanged", "stripe", "subscription", "caea", "print", "print-order", "print-invoice", "print-product", "print-tag", "print-service-order", "print_job_failed", "request_printers", "printers_changed", "agent_status_changed", "print_rules_changed", "printers_active", "agent_command", "maintenance", "currency_auto_updated", "drain_progress", "integration_event_appended", "userActivityRecorded", "mercadolibre_settlement_period", "customDomain", "purchaseOrders", "cycleCounts", "stockTransfers", "workItems", "wholesaleRequests"];
29
+ export declare const SOCKET_ACTIONS: readonly ["account", "appointments", "appointmentWaitlist", "attendance", "attributes", "automation-rules", "baskets", "cart", "brands", "cash", "catalogOperation", "categories", "campaigns", "customers", "customerNote", "customerAddress", "customerContact", "deliveries", "globals", "inventory", "invoices", "literals", "loyalty", "orders", "presupuestos", "products", "promotions", "segments", "returns", "rma", "templates", "services", "service-templates", "shifts", "stores", "suppliers", "supplier-invoice", "support", "surveys", "users", "warehouses", "zones", "favorites", "webhooks", "account-delete", "baskets-delete", "cart-delete", "log-delete", "notifications", "support-message", "payment_received", "mp_payment_status_changed", "payment_linked", "payment_unlinked", "mercadopago", "mercadopago_dynamic_qr_created", "mercadopago_static_qr_created", "mp_hook_log_appended", "mp_ipn_log_appended", "orderPaymentAttempt", "balancePaymentAttempt", "orderDelivery", "paymentAttemptChanged", "orderPurchaseWithdrawal", "orderReturnRequest", "purchaseWithdrawalChanged", "stripe", "subscription", "caea", "print", "print-order", "print-invoice", "print-product", "print-tag", "print-service-order", "print_job_failed", "request_printers", "printers_changed", "agent_status_changed", "print_rules_changed", "printers_active", "agent_command", "maintenance", "currency_auto_updated", "drain_progress", "integration_event_appended", "userActivityRecorded", "mercadolibre_settlement_period", "customDomain", "purchaseOrders", "cycleCounts", "stockTransfers", "workItems", "wholesaleRequests"];
30
30
  /** Union of every server→client data-frame action. */
31
31
  export type SocketAction = (typeof SOCKET_ACTIONS)[number];
32
32
  /**
package/dist/socket.js CHANGED
@@ -516,6 +516,15 @@ export const SOCKET_ACTIONS = [
516
516
  * customer broadcast. Sent once per committed state move of the attempt.
517
517
  */
518
518
  'orderPaymentAttempt',
519
+ /**
520
+ * A signed-in buyer's online cuenta-corriente payment attempt changed state.
521
+ * `data` is `BalancePaymentAttemptFrameData` (`balancePayment.ts`) — the
522
+ * attempt id, its state and, once approved, its receipt number.
523
+ *
524
+ * ⚠️ To the attempt's OWN customer only (`wsPostCustomer`), never a
525
+ * store-wide customer broadcast. Sent once per committed state move.
526
+ */
527
+ 'balancePaymentAttempt',
519
528
  /**
520
529
  * A storefront order's delivery was created or moved. `data` is
521
530
  * `OrderDeliveryFrameData` (`delivery.ts`) — the order id and the minimised
package/dist/store.d.ts CHANGED
@@ -227,6 +227,21 @@ declare global {
227
227
  * they see the attempt's `expiresAt` instead.
228
228
  */
229
229
  paymentHoldMinutes?: number;
230
+ /**
231
+ * Whether a signed-in storefront buyer may pay open cuenta-corriente
232
+ * debits online through the store's Mercado Pago (Checkout Pro). Absent
233
+ * or `false` = off. Written by `PATCH /store` (ADMIN) and
234
+ * `PUT /platform/stores/{storeId}` (MANAGER) as a plain boolean; storing
235
+ * `true` is never refused.
236
+ *
237
+ * ⚠️ SENT TO SHOPPERS AS THE VERDICT, under this same key (web `GET /store`
238
+ * and the customer `stores` frame): `true` only while the stored value is
239
+ * `true` AND `config.modules.customerAccounts` is not `false` AND Mercado
240
+ * Pago is linked AND the ledger (`config.displayCurrency`) is the peso.
241
+ * Web `GET /account?mode=open-debits` and `POST /payments/balance-attempts`
242
+ * judge the same verdict server-side (`BalancePaymentErrorCode`).
243
+ */
244
+ onlineBalancePayment?: boolean;
230
245
  showStocks?: boolean;
231
246
  };
232
247
  sidebar?: {
@@ -273,7 +288,7 @@ declare global {
273
288
  * (Responsable Inscripto) refuses 409 NET_PLUS_IVA_REQUIRES_RI; nothing written.
274
289
  */
275
290
  interface EcommercePatchInput {
276
- config?: Pick<NonNullable<Ecommerce['config']>, 'showDefaultPriceList' | 'newCustomerPriceList' | 'registrationMode' | 'wholesaleRequests' | 'serviceTracking' | 'paymentHoldMinutes'> & StorefrontLiveSettingsPatch;
291
+ config?: Pick<NonNullable<Ecommerce['config']>, 'showDefaultPriceList' | 'newCustomerPriceList' | 'registrationMode' | 'wholesaleRequests' | 'serviceTracking' | 'paymentHoldMinutes' | 'onlineBalancePayment'> & StorefrontLiveSettingsPatch;
277
292
  sidebar?: Ecommerce['sidebar'];
278
293
  home?: Omit<NonNullable<Ecommerce['home']>, 'displayOrders' | 'displayProfile'>;
279
294
  themeColors?: Ecommerce['themeColors'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.856",
3
+ "version": "1.10.858",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",