Updated setComplimentarySubscription to error without a Stripe connection

no-issue

This allows the consumer (e.g. the importer) to surfaces errors when importing comped members
This commit is contained in:
Fabien O'Carroll 2020-10-27 11:01:47 +00:00 committed by Fabien 'egg' O'Carroll
parent d70aab83f6
commit 3abb0c543b

View File

@ -145,6 +145,15 @@ module.exports = function ({
return stripe.linkStripeCustomer(id, member, options);
}
async function setComplimentarySubscription(member, options) {
if (!stripe) {
throw new common.errors.BadRequestError({
message: 'Cannot link create Complimentary Subscription without a Stripe connection'
});
}
return stripe.setComplimentarySubscription(member, options);
}
return {
create,
update,
@ -152,7 +161,7 @@ module.exports = function ({
get,
destroy,
updateSubscription,
setComplimentarySubscription: safeStripe('setComplimentarySubscription'),
setComplimentarySubscription,
setComplimentarySubscriptionById,
cancelComplimentarySubscription: safeStripe('cancelComplimentarySubscription'),
cancelStripeSubscriptions: safeStripe('cancelComplimentarySubscription'),