mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 21:40:39 +03:00
Updated stripe checkout to store member name from metadata
refs TryGhost/members.js#29 - Uses the metadata option in stripe checkout flow to add member's name on creation via anonymous checkout flow - Allows clients like memebrs.js to pass member's info like name from checkout signup flow
This commit is contained in:
parent
2f90c97629
commit
167811c5fd
@ -301,8 +301,12 @@ module.exports = function MembersApi({
|
|||||||
const customer = await stripe.getCustomer(event.data.object.customer, {
|
const customer = await stripe.getCustomer(event.data.object.customer, {
|
||||||
expand: ['subscriptions.data.default_payment_method']
|
expand: ['subscriptions.data.default_payment_method']
|
||||||
});
|
});
|
||||||
|
let member = await users.get({email: customer.email});
|
||||||
const member = await users.get({email: customer.email}) || await users.create({email: customer.email});
|
if (!member) {
|
||||||
|
const metadata = event.data.object.metadata;
|
||||||
|
const name = (metadata && metadata.name) || '';
|
||||||
|
member = await users.create({email: customer.email, name});
|
||||||
|
}
|
||||||
await stripe.handleCheckoutSessionCompletedWebhook(member, customer);
|
await stripe.handleCheckoutSessionCompletedWebhook(member, customer);
|
||||||
|
|
||||||
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');
|
||||||
|
Loading…
Reference in New Issue
Block a user