@usebillow/sdk 0.10.0 → 0.12.0
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/CHANGELOG.md +22 -0
- package/dist/{billing-Bs10EcjR.d.ts → billing-BEbVLGe9.d.ts} +6 -3
- package/dist/{billing-8ug1Gw05.d.cts → billing-CDEO8Jqv.d.cts} +6 -3
- package/dist/{chunk-XKN7ZRAR.js → chunk-H6C7CONO.js} +64 -5
- package/dist/chunk-H6C7CONO.js.map +1 -0
- package/dist/config.d.cts +3 -3
- package/dist/config.d.ts +3 -3
- package/dist/{hosted-domains-Ci6jeNAe.d.cts → hosted-domains-Cuk3j04R.d.cts} +28 -4
- package/dist/{hosted-domains-DSs5Iw9U.d.ts → hosted-domains-DMgokjiv.d.ts} +28 -4
- package/dist/index.cjs +62 -3
- package/dist/index.cjs.map +1 -1
- package/dist/{index.d-DSEYhV2c.d.ts → index.d-D5v2ETKF.d.cts} +21 -1
- package/dist/{index.d-DSEYhV2c.d.cts → index.d-D5v2ETKF.d.ts} +21 -1
- package/dist/index.d.cts +165 -19
- package/dist/index.d.ts +165 -19
- package/dist/index.js +1 -1
- package/dist/ingestion.d.cts +3 -3
- package/dist/ingestion.d.ts +3 -3
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +1 -1
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/webhooks.cjs +1 -0
- package/dist/webhooks.cjs.map +1 -1
- package/dist/webhooks.d.cts +23 -4
- package/dist/webhooks.d.ts +23 -4
- package/dist/webhooks.js +1 -0
- package/dist/webhooks.js.map +1 -1
- package/package.json +3 -3
- package/dist/chunk-XKN7ZRAR.js.map +0 -1
package/dist/config.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Billow } from './index.cjs';
|
|
2
|
-
import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-
|
|
3
|
-
import './index.d-
|
|
2
|
+
import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-CDEO8Jqv.cjs';
|
|
3
|
+
import './index.d-D5v2ETKF.cjs';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import './billing-status-DZkB0VPK.cjs';
|
|
6
6
|
import './status.cjs';
|
|
7
|
-
import './hosted-domains-
|
|
7
|
+
import './hosted-domains-Cuk3j04R.cjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Code-as-config sync (ARCHITECTURE §12 "code-as-config sync"). Keep your catalog
|
package/dist/config.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Billow } from './index.js';
|
|
2
|
-
import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-
|
|
3
|
-
import './index.d-
|
|
2
|
+
import { F as FeatureKind, M as MeterConfig, C as CreateProductInput, a as CreateCouponInput } from './billing-BEbVLGe9.js';
|
|
3
|
+
import './index.d-D5v2ETKF.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import './billing-status-DZkB0VPK.js';
|
|
6
6
|
import './status.js';
|
|
7
|
-
import './hosted-domains-
|
|
7
|
+
import './hosted-domains-DMgokjiv.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Code-as-config sync (ARCHITECTURE §12 "code-as-config sync"). Keep your catalog
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HostedDomainResponse } from './index.d-
|
|
1
|
+
import { H as HostedDomainResponse } from './index.d-D5v2ETKF.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Public SDK types for prepaid credits. Re-exported by ../types.ts.
|
|
@@ -67,6 +67,17 @@ interface CreateCreditGrantInput {
|
|
|
67
67
|
}
|
|
68
68
|
/** A Credit Account's status: `frozen` takes no new reservations; `closed` (erased) takes nothing. */
|
|
69
69
|
type CreditAccountStatus = "active" | "frozen" | "closed";
|
|
70
|
+
/** A customer's Credit Account status, as `credits.accounts.freeze` and `.unfreeze` answer it. */
|
|
71
|
+
interface CreditAccount {
|
|
72
|
+
/** The customer's external id. */
|
|
73
|
+
customerId: string;
|
|
74
|
+
status: CreditAccountStatus;
|
|
75
|
+
/**
|
|
76
|
+
* Whether this call moved the account to `status`, decided under the account's lock: false for a
|
|
77
|
+
* repeat (freezing a frozen account), so of two racing calls exactly one reports the change.
|
|
78
|
+
*/
|
|
79
|
+
changed: boolean;
|
|
80
|
+
}
|
|
70
81
|
/** What current Included Credit Windows include, and where it stands. */
|
|
71
82
|
interface IncludedCredits {
|
|
72
83
|
/** What the windows include. */
|
|
@@ -157,8 +168,8 @@ interface CreditLedgerEntry {
|
|
|
157
168
|
type: CreditTransactionType;
|
|
158
169
|
/**
|
|
159
170
|
* Why Billow posted it, as a system code (`api_grant`, `grant_expired`, `subscription_period`,
|
|
160
|
-
* `subscription_upgrade`, `subscription_canceled`, `subscription_charged_back`,
|
|
161
|
-
* text.
|
|
171
|
+
* `subscription_upgrade`, `subscription_canceled`, `subscription_charged_back`, `sandbox_seed`,
|
|
172
|
+
* ...); never free text.
|
|
162
173
|
*/
|
|
163
174
|
reason: string | null;
|
|
164
175
|
/** How it moved the account's unheld credits (signed). */
|
|
@@ -168,6 +179,11 @@ interface CreditLedgerEntry {
|
|
|
168
179
|
availableAfter: string;
|
|
169
180
|
heldAfter: string;
|
|
170
181
|
grantId: string | null;
|
|
182
|
+
/**
|
|
183
|
+
* The kind of `grantId`'s grant - a promotional grant and an adjustment both read `api_grant` as
|
|
184
|
+
* their `reason`; null when the transaction names no one grant (a hold, a commit, a reversal).
|
|
185
|
+
*/
|
|
186
|
+
grantKind: CreditGrantKind | null;
|
|
171
187
|
reservationId: string | null;
|
|
172
188
|
topUpId: string | null;
|
|
173
189
|
/** On a reversal: the consumption (its `consume` transaction) it gives back. */
|
|
@@ -446,6 +462,8 @@ interface CreditTopUp {
|
|
|
446
462
|
/** The customer's external id. */
|
|
447
463
|
customerId: string;
|
|
448
464
|
packId: string;
|
|
465
|
+
/** The pack's name when it was bought (renaming the pack later changes no purchase). */
|
|
466
|
+
packName: string;
|
|
449
467
|
status: CreditTopUpStatus;
|
|
450
468
|
/** The terms bought: what success grants. */
|
|
451
469
|
credits: string;
|
|
@@ -461,6 +479,12 @@ interface CreditTopUp {
|
|
|
461
479
|
checkoutUrl: string | null;
|
|
462
480
|
purchasedGrantId: string | null;
|
|
463
481
|
bonusGrantId: string | null;
|
|
482
|
+
/**
|
|
483
|
+
* Microcredits of the credits it granted that the customer has spent (consumed, net of
|
|
484
|
+
* reversals). A refund can never take these back: refunding the whole payment leaves them as its
|
|
485
|
+
* `shortfall`.
|
|
486
|
+
*/
|
|
487
|
+
consumed: string;
|
|
464
488
|
/** Microcredits refunds and lost chargebacks of the payment have revoked so far. */
|
|
465
489
|
revoked: string;
|
|
466
490
|
/** Of the revoked credits, those already spent and not paid back since. */
|
|
@@ -534,4 +558,4 @@ interface HostedDomainDisabledData extends HostedDomainEventBase {
|
|
|
534
558
|
reason: Extract<HostedDomainStatusReason, "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended">;
|
|
535
559
|
}
|
|
536
560
|
|
|
537
|
-
export type {
|
|
561
|
+
export type { CreditMoney as A, CreditPackBreakdown as B, CreditGrantKind as C, CreditPackListItem as D, CreditTopUpStatus as E, CreditTransactionType as F, CreditUsageGroupBy as G, HostedDomainActivatedData as H, CreditWindowState as I, HostedDomainEventBase as J, HostedDomainStatus as K, HostedDomainStatusReason as L, IncludedCredits as M, IncludedPeriod as N, UpdateCreditPackInput as U, CreditThresholdLevel as a, HostedDomainDnsFailingData as b, HostedDomainReassignmentPendingData as c, HostedDomainDisabledData as d, CreditGrant as e, CreditTopUp as f, CreditIncludedWindow as g, CreateCreditGrantInput as h, CreditGrantRequestResult as i, CreditAccount as j, CreditPacks as k, CreateCreditPackInput as l, CreditPack as m, CreateCreditIncludedRuleInput as n, CreditIncludedRule as o, UpdateCreditIncludedRuleInput as p, CreditIncludedWindowListParams as q, CreateCreditTopUpInput as r, CreditTopUpRequestResult as s, CreditTopUpListParams as t, CreditBalance as u, CreditLedgerEntry as v, CreditUsageParams as w, CreditUsage as x, CreditAccountStatus as y, CreditAllocationInterval as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { H as HostedDomainResponse } from './index.d-
|
|
1
|
+
import { H as HostedDomainResponse } from './index.d-D5v2ETKF.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Public SDK types for prepaid credits. Re-exported by ../types.ts.
|
|
@@ -67,6 +67,17 @@ interface CreateCreditGrantInput {
|
|
|
67
67
|
}
|
|
68
68
|
/** A Credit Account's status: `frozen` takes no new reservations; `closed` (erased) takes nothing. */
|
|
69
69
|
type CreditAccountStatus = "active" | "frozen" | "closed";
|
|
70
|
+
/** A customer's Credit Account status, as `credits.accounts.freeze` and `.unfreeze` answer it. */
|
|
71
|
+
interface CreditAccount {
|
|
72
|
+
/** The customer's external id. */
|
|
73
|
+
customerId: string;
|
|
74
|
+
status: CreditAccountStatus;
|
|
75
|
+
/**
|
|
76
|
+
* Whether this call moved the account to `status`, decided under the account's lock: false for a
|
|
77
|
+
* repeat (freezing a frozen account), so of two racing calls exactly one reports the change.
|
|
78
|
+
*/
|
|
79
|
+
changed: boolean;
|
|
80
|
+
}
|
|
70
81
|
/** What current Included Credit Windows include, and where it stands. */
|
|
71
82
|
interface IncludedCredits {
|
|
72
83
|
/** What the windows include. */
|
|
@@ -157,8 +168,8 @@ interface CreditLedgerEntry {
|
|
|
157
168
|
type: CreditTransactionType;
|
|
158
169
|
/**
|
|
159
170
|
* Why Billow posted it, as a system code (`api_grant`, `grant_expired`, `subscription_period`,
|
|
160
|
-
* `subscription_upgrade`, `subscription_canceled`, `subscription_charged_back`,
|
|
161
|
-
* text.
|
|
171
|
+
* `subscription_upgrade`, `subscription_canceled`, `subscription_charged_back`, `sandbox_seed`,
|
|
172
|
+
* ...); never free text.
|
|
162
173
|
*/
|
|
163
174
|
reason: string | null;
|
|
164
175
|
/** How it moved the account's unheld credits (signed). */
|
|
@@ -168,6 +179,11 @@ interface CreditLedgerEntry {
|
|
|
168
179
|
availableAfter: string;
|
|
169
180
|
heldAfter: string;
|
|
170
181
|
grantId: string | null;
|
|
182
|
+
/**
|
|
183
|
+
* The kind of `grantId`'s grant - a promotional grant and an adjustment both read `api_grant` as
|
|
184
|
+
* their `reason`; null when the transaction names no one grant (a hold, a commit, a reversal).
|
|
185
|
+
*/
|
|
186
|
+
grantKind: CreditGrantKind | null;
|
|
171
187
|
reservationId: string | null;
|
|
172
188
|
topUpId: string | null;
|
|
173
189
|
/** On a reversal: the consumption (its `consume` transaction) it gives back. */
|
|
@@ -446,6 +462,8 @@ interface CreditTopUp {
|
|
|
446
462
|
/** The customer's external id. */
|
|
447
463
|
customerId: string;
|
|
448
464
|
packId: string;
|
|
465
|
+
/** The pack's name when it was bought (renaming the pack later changes no purchase). */
|
|
466
|
+
packName: string;
|
|
449
467
|
status: CreditTopUpStatus;
|
|
450
468
|
/** The terms bought: what success grants. */
|
|
451
469
|
credits: string;
|
|
@@ -461,6 +479,12 @@ interface CreditTopUp {
|
|
|
461
479
|
checkoutUrl: string | null;
|
|
462
480
|
purchasedGrantId: string | null;
|
|
463
481
|
bonusGrantId: string | null;
|
|
482
|
+
/**
|
|
483
|
+
* Microcredits of the credits it granted that the customer has spent (consumed, net of
|
|
484
|
+
* reversals). A refund can never take these back: refunding the whole payment leaves them as its
|
|
485
|
+
* `shortfall`.
|
|
486
|
+
*/
|
|
487
|
+
consumed: string;
|
|
464
488
|
/** Microcredits refunds and lost chargebacks of the payment have revoked so far. */
|
|
465
489
|
revoked: string;
|
|
466
490
|
/** Of the revoked credits, those already spent and not paid back since. */
|
|
@@ -534,4 +558,4 @@ interface HostedDomainDisabledData extends HostedDomainEventBase {
|
|
|
534
558
|
reason: Extract<HostedDomainStatusReason, "dns_lost" | "reassigned" | "entitlement_lapsed" | "suspended">;
|
|
535
559
|
}
|
|
536
560
|
|
|
537
|
-
export type {
|
|
561
|
+
export type { CreditMoney as A, CreditPackBreakdown as B, CreditGrantKind as C, CreditPackListItem as D, CreditTopUpStatus as E, CreditTransactionType as F, CreditUsageGroupBy as G, HostedDomainActivatedData as H, CreditWindowState as I, HostedDomainEventBase as J, HostedDomainStatus as K, HostedDomainStatusReason as L, IncludedCredits as M, IncludedPeriod as N, UpdateCreditPackInput as U, CreditThresholdLevel as a, HostedDomainDnsFailingData as b, HostedDomainReassignmentPendingData as c, HostedDomainDisabledData as d, CreditGrant as e, CreditTopUp as f, CreditIncludedWindow as g, CreateCreditGrantInput as h, CreditGrantRequestResult as i, CreditAccount as j, CreditPacks as k, CreateCreditPackInput as l, CreditPack as m, CreateCreditIncludedRuleInput as n, CreditIncludedRule as o, UpdateCreditIncludedRuleInput as p, CreditIncludedWindowListParams as q, CreateCreditTopUpInput as r, CreditTopUpRequestResult as s, CreditTopUpListParams as t, CreditBalance as u, CreditLedgerEntry as v, CreditUsageParams as w, CreditUsage as x, CreditAccountStatus as y, CreditAllocationInterval as z };
|
package/dist/index.cjs
CHANGED
|
@@ -249,7 +249,9 @@ var BILLOW_ERROR_CODES = [
|
|
|
249
249
|
"account_closed",
|
|
250
250
|
"idempotency_conflict",
|
|
251
251
|
"commit_exceeds_hold",
|
|
252
|
-
"reversal_exceeds_consumption"
|
|
252
|
+
"reversal_exceeds_consumption",
|
|
253
|
+
// Merchant custom domains (ADR-0039): a portal session asked for a host that cannot serve it.
|
|
254
|
+
"hosted_domain_unavailable"
|
|
253
255
|
];
|
|
254
256
|
|
|
255
257
|
// src/money.ts
|
|
@@ -433,6 +435,16 @@ function createChargesResource(ctx) {
|
|
|
433
435
|
`/v1/charges/${encodeURIComponent(chargeId)}/refunds/${encodeURIComponent(refundId)}/credit-note.pdf`,
|
|
434
436
|
options
|
|
435
437
|
),
|
|
438
|
+
/**
|
|
439
|
+
* Download a credit note voided on a refund (one of its `voidedCreditNotes`), exactly as it was
|
|
440
|
+
* issued and badged VOID.
|
|
441
|
+
*/
|
|
442
|
+
voidedCreditNote: (chargeId, refundId, creditNoteNumber, options) => apiRequestBinary(
|
|
443
|
+
ctx,
|
|
444
|
+
"GET",
|
|
445
|
+
`/v1/charges/${encodeURIComponent(chargeId)}/refunds/${encodeURIComponent(refundId)}/credit-note.pdf?number=${encodeURIComponent(creditNoteNumber)}`,
|
|
446
|
+
options
|
|
447
|
+
),
|
|
436
448
|
/**
|
|
437
449
|
* Refund a succeeded charge: `{ amount }` (minor units) for a partial, `{}` for its whole
|
|
438
450
|
* remaining balance. The `idempotencyKey` is required and must identify this one refund
|
|
@@ -476,7 +488,10 @@ function createChargesResource(ctx) {
|
|
|
476
488
|
/**
|
|
477
489
|
* Record the outcome you verified in the provider dashboard for a refund awaiting review
|
|
478
490
|
* (`needsReview`): `succeeded` settles it with a credit note, `failed` releases its amount.
|
|
479
|
-
* A refund with a provider conflict (`providerConflictStatus`) resolves only
|
|
491
|
+
* A refund with a provider conflict (`providerConflictStatus`) recorded `failed` resolves only
|
|
492
|
+
* as `succeeded`; one recorded `succeeded` that the provider later reported failed (a reversal:
|
|
493
|
+
* the customer's bank returned the money) resolves either way, `failed` making its amount
|
|
494
|
+
* refundable again.
|
|
480
495
|
*/
|
|
481
496
|
resolveRefund: (chargeId, refundId, input, options) => apiRequest(ctx, "POST", `${refundPath(chargeId, refundId)}/resolve`, input, options)
|
|
482
497
|
};
|
|
@@ -519,6 +534,35 @@ function createCreditsResource(ctx) {
|
|
|
519
534
|
return { ...data, replayed: status === 200 };
|
|
520
535
|
}
|
|
521
536
|
},
|
|
537
|
+
accounts: {
|
|
538
|
+
/**
|
|
539
|
+
* Freeze a customer's Credit Account (by external id): it takes no new reservations - a
|
|
540
|
+
* reserve throws `account_frozen` (423) - until unfrozen, while holds already made still
|
|
541
|
+
* commit and release, and grants, top-ups, reversals and included credits still fund it.
|
|
542
|
+
* Safe to retry: freezing a frozen account changes nothing and answers `changed: false`. A
|
|
543
|
+
* customer with no account yet gets one, frozen. Throws `account_closed` (409) for an erased
|
|
544
|
+
* customer.
|
|
545
|
+
*/
|
|
546
|
+
freeze: (customer, options) => apiRequest(
|
|
547
|
+
ctx,
|
|
548
|
+
"POST",
|
|
549
|
+
"/v1/credits/accounts/freeze",
|
|
550
|
+
{ customerId: customer },
|
|
551
|
+
options
|
|
552
|
+
),
|
|
553
|
+
/**
|
|
554
|
+
* Unfreeze a customer's Credit Account (by external id): it takes reservations again. Safe to
|
|
555
|
+
* retry: unfreezing an account that is not frozen changes nothing and answers
|
|
556
|
+
* `changed: false`.
|
|
557
|
+
*/
|
|
558
|
+
unfreeze: (customer, options) => apiRequest(
|
|
559
|
+
ctx,
|
|
560
|
+
"POST",
|
|
561
|
+
"/v1/credits/accounts/unfreeze",
|
|
562
|
+
{ customerId: customer },
|
|
563
|
+
options
|
|
564
|
+
)
|
|
565
|
+
},
|
|
522
566
|
packs: {
|
|
523
567
|
/**
|
|
524
568
|
* The Credit Packs a customer can buy in `currency` (ISO 4217), cheapest first: credits and
|
|
@@ -724,7 +768,8 @@ function createCreditsResource(ctx) {
|
|
|
724
768
|
/**
|
|
725
769
|
* Publish a new Rate Card version: what each Credit Action costs, as
|
|
726
770
|
* `ceil(units * unitPrice / perUnits)` microcredits a line. Versions are immutable - a price
|
|
727
|
-
* change is a new version - and take effect in order, at `effectiveAt` (now when omitted)
|
|
771
|
+
* change is a new version - and take effect in order, at `effectiveAt` (now when omitted),
|
|
772
|
+
* unless retracted before then.
|
|
728
773
|
*/
|
|
729
774
|
publish: (input, options) => apiRequest(ctx, "POST", "/v1/credits/rate-cards", input, options),
|
|
730
775
|
/** The version in effect now (`not_found` before the first takes effect). */
|
|
@@ -743,6 +788,20 @@ function createCreditsResource(ctx) {
|
|
|
743
788
|
void 0,
|
|
744
789
|
options
|
|
745
790
|
),
|
|
791
|
+
/**
|
|
792
|
+
* Retract a version before it takes effect: it never does (`retractedAt` is set), and
|
|
793
|
+
* versions published after it take effect in order after the last one not retracted - so a
|
|
794
|
+
* scheduled price change no longer holds back an earlier correction. Safe to retry: a
|
|
795
|
+
* retracted version answers as retracted. A version already in effect, current or
|
|
796
|
+
* superseded, throws `conflict` (409, `details.reason: "already_effective"`).
|
|
797
|
+
*/
|
|
798
|
+
retract: (version, options) => apiRequest(
|
|
799
|
+
ctx,
|
|
800
|
+
"POST",
|
|
801
|
+
`/v1/credits/rate-cards/${encodeURIComponent(String(version))}/retract`,
|
|
802
|
+
void 0,
|
|
803
|
+
options
|
|
804
|
+
),
|
|
746
805
|
/**
|
|
747
806
|
* The published versions, newest first. Auto-paginating by cursor: `await` the first page,
|
|
748
807
|
* `for await (…)` every version, or `.listAll()` to collect them.
|