Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proration parameters and bump minor version number #30

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lemonsqueezy.ts",
"version": "0.1.7",
"version": "0.1.8",
"description": "JavaScript / TypeScript SDK for the Lemon Squeezy API",
"repository": {
"type": "git",
Expand Down
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
15 changes: 15 additions & 0 deletions src/modules/subscription/subscription.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,21 @@ 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.
* A new prorated invoice will be generated and payment attempted.
* Defaults to `false`. Note that this will be overridden by the `disableProrations` option if used.
*
* @docs https://docs.lemonsqueezy.com/api/subscriptions#update-a-subscription
*/
invoiceImmediately?: boolean;
/**
* If `true`, no proration will be charged and the customer will simply be charged the new price at the next renewal.
* Defaults to `false`. Note that this will override the `invoiceImmediately` option if used.
*
* @docs https://docs.lemonsqueezy.com/api/subscriptions#update-a-subscription
*/
disableProrations?: boolean;
}

export type UpdateSubscriptionResult =
Expand Down