Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Proration configs added to update subscription #26

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/modules/subscription/subscription.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export async function retrieveSubscription(
export async function updateSubscription(
options: UpdateSubscriptionOptions & SharedModuleOptions
): Promise<UpdateSubscriptionResult> {
const { billingAnchor, cancelled, id, pause, productId, variantId, ...rest } =
const { billingAnchor, cancelled, id, pause, productId, variantId, invoiceImmediately, disableProrations, ...rest } =
options;

return requestLemonSqueeze<UpdateSubscriptionResult>({
Expand All @@ -106,6 +106,8 @@ export async function updateSubscription(
pause,
product_id: productId,
variant_id: variantId,
invoice_immediately: invoiceImmediately,
disable_prorations: disableProrations
},
id,
type: LemonsqueezyDataType.subscriptions,
Expand Down
13 changes: 13 additions & 0 deletions src/modules/subscription/subscription.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,19 @@ export interface UpdateSubscriptionOptions extends SharedLemonsqueezyOptions {
* @docs https://docs.lemonsqueezy.com/api/variants
*/
variantId: string;
/**
* If true, any updates to the subscription will be charged immediately.
*
* @docs https://docs.lemonsqueezy.com/guides/developer-guide/managing-subscriptions#handling-proration
*/
invoiceImmediately?: boolean;
/**
* If true, any updates to the subscription will be charged immediately but will not be prorated.
* Note that this will override the invoice_immediately option if enabled.
*
* @docs https://docs.lemonsqueezy.com/guides/developer-guide/managing-subscriptions#handling-proration
*/
disableProrations?: boolean;
}

export type UpdateSubscriptionResult =
Expand Down