mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
Fixed stripe migration to avoid complimentary prices as monthly/yearly price
closes https://github.com/TryGhost/Team/issues/778 - cleans up the stripe migration to add default monthly/yearly prices for sites, which had a possibility of using complimentary (0 amount prices) in edge cases - adds missing return in the same migration for an unlikely failure to parse stripe plans
This commit is contained in:
parent
ceec3efe6a
commit
069accdbe8
@ -262,6 +262,7 @@ module.exports = class StripeMigrations {
|
|||||||
plans = JSON.parse(stripePlans.get('value'));
|
plans = JSON.parse(stripePlans.get('value'));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this._logging.warn('Skipping population of members_monthly_price_id, could not parse stripe_plans');
|
this._logging.warn('Skipping population of members_monthly_price_id, could not parse stripe_plans');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const monthlyPlan = plans.find((plan) => {
|
const monthlyPlan = plans.find((plan) => {
|
||||||
@ -284,10 +285,8 @@ module.exports = class StripeMigrations {
|
|||||||
|
|
||||||
if (!monthlyPrice) {
|
if (!monthlyPrice) {
|
||||||
this._logging.info('Could not find active Monthly price from stripe_plans - searching by interval');
|
this._logging.info('Could not find active Monthly price from stripe_plans - searching by interval');
|
||||||
monthlyPrice = await this._StripePrice.findOne({
|
monthlyPrice = await this._StripePrice.where('amount', '>', 0)
|
||||||
interval: 'month',
|
.where({interval: 'month', active: true}).fetch();
|
||||||
active: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!monthlyPrice) {
|
if (!monthlyPrice) {
|
||||||
@ -357,10 +356,8 @@ module.exports = class StripeMigrations {
|
|||||||
|
|
||||||
if (!yearlyPrice) {
|
if (!yearlyPrice) {
|
||||||
this._logging.info('Could not find active yearly price from stripe_plans - searching by interval');
|
this._logging.info('Could not find active yearly price from stripe_plans - searching by interval');
|
||||||
yearlyPrice = await this._StripePrice.findOne({
|
yearlyPrice = await this._StripePrice.where('amount', '>', 0)
|
||||||
interval: 'year',
|
.where({interval: 'year', active: true}).fetch();
|
||||||
active: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!yearlyPrice) {
|
if (!yearlyPrice) {
|
||||||
|
Loading…
Reference in New Issue
Block a user