@fonderie/client 0.12.0 → 0.14.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/brain/signatures.md +67 -0
- package/dist/index.cjs +102 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +68 -1
- package/dist/index.d.ts +68 -1
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/brain/signatures.md
CHANGED
|
@@ -183,12 +183,21 @@ new BillingClient(http: HttpClient, tokens: TokenStore): BillingClient
|
|
|
183
183
|
.updatePlan(planId: string, input: Partial<ICreatePlanInput>): Promise<IApiResponse<IPlanResult>>
|
|
184
184
|
.deletePlan(planId: string): Promise<IApiResponse<undefined>>
|
|
185
185
|
.getSubscription(opts?: IReadOptions | undefined): Promise<IApiResponse<ISubscriptionResult>>
|
|
186
|
+
.cancelSubscription(input?: ICancelSubscriptionInput | undefined): Promise<IApiResponse<ISubscriptionChangeResult>>
|
|
187
|
+
.reactivateSubscription(): Promise<IApiResponse<ISubscriptionChangeResult>>
|
|
186
188
|
.createCheckoutSession(input: ICheckoutInput): Promise<IApiResponse<ICheckoutUrlResult>>
|
|
187
189
|
.createPortalSession(): Promise<IApiResponse<IPortalUrlResult>>
|
|
188
190
|
.recordUsage(input: IRecordUsageInput): Promise<IApiResponse<undefined>>
|
|
189
191
|
.getUsage(metric: string, opts?: IReadOptions | undefined): Promise<IApiResponse<IUsageResult>>
|
|
190
192
|
.getWallet(opts?: IReadOptions | undefined): Promise<IApiResponse<IWalletResult>>
|
|
191
193
|
.setWalletPreferences(input: IWalletPreferencesInput): Promise<IApiResponse<IWalletResult>>
|
|
194
|
+
.createWalletCheckout(input: IWalletCheckoutInput): Promise<IApiResponse<ICheckoutUrlResult>>
|
|
195
|
+
.getWalletTransactions(opts?: (IReadOptions & { cursor?: string; limit?: number; }) | undefined): Promise<IApiResponse<IWalletTransactionsResult>>
|
|
196
|
+
.getPaymentMethod(opts?: IReadOptions | undefined): Promise<IApiResponse<IPaymentMethodResult>>
|
|
197
|
+
.setupPaymentMethod(): Promise<IApiResponse<ISetupIntentResult>>
|
|
198
|
+
.savePaymentMethod(input: ISavePaymentMethodInput): Promise<IApiResponse<IPaymentMethodResult>>
|
|
199
|
+
.removePaymentMethod(): Promise<IApiResponse<IPaymentMethodResult>>
|
|
200
|
+
.listInvoices(opts?: IReadOptions | undefined): Promise<IApiResponse<IInvoicesResult>>
|
|
192
201
|
|
|
193
202
|
interface IConfigAdminClientOptions {
|
|
194
203
|
baseUrl: string;
|
|
@@ -516,6 +525,10 @@ interface IAuditPageResult {
|
|
|
516
525
|
nextCursor: string | null;
|
|
517
526
|
}
|
|
518
527
|
|
|
528
|
+
interface ICancelSubscriptionInput {
|
|
529
|
+
atPeriodEnd?: boolean;
|
|
530
|
+
}
|
|
531
|
+
|
|
519
532
|
interface ICheckoutUrlResult {
|
|
520
533
|
url: string;
|
|
521
534
|
}
|
|
@@ -722,6 +735,22 @@ interface IInviteResult {
|
|
|
722
735
|
}>;
|
|
723
736
|
}
|
|
724
737
|
|
|
738
|
+
interface IInvoiceDTO {
|
|
739
|
+
id: string;
|
|
740
|
+
number: string | null;
|
|
741
|
+
amountDue: string;
|
|
742
|
+
amountPaid: string;
|
|
743
|
+
currency: string;
|
|
744
|
+
status: string;
|
|
745
|
+
created: string;
|
|
746
|
+
hostedInvoiceUrl: string | null;
|
|
747
|
+
invoicePdf: string | null;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
interface IInvoicesResult {
|
|
751
|
+
invoices: IInvoiceDTO[];
|
|
752
|
+
}
|
|
753
|
+
|
|
725
754
|
interface ILoginResult {
|
|
726
755
|
tokens: ITokens;
|
|
727
756
|
user: IUserDTO;
|
|
@@ -762,6 +791,17 @@ interface IMfaSetupResult {
|
|
|
762
791
|
backupCodes: string[];
|
|
763
792
|
}
|
|
764
793
|
|
|
794
|
+
interface IPaymentMethodDTO {
|
|
795
|
+
brand: string;
|
|
796
|
+
last4: string;
|
|
797
|
+
expMonth: number;
|
|
798
|
+
expYear: number;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
interface IPaymentMethodResult {
|
|
802
|
+
paymentMethod: IPaymentMethodDTO | null;
|
|
803
|
+
}
|
|
804
|
+
|
|
765
805
|
interface IPlanDTO {
|
|
766
806
|
id: string;
|
|
767
807
|
planId: string;
|
|
@@ -857,6 +897,12 @@ interface ISecretRevision {
|
|
|
857
897
|
createdAt: string;
|
|
858
898
|
}
|
|
859
899
|
|
|
900
|
+
interface ISubscriptionChangeResult {
|
|
901
|
+
atPeriodEnd: boolean;
|
|
902
|
+
status: string;
|
|
903
|
+
currentPeriodEnd: string | null;
|
|
904
|
+
}
|
|
905
|
+
|
|
860
906
|
interface ISubscriptionDTO {
|
|
861
907
|
id: string;
|
|
862
908
|
subscriberType: SubscriberType;
|
|
@@ -954,6 +1000,10 @@ interface IVerifyEmailResult {
|
|
|
954
1000
|
email: string;
|
|
955
1001
|
}
|
|
956
1002
|
|
|
1003
|
+
interface IWalletCheckoutInput {
|
|
1004
|
+
packId: string;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
957
1007
|
interface IWalletDTO {
|
|
958
1008
|
balance: string;
|
|
959
1009
|
currency: string;
|
|
@@ -968,6 +1018,23 @@ interface IWalletResult {
|
|
|
968
1018
|
wallet: IWalletDTO;
|
|
969
1019
|
}
|
|
970
1020
|
|
|
1021
|
+
interface IWalletTransactionDTO {
|
|
1022
|
+
id: string;
|
|
1023
|
+
type: string;
|
|
1024
|
+
amount: string;
|
|
1025
|
+
balanceAfter: string;
|
|
1026
|
+
currency: string;
|
|
1027
|
+
description: string | null;
|
|
1028
|
+
providerTxId: string | null;
|
|
1029
|
+
metadata: Record<string, unknown>;
|
|
1030
|
+
createdAt: string;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
interface IWalletTransactionsResult {
|
|
1034
|
+
transactions: IWalletTransactionDTO[];
|
|
1035
|
+
nextCursor: string | null;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
971
1038
|
interface IWebhookDeliveryDTO {
|
|
972
1039
|
id: string;
|
|
973
1040
|
eventId: string;
|
package/dist/index.cjs
CHANGED
|
@@ -456,6 +456,28 @@ var BillingClient = class {
|
|
|
456
456
|
bust: opts?.bust
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
|
+
// First-party cancel — no portal round-trip. Default keeps access until the
|
|
460
|
+
// paid-through date; pass { atPeriodEnd: false } to end it immediately. 501
|
|
461
|
+
// when the provider has no first-party cancel (the portal remains a fallback).
|
|
462
|
+
cancelSubscription(input) {
|
|
463
|
+
return this.http.request({
|
|
464
|
+
method: "POST",
|
|
465
|
+
path: "/billing/subscription/cancel",
|
|
466
|
+
body: input ?? {},
|
|
467
|
+
token: this.tokens.get(),
|
|
468
|
+
workspaceId: this.workspaceId
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
// Un-cancel a subscription scheduled to cancel at period end. Idempotent; 409
|
|
472
|
+
// when the subscription is already fully canceled (start a new checkout).
|
|
473
|
+
reactivateSubscription() {
|
|
474
|
+
return this.http.request({
|
|
475
|
+
method: "POST",
|
|
476
|
+
path: "/billing/subscription/reactivate",
|
|
477
|
+
token: this.tokens.get(),
|
|
478
|
+
workspaceId: this.workspaceId
|
|
479
|
+
});
|
|
480
|
+
}
|
|
459
481
|
// ── Checkout / portal ────────────────────────────────────────────────────────
|
|
460
482
|
createCheckoutSession(input) {
|
|
461
483
|
return this.http.request({
|
|
@@ -512,6 +534,86 @@ var BillingClient = class {
|
|
|
512
534
|
workspaceId: this.workspaceId
|
|
513
535
|
});
|
|
514
536
|
}
|
|
537
|
+
// Start a one-time credit-pack purchase. Returns a hosted checkout URL to
|
|
538
|
+
// redirect the buyer to; the wallet is credited by the payment webhook.
|
|
539
|
+
createWalletCheckout(input) {
|
|
540
|
+
return this.http.request({
|
|
541
|
+
method: "POST",
|
|
542
|
+
path: "/billing/wallet/checkout",
|
|
543
|
+
body: input,
|
|
544
|
+
token: this.tokens.get(),
|
|
545
|
+
workspaceId: this.workspaceId
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
// The wallet ledger, newest first — every credit/debit with a running
|
|
549
|
+
// balanceAfter. Cursor-paginated: pass the previous result's `nextCursor`.
|
|
550
|
+
getWalletTransactions(opts) {
|
|
551
|
+
const params = new URLSearchParams();
|
|
552
|
+
if (opts?.cursor) params.set("cursor", opts.cursor);
|
|
553
|
+
if (opts?.limit !== void 0) params.set("limit", String(opts.limit));
|
|
554
|
+
const qs = params.toString();
|
|
555
|
+
return this.http.request({
|
|
556
|
+
method: "GET",
|
|
557
|
+
path: `/billing/wallet/transactions${qs ? "?" + qs : ""}`,
|
|
558
|
+
token: this.tokens.get(),
|
|
559
|
+
workspaceId: this.workspaceId,
|
|
560
|
+
bust: opts?.bust
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
// ── Account ──────────────────────────────────────────────────────────────────
|
|
564
|
+
// The customer's card on file (brand/last4/expiry), or { paymentMethod: null }
|
|
565
|
+
// when none is stored. 501 when the provider can't retrieve it.
|
|
566
|
+
getPaymentMethod(opts) {
|
|
567
|
+
return this.http.request({
|
|
568
|
+
method: "GET",
|
|
569
|
+
path: "/billing/payment-method",
|
|
570
|
+
token: this.tokens.get(),
|
|
571
|
+
workspaceId: this.workspaceId,
|
|
572
|
+
bust: opts?.bust
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
// Begin in-app card entry — returns a SetupIntent client secret for the
|
|
576
|
+
// provider's embedded card element (Stripe Payment Element); the user never
|
|
577
|
+
// leaves the site. 501 when the provider has no in-app card support.
|
|
578
|
+
setupPaymentMethod() {
|
|
579
|
+
return this.http.request({
|
|
580
|
+
method: "POST",
|
|
581
|
+
path: "/billing/payment-method/setup",
|
|
582
|
+
token: this.tokens.get(),
|
|
583
|
+
workspaceId: this.workspaceId
|
|
584
|
+
});
|
|
585
|
+
}
|
|
586
|
+
// Save the card after the client confirms the SetupIntent: makes it the
|
|
587
|
+
// default and records it. 422 when the card isn't attached to this customer.
|
|
588
|
+
savePaymentMethod(input) {
|
|
589
|
+
return this.http.request({
|
|
590
|
+
method: "PUT",
|
|
591
|
+
path: "/billing/payment-method",
|
|
592
|
+
body: input,
|
|
593
|
+
token: this.tokens.get(),
|
|
594
|
+
workspaceId: this.workspaceId
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
// Remove the saved card (detach at the provider + clear the record).
|
|
598
|
+
removePaymentMethod() {
|
|
599
|
+
return this.http.request({
|
|
600
|
+
method: "DELETE",
|
|
601
|
+
path: "/billing/payment-method",
|
|
602
|
+
token: this.tokens.get(),
|
|
603
|
+
workspaceId: this.workspaceId
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
// The customer's invoices, newest first — each links out to the hosted
|
|
607
|
+
// invoice / PDF. 501 when the provider can't list them.
|
|
608
|
+
listInvoices(opts) {
|
|
609
|
+
return this.http.request({
|
|
610
|
+
method: "GET",
|
|
611
|
+
path: "/billing/invoices",
|
|
612
|
+
token: this.tokens.get(),
|
|
613
|
+
workspaceId: this.workspaceId,
|
|
614
|
+
bust: opts?.bust
|
|
615
|
+
});
|
|
616
|
+
}
|
|
515
617
|
};
|
|
516
618
|
|
|
517
619
|
// src/modules/customers.ts
|