From b189584f98e01e6774fef702f3e481e877a353cd Mon Sep 17 00:00:00 2001 From: Fabien O'Carroll Date: Mon, 28 Sep 2020 13:09:11 +0100 Subject: [PATCH] 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. --- ghost/members-api/lib/stripe/index.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ghost/members-api/lib/stripe/index.js b/ghost/members-api/lib/stripe/index.js index 2f1118870c..789d1390a9 100644 --- a/ghost/members-api/lib/stripe/index.js +++ b/ghost/members-api/lib/stripe/index.js @@ -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} + */ + 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({