diff --git a/core/server/services/members/api.js b/core/server/services/members/api.js index 5dd337ee80..a4097683bc 100644 --- a/core/server/services/members/api.js +++ b/core/server/services/members/api.js @@ -27,6 +27,25 @@ function getMember(data, options = {}) { }); } +async function setMemberMetadata(member, module, metadata) { + if (module !== 'stripe') { + return; + } + await models.Member.edit({ + stripe_info: metadata + }, {id: member.id, withRelated: ['stripe_info']}); + return; +} + +async function getMemberMetadata(member, module) { + if (module !== 'stripe') { + return; + } + const model = await models.Member.where({id: member.id}).fetch({withRelated: ['stripe_info']}); + const metadata = await model.related('stripe_info'); + return metadata.toJSON(); +} + function deleteMember(options) { options = options || {}; return models.Member.destroy(options).catch(models.Member.NotFoundError, () => { @@ -121,6 +140,8 @@ function createApiInstance() { paymentConfig: { stripe: getStripePaymentConfig() }, + setMemberMetadata, + getMemberMetadata, createMember, getMember, deleteMember,