@stackbe/sdk 0.8.4 → 0.8.5

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/dist/index.d.mts CHANGED
@@ -720,6 +720,42 @@ declare class EntitlementsClient {
720
720
  require(customerId: string, feature: string): Promise<void>;
721
721
  }
722
722
 
723
+ interface CustomerSubscriptionHistory {
724
+ id: string;
725
+ status: string;
726
+ planId: string;
727
+ planName?: string;
728
+ priceCents?: number;
729
+ currency?: string;
730
+ interval?: string;
731
+ currentPeriodStart?: string;
732
+ currentPeriodEnd?: string;
733
+ cancelAtPeriodEnd: boolean;
734
+ pausedAt?: string | null;
735
+ resumesAt?: string | null;
736
+ createdAt: string;
737
+ }
738
+ interface CustomerSubscriptionHistoryResponse {
739
+ subscriptions: CustomerSubscriptionHistory[];
740
+ total: number;
741
+ }
742
+ interface CustomerInvoice {
743
+ id: string;
744
+ number?: string;
745
+ status?: string;
746
+ amountPaid: number;
747
+ amountDue: number;
748
+ currency: string;
749
+ created: string;
750
+ periodStart?: string;
751
+ periodEnd?: string;
752
+ invoiceUrl?: string;
753
+ invoicePdf?: string;
754
+ }
755
+ interface CustomerInvoicesResponse {
756
+ invoices: CustomerInvoice[];
757
+ hasMore: boolean;
758
+ }
723
759
  declare class CustomersClient {
724
760
  private http;
725
761
  private appId;
@@ -814,6 +850,35 @@ declare class CustomersClient {
814
850
  * ```
815
851
  */
816
852
  getSession(token: string): Promise<SessionResponse>;
853
+ /**
854
+ * Get a customer's subscription history (all subscriptions, including past).
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * const { subscriptions, total } = await stackbe.customers.getSubscriptionHistory('cust_123');
859
+ *
860
+ * subscriptions.forEach(sub => {
861
+ * console.log(`${sub.planName} - ${sub.status} (${sub.createdAt})`);
862
+ * });
863
+ * ```
864
+ */
865
+ getSubscriptionHistory(customerId: string): Promise<CustomerSubscriptionHistoryResponse>;
866
+ /**
867
+ * Get a customer's invoice/payment history from Stripe.
868
+ *
869
+ * @example
870
+ * ```typescript
871
+ * const { invoices, hasMore } = await stackbe.customers.getInvoices('cust_123');
872
+ *
873
+ * invoices.forEach(inv => {
874
+ * console.log(`Invoice ${inv.number}: $${inv.amountPaid} - ${inv.status}`);
875
+ * console.log(`PDF: ${inv.invoicePdf}`);
876
+ * });
877
+ * ```
878
+ */
879
+ getInvoices(customerId: string, options?: {
880
+ limit?: number;
881
+ }): Promise<CustomerInvoicesResponse>;
817
882
  }
818
883
 
819
884
  declare class CheckoutClient {
@@ -2081,4 +2146,4 @@ declare class StackBE {
2081
2146
  }): (req: any, res: any, next: any) => Promise<any>;
2082
2147
  }
2083
2148
 
2084
- export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type GetSubscriptionOptions, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
2149
+ export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerInvoice, type CustomerInvoicesResponse, type CustomerSubscriptionHistory, type CustomerSubscriptionHistoryResponse, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type GetSubscriptionOptions, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
package/dist/index.d.ts CHANGED
@@ -720,6 +720,42 @@ declare class EntitlementsClient {
720
720
  require(customerId: string, feature: string): Promise<void>;
721
721
  }
722
722
 
723
+ interface CustomerSubscriptionHistory {
724
+ id: string;
725
+ status: string;
726
+ planId: string;
727
+ planName?: string;
728
+ priceCents?: number;
729
+ currency?: string;
730
+ interval?: string;
731
+ currentPeriodStart?: string;
732
+ currentPeriodEnd?: string;
733
+ cancelAtPeriodEnd: boolean;
734
+ pausedAt?: string | null;
735
+ resumesAt?: string | null;
736
+ createdAt: string;
737
+ }
738
+ interface CustomerSubscriptionHistoryResponse {
739
+ subscriptions: CustomerSubscriptionHistory[];
740
+ total: number;
741
+ }
742
+ interface CustomerInvoice {
743
+ id: string;
744
+ number?: string;
745
+ status?: string;
746
+ amountPaid: number;
747
+ amountDue: number;
748
+ currency: string;
749
+ created: string;
750
+ periodStart?: string;
751
+ periodEnd?: string;
752
+ invoiceUrl?: string;
753
+ invoicePdf?: string;
754
+ }
755
+ interface CustomerInvoicesResponse {
756
+ invoices: CustomerInvoice[];
757
+ hasMore: boolean;
758
+ }
723
759
  declare class CustomersClient {
724
760
  private http;
725
761
  private appId;
@@ -814,6 +850,35 @@ declare class CustomersClient {
814
850
  * ```
815
851
  */
816
852
  getSession(token: string): Promise<SessionResponse>;
853
+ /**
854
+ * Get a customer's subscription history (all subscriptions, including past).
855
+ *
856
+ * @example
857
+ * ```typescript
858
+ * const { subscriptions, total } = await stackbe.customers.getSubscriptionHistory('cust_123');
859
+ *
860
+ * subscriptions.forEach(sub => {
861
+ * console.log(`${sub.planName} - ${sub.status} (${sub.createdAt})`);
862
+ * });
863
+ * ```
864
+ */
865
+ getSubscriptionHistory(customerId: string): Promise<CustomerSubscriptionHistoryResponse>;
866
+ /**
867
+ * Get a customer's invoice/payment history from Stripe.
868
+ *
869
+ * @example
870
+ * ```typescript
871
+ * const { invoices, hasMore } = await stackbe.customers.getInvoices('cust_123');
872
+ *
873
+ * invoices.forEach(inv => {
874
+ * console.log(`Invoice ${inv.number}: $${inv.amountPaid} - ${inv.status}`);
875
+ * console.log(`PDF: ${inv.invoicePdf}`);
876
+ * });
877
+ * ```
878
+ */
879
+ getInvoices(customerId: string, options?: {
880
+ limit?: number;
881
+ }): Promise<CustomerInvoicesResponse>;
817
882
  }
818
883
 
819
884
  declare class CheckoutClient {
@@ -2081,4 +2146,4 @@ declare class StackBE {
2081
2146
  }): (req: any, res: any, next: any) => Promise<any>;
2082
2147
  }
2083
2148
 
2084
- export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type GetSubscriptionOptions, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
2149
+ export { type AddMemberOptions, type AffiliateCommission, type AffiliateCommissionsResponse, type AffiliateEnrollment, type AffiliateInfo, type AffiliateStats, AffiliatesClient, type AnyWebhookEvent, AuthClient, type CancelSubscriptionOptions, type CancelSubscriptionResponse, type CheckEntitlementResponse, type CheckUsageResponse, CheckoutClient, type CheckoutSessionResponse, type CreateCheckoutOptions, type CreateCustomerOptions, type CreateEarlyAccessSignupOptions, type CreateFeatureRequestOptions, type CreateOrganizationOptions, type Customer, type CustomerCreatedEvent, type CustomerFeatureActivity, type CustomerInvoice, type CustomerInvoicesResponse, type CustomerSubscriptionHistory, type CustomerSubscriptionHistoryResponse, type CustomerUpdatedEvent, type CustomerUsageResponse, type CustomerWebhookPayload, type CustomerWithSubscription, CustomersClient, EarlyAccessClient, type EarlyAccessSignup, type EarlyAccessSignupListResponse, type EnrollOptions, EntitlementsClient, type EntitlementsResponse, type FeatureRequest, type FeatureRequestComment, type FeatureRequestImage, type FeatureRequestListResponse, FeatureRequestsClient, type GetSubscriptionOptions, type InterestedCustomer, type InterestedCustomersResponse, type InviteMemberOptions, type ListEarlyAccessOptions, type ListFeatureRequestsOptions, type ListPlansOptions, type ListProductsOptions, type MagicLinkOptions, type MagicLinkResponse, type Organization, type OrganizationInvite, type OrganizationMember, OrganizationsClient, type PaymentFailedEvent, type PaymentSucceededEvent, type PaymentWebhookPayload, type Plan, PlansClient, type Product, ProductsClient, type SessionResponse, StackBE, type StackBEConfig, StackBEError, type StackBEErrorCode, type StackBEErrorResponse, type Subscription, type SubscriptionCancelledEvent, type SubscriptionCreatedEvent, type SubscriptionPlan, type SubscriptionRenewedEvent, type SubscriptionUpdatedEvent, type SubscriptionWebhookPayload, type SubscriptionWithPlan, SubscriptionsClient, type TrackReferralResponse, type TrackUsageOptions, type TrackUsageResponse, type TrialEndedEvent, type TrialStartedEvent, type UpdateCustomerOptions, type UpdateOrganizationOptions, type UpdateSubscriptionOptions, UsageClient, type UsageMetric, type VerifyTokenResponse, type WebhookEvent, type WebhookEventType };
package/dist/index.js CHANGED
@@ -612,6 +612,45 @@ var CustomersClient = class {
612
612
  }
613
613
  return response.json();
614
614
  }
615
+ // ==================== Billing History ====================
616
+ /**
617
+ * Get a customer's subscription history (all subscriptions, including past).
618
+ *
619
+ * @example
620
+ * ```typescript
621
+ * const { subscriptions, total } = await stackbe.customers.getSubscriptionHistory('cust_123');
622
+ *
623
+ * subscriptions.forEach(sub => {
624
+ * console.log(`${sub.planName} - ${sub.status} (${sub.createdAt})`);
625
+ * });
626
+ * ```
627
+ */
628
+ async getSubscriptionHistory(customerId) {
629
+ return this.http.get(
630
+ `/v1/apps/${this.appId}/customers/${customerId}/subscriptions`
631
+ );
632
+ }
633
+ /**
634
+ * Get a customer's invoice/payment history from Stripe.
635
+ *
636
+ * @example
637
+ * ```typescript
638
+ * const { invoices, hasMore } = await stackbe.customers.getInvoices('cust_123');
639
+ *
640
+ * invoices.forEach(inv => {
641
+ * console.log(`Invoice ${inv.number}: $${inv.amountPaid} - ${inv.status}`);
642
+ * console.log(`PDF: ${inv.invoicePdf}`);
643
+ * });
644
+ * ```
645
+ */
646
+ async getInvoices(customerId, options) {
647
+ const params = {};
648
+ if (options?.limit) params.limit = options.limit;
649
+ return this.http.get(
650
+ `/v1/apps/${this.appId}/customers/${customerId}/invoices`,
651
+ params
652
+ );
653
+ }
615
654
  };
616
655
 
617
656
  // src/checkout.ts
package/dist/index.mjs CHANGED
@@ -573,6 +573,45 @@ var CustomersClient = class {
573
573
  }
574
574
  return response.json();
575
575
  }
576
+ // ==================== Billing History ====================
577
+ /**
578
+ * Get a customer's subscription history (all subscriptions, including past).
579
+ *
580
+ * @example
581
+ * ```typescript
582
+ * const { subscriptions, total } = await stackbe.customers.getSubscriptionHistory('cust_123');
583
+ *
584
+ * subscriptions.forEach(sub => {
585
+ * console.log(`${sub.planName} - ${sub.status} (${sub.createdAt})`);
586
+ * });
587
+ * ```
588
+ */
589
+ async getSubscriptionHistory(customerId) {
590
+ return this.http.get(
591
+ `/v1/apps/${this.appId}/customers/${customerId}/subscriptions`
592
+ );
593
+ }
594
+ /**
595
+ * Get a customer's invoice/payment history from Stripe.
596
+ *
597
+ * @example
598
+ * ```typescript
599
+ * const { invoices, hasMore } = await stackbe.customers.getInvoices('cust_123');
600
+ *
601
+ * invoices.forEach(inv => {
602
+ * console.log(`Invoice ${inv.number}: $${inv.amountPaid} - ${inv.status}`);
603
+ * console.log(`PDF: ${inv.invoicePdf}`);
604
+ * });
605
+ * ```
606
+ */
607
+ async getInvoices(customerId, options) {
608
+ const params = {};
609
+ if (options?.limit) params.limit = options.limit;
610
+ return this.http.get(
611
+ `/v1/apps/${this.appId}/customers/${customerId}/invoices`,
612
+ params
613
+ );
614
+ }
576
615
  };
577
616
 
578
617
  // src/checkout.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbe/sdk",
3
- "version": "0.8.4",
3
+ "version": "0.8.5",
4
4
  "description": "Official JavaScript/TypeScript SDK for StackBE - the billing backend for your side project",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",