0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Ensured member is not linked to customer twice

no-issue

Edge case but easy to solve - so we dun it
This commit is contained in:
Fabien O'Carroll 2019-09-25 10:29:27 +07:00
parent db42b35e9f
commit 6722d3bc8a

View file

@ -115,6 +115,10 @@ module.exports = class StripePaymentProcessor {
async addCustomerToMember(member, customer) {
const metadata = await this.storage.get(member);
// Do not add the customer if they are already linked
if (metadata.some(data => data.customer_id === customer.id)) {
return;
}
return this.storage.set(member, metadata.concat({
customer_id: customer.id
}));