Added method to to update customer email address

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

This will be used by the users module when updating a members email
address to keep the Stripe Customer email in sync.
This commit is contained in:
Fabien O'Carroll 2020-09-28 13:09:11 +01:00
parent feaf73f7d2
commit b189584f98

View File

@ -418,6 +418,25 @@ module.exports = class StripePaymentProcessor {
await this._updateSubscription(subscription);
}
/**
* @param {string} customerId - The ID of the Stripe Customer to update
* @param {string} email - The email to update
*
* @returns {Promise<null>}
*/
async updateStripeCustomerEmail(customerId, email) {
try {
await update(this._stripe, 'customers', customerId, {
email
});
} catch (err) {
this.logging.error(err, {
message: 'Failed to update Stripe Customer email'
});
}
return null;
}
async _updateCustomer(member, customer) {
debug(`Attaching customer to member ${member.get('email')} ${customer.id}`);
await this.storage.set({