@fonderie/client 0.14.0 → 0.15.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.
@@ -192,6 +192,7 @@ new BillingClient(http: HttpClient, tokens: TokenStore): BillingClient
192
192
  .getWallet(opts?: IReadOptions | undefined): Promise<IApiResponse<IWalletResult>>
193
193
  .setWalletPreferences(input: IWalletPreferencesInput): Promise<IApiResponse<IWalletResult>>
194
194
  .createWalletCheckout(input: IWalletCheckoutInput): Promise<IApiResponse<ICheckoutUrlResult>>
195
+ .purchaseWalletPack(input: IWalletPurchaseInput): Promise<IApiResponse<IWalletPurchaseResult>>
195
196
  .getWalletTransactions(opts?: (IReadOptions & { cursor?: string; limit?: number; }) | undefined): Promise<IApiResponse<IWalletTransactionsResult>>
196
197
  .getPaymentMethod(opts?: IReadOptions | undefined): Promise<IApiResponse<IPaymentMethodResult>>
197
198
  .setupPaymentMethod(): Promise<IApiResponse<ISetupIntentResult>>
@@ -1014,6 +1015,20 @@ interface IWalletDTO {
1014
1015
  grantedExpiresAt?: string | null;
1015
1016
  }
1016
1017
 
1018
+ interface IWalletPurchaseInput {
1019
+ packId: string;
1020
+ idempotencyKey: string;
1021
+ }
1022
+
1023
+ interface IWalletPurchaseResult {
1024
+ status: 'credited' | 'checkout_required' | 'declined' | 'processing';
1025
+ balance?: string;
1026
+ currency?: string;
1027
+ credits?: string;
1028
+ duplicate?: boolean;
1029
+ reason?: 'no_saved_card' | 'authentication_required';
1030
+ }
1031
+
1017
1032
  interface IWalletResult {
1018
1033
  wallet: IWalletDTO;
1019
1034
  }
package/dist/index.cjs CHANGED
@@ -545,6 +545,21 @@ var BillingClient = class {
545
545
  workspaceId: this.workspaceId
546
546
  });
547
547
  }
548
+ // Buy a credit pack in-app by charging the saved card — no redirect. Inspect
549
+ // `result.status`: 'credited' (done — refresh the wallet), 'checkout_required'
550
+ // (no saved card or the card needs 3-D Secure → fall back to
551
+ // createWalletCheckout), 'declined', or 'processing' (indeterminate — retry
552
+ // with the SAME idempotencyKey). Generate one idempotencyKey per attempt and
553
+ // reuse it on retry so a double-submit can't double-charge.
554
+ purchaseWalletPack(input) {
555
+ return this.http.request({
556
+ method: "POST",
557
+ path: "/billing/wallet/purchase",
558
+ body: input,
559
+ token: this.tokens.get(),
560
+ workspaceId: this.workspaceId
561
+ });
562
+ }
548
563
  // The wallet ledger, newest first — every credit/debit with a running
549
564
  // balanceAfter. Cursor-paginated: pass the previous result's `nextCursor`.
550
565
  getWalletTransactions(opts) {