Skip to content

Commit a169c3b

Browse files
committed
Allow overriding quantity in sub plan switch script
1 parent 7d3c9f4 commit a169c3b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

scripts/switch-subscription-plan.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const email = process.argv[2];
1111
const newPlan = process.argv[3]
1212
const price = +process.argv[4];
1313
const currency = process.argv[5];
14+
const quantity = process.argv[6] ? +process.argv[6] : undefined;
1415

1516
(async () => {
1617
if (isNaN(price)) {
@@ -40,16 +41,18 @@ const currency = process.argv[5];
4041
const subscriptionId = user.app_metadata.subscription_id;
4142
const existingQuantity = user.app_metadata.subscription_quantity;
4243

44+
const newQuantity = quantity ?? existingQuantity ?? 1;
45+
4346
const { result } = await prompts({
4447
name: 'result',
4548
type: 'confirm',
4649
message: `Update subscription https://vendors.paddle.com/subscriptions/customers/manage/${subscriptionId} to ${
4750
newPlan
48-
} at ${
51+
} (x${newQuantity}) at ${
4952
price
5053
} ${
5154
currency
52-
}?`
55+
} each?`
5356
});
5457

5558
if (!result) {
@@ -66,7 +69,7 @@ const currency = process.argv[5];
6669
vendor_id: PADDLE_ID!,
6770
vendor_auth_code: PADDLE_KEY!,
6871
subscription_id: subscriptionId,
69-
quantity: existingQuantity ?? 1,
72+
quantity: newQuantity,
7073
plan_id: newPlan,
7174
currency: currency,
7275
recurring_price: price.toString(),

0 commit comments

Comments
 (0)