Skip to content

Commit

Permalink
Allows subscription quantities of zero on Pricing instances
Browse files Browse the repository at this point in the history
  • Loading branch information
chrissrogers committed Jul 16, 2024
1 parent dbe1dbc commit 0513ed5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/recurly/pricing/subscription/calculations.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ export default class Calculations {
const plan = this.items.plan;
if (!plan) return { amount: 0, setup_fee: 0 };
let price = plan.price[this.items.currency];
price.amount = price.unit_amount * (plan.quantity || 1);
let quantity = plan.quantity;
if (typeof quantity !== 'number') quantity = 1;
price.amount = price.unit_amount * quantity;
return price;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/recurly/pricing/subscription/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ export default class SubscriptionPricing extends Pricing {

// options.quantity, plan.quantity, 1
if (plan && plan.quantity) quantity = plan.quantity;
if (options.quantity) quantity = parseInt(options.quantity, 10);
if (!quantity || quantity < 1) quantity = 1;
if (typeof Number(options.quantity) === 'number') quantity = parseInt(options.quantity, 10);
if (typeof quantity !== 'number' || quantity < 0) quantity = 1;

return { currentPlan: plan, quantity, planCode, options, done };
}
Expand Down

0 comments on commit 0513ed5

Please sign in to comment.