0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-25 02:31:59 -05:00

Passed in metadata getter/setter to stripe

no-issue

This will be used to store information such as customer id
This commit is contained in:
Fabien O'Carroll 2019-09-25 10:15:31 +07:00
parent 644fd71d4f
commit 9beb496bd1
2 changed files with 13 additions and 2 deletions

View file

@ -20,6 +20,8 @@ module.exports = function MembersApi({
mail: {
transporter
},
setMemberMetadata,
getMemberMetadata,
createMember,
getMember,
updateMember,
@ -28,7 +30,15 @@ module.exports = function MembersApi({
}) {
const {encodeIdentityToken, decodeToken} = Tokens({privateKey, publicKey, issuer});
const stripe = paymentConfig.stripe ? new StripePaymentProcessor(paymentConfig.stripe) : null;
const stripeStorage = {
async get(member) {
return getMemberMetadata(member, 'stripe');
},
async set(member, metadata) {
return setMemberMetadata(member, 'stripe', metadata);
}
};
const stripe = paymentConfig.stripe ? new StripePaymentProcessor(paymentConfig.stripe, stripeStorage) : null;
async function ensureStripe(_req, res, next) {
if (!stripe) {

View file

@ -2,7 +2,8 @@ const {retrieve, create} = require('./api/stripeRequests');
const api = require('./api');
module.exports = class StripePaymentProcessor {
constructor(config) {
constructor(config, storage) {
this.storage = storage;
this._ready = new Promise((resolve, reject) => {
this._resolveReady = resolve;
this._rejectReady = reject;