Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async (data: any, context: CallableContext) => {
if (context.auth == null) {
return notAuthenticatedResponse
}
// todo: move this up to the global import runtime context if the tests are okay with it
chargebee.configure(getChargebeeOptions())
const checkoutOptions = {
subscription: { plan_id: data.planId },
customer: getUser(context),
}
return chargebee.hosted_page
.checkout_new(checkoutOptions)
.request(resultFormatter(hostedPage))
},
)
createHostedPageSubscription(planId, user, cb) {
const hostedPage = chargebee.hosted_page;
const checkoutFunc = user.subscriptionId
? hostedPage.checkout_existing : hostedPage.checkout_new;
const params = ({
subscription: {
plan_id: planId
},
customer: {
id: user && user._id.toString(),
email: user && user.email,
first_name: user.name && user.name.split(' ')[0],
last_name: ''
},
reactivate: true,
redirect_url: configChargebee.redirect_url,
cancel_url: configChargebee.cancel_url,
embed: true,