@stackbe/sdk 0.5.0 → 0.6.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/dist/index.d.mts +52 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.js +53 -0
- package/dist/index.mjs +53 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -184,6 +184,10 @@ interface Subscription {
|
|
|
184
184
|
currentPeriodStart: string;
|
|
185
185
|
currentPeriodEnd: string;
|
|
186
186
|
cancelAtPeriodEnd: boolean;
|
|
187
|
+
/** When the subscription was paused (null if not paused) */
|
|
188
|
+
pausedAt?: string | null;
|
|
189
|
+
/** When the subscription will auto-resume (null = indefinite pause) */
|
|
190
|
+
resumesAt?: string | null;
|
|
187
191
|
createdAt: string;
|
|
188
192
|
}
|
|
189
193
|
interface CustomerWithSubscription extends Customer {
|
|
@@ -378,6 +382,10 @@ interface SubscriptionWebhookPayload {
|
|
|
378
382
|
currentPeriodEnd: string;
|
|
379
383
|
cancelAtPeriodEnd: boolean;
|
|
380
384
|
trialEnd?: string;
|
|
385
|
+
/** When the subscription was paused (null if not paused) */
|
|
386
|
+
pausedAt?: string | null;
|
|
387
|
+
/** When the subscription will auto-resume (null = indefinite pause) */
|
|
388
|
+
resumesAt?: string | null;
|
|
381
389
|
}
|
|
382
390
|
/** Customer webhook payload */
|
|
383
391
|
interface CustomerWebhookPayload {
|
|
@@ -860,6 +868,50 @@ declare class SubscriptionsClient {
|
|
|
860
868
|
* ```
|
|
861
869
|
*/
|
|
862
870
|
isActive(customerId: string): Promise<boolean>;
|
|
871
|
+
/**
|
|
872
|
+
* Pause a subscription.
|
|
873
|
+
*
|
|
874
|
+
* Pauses billing collection for a subscription. The subscription remains
|
|
875
|
+
* active but no invoices are generated while paused. Use cases include:
|
|
876
|
+
* - Customer requests temporary pause (vacation, budget constraints)
|
|
877
|
+
* - Seasonal businesses with predictable downtime
|
|
878
|
+
* - Retention strategy: offer pause instead of cancel
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* // Pause indefinitely (until manually resumed)
|
|
883
|
+
* await stackbe.subscriptions.pause('sub_123');
|
|
884
|
+
*
|
|
885
|
+
* // Pause for 30 days (auto-resume)
|
|
886
|
+
* const resumeDate = new Date();
|
|
887
|
+
* resumeDate.setDate(resumeDate.getDate() + 30);
|
|
888
|
+
* await stackbe.subscriptions.pause('sub_123', { resumesAt: resumeDate });
|
|
889
|
+
*
|
|
890
|
+
* // Check if paused
|
|
891
|
+
* const sub = await stackbe.subscriptions.get('cust_123');
|
|
892
|
+
* if (sub?.pausedAt) {
|
|
893
|
+
* console.log('Subscription is paused');
|
|
894
|
+
* if (sub.resumesAt) {
|
|
895
|
+
* console.log(`Will resume on ${sub.resumesAt}`);
|
|
896
|
+
* }
|
|
897
|
+
* }
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
pause(subscriptionId: string, options?: {
|
|
901
|
+
resumesAt?: Date;
|
|
902
|
+
}): Promise<Subscription>;
|
|
903
|
+
/**
|
|
904
|
+
* Resume a paused subscription.
|
|
905
|
+
*
|
|
906
|
+
* Restarts billing collection for a paused subscription.
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* ```typescript
|
|
910
|
+
* // Resume a paused subscription
|
|
911
|
+
* await stackbe.subscriptions.resume('sub_123');
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
resume(subscriptionId: string): Promise<Subscription>;
|
|
863
915
|
}
|
|
864
916
|
|
|
865
917
|
interface AuthClientOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -184,6 +184,10 @@ interface Subscription {
|
|
|
184
184
|
currentPeriodStart: string;
|
|
185
185
|
currentPeriodEnd: string;
|
|
186
186
|
cancelAtPeriodEnd: boolean;
|
|
187
|
+
/** When the subscription was paused (null if not paused) */
|
|
188
|
+
pausedAt?: string | null;
|
|
189
|
+
/** When the subscription will auto-resume (null = indefinite pause) */
|
|
190
|
+
resumesAt?: string | null;
|
|
187
191
|
createdAt: string;
|
|
188
192
|
}
|
|
189
193
|
interface CustomerWithSubscription extends Customer {
|
|
@@ -378,6 +382,10 @@ interface SubscriptionWebhookPayload {
|
|
|
378
382
|
currentPeriodEnd: string;
|
|
379
383
|
cancelAtPeriodEnd: boolean;
|
|
380
384
|
trialEnd?: string;
|
|
385
|
+
/** When the subscription was paused (null if not paused) */
|
|
386
|
+
pausedAt?: string | null;
|
|
387
|
+
/** When the subscription will auto-resume (null = indefinite pause) */
|
|
388
|
+
resumesAt?: string | null;
|
|
381
389
|
}
|
|
382
390
|
/** Customer webhook payload */
|
|
383
391
|
interface CustomerWebhookPayload {
|
|
@@ -860,6 +868,50 @@ declare class SubscriptionsClient {
|
|
|
860
868
|
* ```
|
|
861
869
|
*/
|
|
862
870
|
isActive(customerId: string): Promise<boolean>;
|
|
871
|
+
/**
|
|
872
|
+
* Pause a subscription.
|
|
873
|
+
*
|
|
874
|
+
* Pauses billing collection for a subscription. The subscription remains
|
|
875
|
+
* active but no invoices are generated while paused. Use cases include:
|
|
876
|
+
* - Customer requests temporary pause (vacation, budget constraints)
|
|
877
|
+
* - Seasonal businesses with predictable downtime
|
|
878
|
+
* - Retention strategy: offer pause instead of cancel
|
|
879
|
+
*
|
|
880
|
+
* @example
|
|
881
|
+
* ```typescript
|
|
882
|
+
* // Pause indefinitely (until manually resumed)
|
|
883
|
+
* await stackbe.subscriptions.pause('sub_123');
|
|
884
|
+
*
|
|
885
|
+
* // Pause for 30 days (auto-resume)
|
|
886
|
+
* const resumeDate = new Date();
|
|
887
|
+
* resumeDate.setDate(resumeDate.getDate() + 30);
|
|
888
|
+
* await stackbe.subscriptions.pause('sub_123', { resumesAt: resumeDate });
|
|
889
|
+
*
|
|
890
|
+
* // Check if paused
|
|
891
|
+
* const sub = await stackbe.subscriptions.get('cust_123');
|
|
892
|
+
* if (sub?.pausedAt) {
|
|
893
|
+
* console.log('Subscription is paused');
|
|
894
|
+
* if (sub.resumesAt) {
|
|
895
|
+
* console.log(`Will resume on ${sub.resumesAt}`);
|
|
896
|
+
* }
|
|
897
|
+
* }
|
|
898
|
+
* ```
|
|
899
|
+
*/
|
|
900
|
+
pause(subscriptionId: string, options?: {
|
|
901
|
+
resumesAt?: Date;
|
|
902
|
+
}): Promise<Subscription>;
|
|
903
|
+
/**
|
|
904
|
+
* Resume a paused subscription.
|
|
905
|
+
*
|
|
906
|
+
* Restarts billing collection for a paused subscription.
|
|
907
|
+
*
|
|
908
|
+
* @example
|
|
909
|
+
* ```typescript
|
|
910
|
+
* // Resume a paused subscription
|
|
911
|
+
* await stackbe.subscriptions.resume('sub_123');
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
resume(subscriptionId: string): Promise<Subscription>;
|
|
863
915
|
}
|
|
864
916
|
|
|
865
917
|
interface AuthClientOptions {
|
package/dist/index.js
CHANGED
|
@@ -802,6 +802,59 @@ var SubscriptionsClient = class {
|
|
|
802
802
|
const subscription = await this.get(customerId);
|
|
803
803
|
return subscription !== null && (subscription.status === "active" || subscription.status === "trialing");
|
|
804
804
|
}
|
|
805
|
+
/**
|
|
806
|
+
* Pause a subscription.
|
|
807
|
+
*
|
|
808
|
+
* Pauses billing collection for a subscription. The subscription remains
|
|
809
|
+
* active but no invoices are generated while paused. Use cases include:
|
|
810
|
+
* - Customer requests temporary pause (vacation, budget constraints)
|
|
811
|
+
* - Seasonal businesses with predictable downtime
|
|
812
|
+
* - Retention strategy: offer pause instead of cancel
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```typescript
|
|
816
|
+
* // Pause indefinitely (until manually resumed)
|
|
817
|
+
* await stackbe.subscriptions.pause('sub_123');
|
|
818
|
+
*
|
|
819
|
+
* // Pause for 30 days (auto-resume)
|
|
820
|
+
* const resumeDate = new Date();
|
|
821
|
+
* resumeDate.setDate(resumeDate.getDate() + 30);
|
|
822
|
+
* await stackbe.subscriptions.pause('sub_123', { resumesAt: resumeDate });
|
|
823
|
+
*
|
|
824
|
+
* // Check if paused
|
|
825
|
+
* const sub = await stackbe.subscriptions.get('cust_123');
|
|
826
|
+
* if (sub?.pausedAt) {
|
|
827
|
+
* console.log('Subscription is paused');
|
|
828
|
+
* if (sub.resumesAt) {
|
|
829
|
+
* console.log(`Will resume on ${sub.resumesAt}`);
|
|
830
|
+
* }
|
|
831
|
+
* }
|
|
832
|
+
* ```
|
|
833
|
+
*/
|
|
834
|
+
async pause(subscriptionId, options = {}) {
|
|
835
|
+
return this.http.post(
|
|
836
|
+
`/v1/subscriptions/${subscriptionId}/pause`,
|
|
837
|
+
{
|
|
838
|
+
resumesAt: options.resumesAt?.toISOString()
|
|
839
|
+
}
|
|
840
|
+
);
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Resume a paused subscription.
|
|
844
|
+
*
|
|
845
|
+
* Restarts billing collection for a paused subscription.
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* ```typescript
|
|
849
|
+
* // Resume a paused subscription
|
|
850
|
+
* await stackbe.subscriptions.resume('sub_123');
|
|
851
|
+
* ```
|
|
852
|
+
*/
|
|
853
|
+
async resume(subscriptionId) {
|
|
854
|
+
return this.http.post(
|
|
855
|
+
`/v1/subscriptions/${subscriptionId}/resume`
|
|
856
|
+
);
|
|
857
|
+
}
|
|
805
858
|
};
|
|
806
859
|
|
|
807
860
|
// src/auth.ts
|
package/dist/index.mjs
CHANGED
|
@@ -769,6 +769,59 @@ var SubscriptionsClient = class {
|
|
|
769
769
|
const subscription = await this.get(customerId);
|
|
770
770
|
return subscription !== null && (subscription.status === "active" || subscription.status === "trialing");
|
|
771
771
|
}
|
|
772
|
+
/**
|
|
773
|
+
* Pause a subscription.
|
|
774
|
+
*
|
|
775
|
+
* Pauses billing collection for a subscription. The subscription remains
|
|
776
|
+
* active but no invoices are generated while paused. Use cases include:
|
|
777
|
+
* - Customer requests temporary pause (vacation, budget constraints)
|
|
778
|
+
* - Seasonal businesses with predictable downtime
|
|
779
|
+
* - Retention strategy: offer pause instead of cancel
|
|
780
|
+
*
|
|
781
|
+
* @example
|
|
782
|
+
* ```typescript
|
|
783
|
+
* // Pause indefinitely (until manually resumed)
|
|
784
|
+
* await stackbe.subscriptions.pause('sub_123');
|
|
785
|
+
*
|
|
786
|
+
* // Pause for 30 days (auto-resume)
|
|
787
|
+
* const resumeDate = new Date();
|
|
788
|
+
* resumeDate.setDate(resumeDate.getDate() + 30);
|
|
789
|
+
* await stackbe.subscriptions.pause('sub_123', { resumesAt: resumeDate });
|
|
790
|
+
*
|
|
791
|
+
* // Check if paused
|
|
792
|
+
* const sub = await stackbe.subscriptions.get('cust_123');
|
|
793
|
+
* if (sub?.pausedAt) {
|
|
794
|
+
* console.log('Subscription is paused');
|
|
795
|
+
* if (sub.resumesAt) {
|
|
796
|
+
* console.log(`Will resume on ${sub.resumesAt}`);
|
|
797
|
+
* }
|
|
798
|
+
* }
|
|
799
|
+
* ```
|
|
800
|
+
*/
|
|
801
|
+
async pause(subscriptionId, options = {}) {
|
|
802
|
+
return this.http.post(
|
|
803
|
+
`/v1/subscriptions/${subscriptionId}/pause`,
|
|
804
|
+
{
|
|
805
|
+
resumesAt: options.resumesAt?.toISOString()
|
|
806
|
+
}
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
/**
|
|
810
|
+
* Resume a paused subscription.
|
|
811
|
+
*
|
|
812
|
+
* Restarts billing collection for a paused subscription.
|
|
813
|
+
*
|
|
814
|
+
* @example
|
|
815
|
+
* ```typescript
|
|
816
|
+
* // Resume a paused subscription
|
|
817
|
+
* await stackbe.subscriptions.resume('sub_123');
|
|
818
|
+
* ```
|
|
819
|
+
*/
|
|
820
|
+
async resume(subscriptionId) {
|
|
821
|
+
return this.http.post(
|
|
822
|
+
`/v1/subscriptions/${subscriptionId}/resume`
|
|
823
|
+
);
|
|
824
|
+
}
|
|
772
825
|
};
|
|
773
826
|
|
|
774
827
|
// src/auth.ts
|
package/package.json
CHANGED