Skip to content

Commit

Permalink
Merge pull request #225 from recurly/add-subscription-id
Browse files Browse the repository at this point in the history
Adds Subscription id pass-through for useCheckoutPricing
  • Loading branch information
douglasmiller authored May 13, 2024
2 parents 41152ff + bf2706d commit b806c1c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions lib/use-checkout-pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,19 @@ export default function useCheckoutPricing (initialInputs, handleError = throwEr

function addSubscriptions(subscriptions, checkoutPricing) {
const { subscriptionPricings } = subscriptions.reduce(
({ checkoutPricing, subscriptionPricings }, { plan, tax, addons = [], quantity }) => {
let subscriptionPricing;
({ checkoutPricing, subscriptionPricings }, { id, plan, tax, addons = [], quantity }) => {
let subscriptionPricing = recurly.Pricing.Subscription();

if (id) {
subscriptionPricing.id = id;
}

if (restInputs.currency) {
subscriptionPricing = recurly.Pricing.Subscription().currency(restInputs.currency).plan(plan, { quantity });
} else {
subscriptionPricing = recurly.Pricing.Subscription().plan(plan, { quantity });
subscriptionPricing = subscriptionPricing.currency(restInputs.currency);
}

subscriptionPricing = subscriptionPricing.plan(plan, { quantity });

if (addons.length) {
subscriptionPricing = addAddons(addons, subscriptionPricing);
}
Expand Down

0 comments on commit b806c1c

Please sign in to comment.