0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-03-18 02:21:47 -05:00

Added interval, currency and last4 to stripe data

no-issue

This is attached to each "stripe item" belonging to a member
This commit is contained in:
Fabien O'Carroll 2019-10-02 18:10:19 +07:00
parent 3861bf253c
commit af25cfb619

View file

@ -127,7 +127,9 @@ module.exports = class StripePaymentProcessor {
const customers = await Promise.all(metadata.map(async (data) => {
try {
const customer = await this.getCustomer(data.customer_id);
const customer = await this.getCustomer(data.customer_id, {
expand: ['subscriptions.data.default_payment_method']
});
return customer;
} catch (err) {
debug(`Ignoring Error getting customer for active subscriptions ${err.message}`);
@ -149,13 +151,17 @@ module.exports = class StripePaymentProcessor {
return subscriptions;
}
const payment = subscription.default_payment_method;
return subscriptions.concat([{
customer: customer.id,
status: subscription.status,
subscription: subscription.id,
plan: subscription.plan.id,
name: subscription.plan.nickname,
interval: subscription.plan.interval,
amount: subscription.plan.amount,
currency: subscription.plan.currency,
last4: payment && payment.card && payment.card.last4 || null,
validUntil: subscription.current_period_end
}]);
}, []));
@ -206,7 +212,7 @@ module.exports = class StripePaymentProcessor {
return customer;
}
async getCustomer(id) {
return retrieve(this._stripe, 'customers', id);
async getCustomer(id, options) {
return retrieve(this._stripe, 'customers', id, options);
}
};