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

Commit

Permalink
Merge pull request #26 from Rameshv/main
Browse files Browse the repository at this point in the history
Proration configs added to update subscription
  • Loading branch information
NuroDev authored Nov 4, 2024
2 parents f3072a3 + 5b2dae5 commit c187ff3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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

0 comments on commit c187ff3

Please sign in to comment.