Skip to content

Commit 63fa204

Browse files
authored
chore(backend): Add extend trial endpoint (#6714)
1 parent 637f2e8 commit 63fa204

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

.changeset/public-goats-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/backend': minor
3+
---
4+
5+
Extend the trial of a subscription item via the BillingAPI.

packages/backend/src/api/endpoints/BillingApi.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ type CancelSubscriptionItemParams = {
2323
endNow?: boolean;
2424
};
2525

26+
type ExtendSubscriptionItemFreeTrialParams = {
27+
/**
28+
* RFC3339 timestamp to extend the free trial to.
29+
* Must be in the future and not more than 365 days from the current trial end.
30+
*/
31+
extendTo: Date;
32+
};
33+
2634
export class BillingAPI extends AbstractAPI {
2735
/**
2836
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
@@ -49,6 +57,22 @@ export class BillingAPI extends AbstractAPI {
4957
});
5058
}
5159

60+
/**
61+
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
62+
* It is advised to pin the SDK version to avoid breaking changes.
63+
*/
64+
public async extendSubscriptionItemFreeTrial(
65+
subscriptionItemId: string,
66+
params: ExtendSubscriptionItemFreeTrialParams,
67+
) {
68+
this.requireId(subscriptionItemId);
69+
return this.request<CommerceSubscriptionItem>({
70+
method: 'POST',
71+
path: joinPaths('/billing', 'subscription_items', subscriptionItemId, 'extend_free_trial'),
72+
bodyParams: params,
73+
});
74+
}
75+
5276
/**
5377
* @experimental This is an experimental API for the Billing feature that is available under a public beta, and the API is subject to change.
5478
* It is advised to pin the SDK version to avoid breaking changes.

0 commit comments

Comments
 (0)