Allowed requestSrc in stripe checkout metadata flow

refs https://github.com/TryGhost/Ghost/issues/12253

Allows reading `requestSrc` from Stripe checkout flow metadata to send signup emails with customized action param when requesting from Portal
This commit is contained in:
Rish 2020-10-29 12:12:15 +05:30
parent 1ba68ce72f
commit 18fa6ead56

View File

@ -121,7 +121,7 @@ module.exports = function MembersApi({
Member Member
}); });
async function sendEmailWithMagicLink({email, requestedType, requestSrc, tokenData, options = {forceEmailType: false}}) { async function sendEmailWithMagicLink({email, requestedType, tokenData, options = {forceEmailType: false}, requestSrc = ''}) {
let type = requestedType; let type = requestedType;
if (!options.forceEmailType) { if (!options.forceEmailType) {
const member = await users.get({email}); const member = await users.get({email});
@ -389,6 +389,7 @@ module.exports = function MembersApi({
}); });
let member = await users.get({email: customer.email}); let member = await users.get({email: customer.email});
const checkoutType = _.get(event, 'data.object.metadata.checkoutType'); const checkoutType = _.get(event, 'data.object.metadata.checkoutType');
const requestSrc = _.get(event, 'data.object.metadata.requestSrc') || '';
if (!member) { if (!member) {
const metadataName = _.get(event, 'data.object.metadata.name'); const metadataName = _.get(event, 'data.object.metadata.name');
const payerName = _.get(customer, 'subscriptions.data[0].default_payment_method.billing_details.name'); const payerName = _.get(customer, 'subscriptions.data[0].default_payment_method.billing_details.name');