mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added support for un/archiving Prices
https://github.com/TryGhost/Team/issues/665 We update both Stripe and our database based on the `active` flag for existing stripe prices.
This commit is contained in:
parent
1dd2c4f656
commit
f2123d07db
2 changed files with 26 additions and 2 deletions
|
@ -217,13 +217,19 @@ class ProductRepository {
|
|||
interval: existingPrice.interval
|
||||
}, options);
|
||||
} else {
|
||||
await this._StripePrice.edit({
|
||||
const updated = await this._StripePrice.edit({
|
||||
nickname: existingPrice.nickname,
|
||||
description: existingPrice.description
|
||||
description: existingPrice.description,
|
||||
active: existingPrice.active
|
||||
}, {
|
||||
...options,
|
||||
id: stripePrice.id
|
||||
});
|
||||
|
||||
await this._stripeAPIService.updatePrice(updated.get('stripe_price_id'), {
|
||||
nickname: updated.get('nickname'),
|
||||
active: updated.get('active')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,6 +118,24 @@ module.exports = class StripeAPIService {
|
|||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} id
|
||||
* @param {object} options
|
||||
* @param {boolean} options.active
|
||||
* @param {string} options.nickname
|
||||
*
|
||||
* @returns {Promise<IPrice>}
|
||||
*/
|
||||
async updatePrice(id, options) {
|
||||
await this._rateLimitBucket.throttle();
|
||||
const price = await this._stripe.prices.update(id, {
|
||||
active: options.active,
|
||||
nickname: options.nickname
|
||||
});
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
/**
|
||||
* ensureProduct.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue