mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Updated customer when member email is changed
refs: https://github.com/TryGhost/Ghost/issues/12055 This ensures that newsletters and billing related emails are all sent to the same address
This commit is contained in:
parent
b189584f98
commit
f41f366b5a
1 changed files with 9 additions and 1 deletions
|
@ -29,7 +29,7 @@ module.exports = function ({
|
|||
|
||||
async function update(data, options) {
|
||||
debug(`update id:${options.id}`);
|
||||
return Member.edit(_.pick(data, [
|
||||
const member = await Member.edit(_.pick(data, [
|
||||
'email',
|
||||
'name',
|
||||
'note',
|
||||
|
@ -37,6 +37,14 @@ module.exports = function ({
|
|||
'labels',
|
||||
'geolocation'
|
||||
]), options);
|
||||
if (member._changed.email) {
|
||||
await member.related('stripeCustomers').fetch();
|
||||
const customers = member.related('stripeCustomers');
|
||||
for (const customer of customers.models) {
|
||||
await stripe.updateStripeCustomerEmail(customer.get('customer_id'), member.get('email'));
|
||||
}
|
||||
}
|
||||
return member;
|
||||
}
|
||||
|
||||
async function list(options = {}) {
|
||||
|
|
Loading…
Add table
Reference in a new issue