mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 10:42:45 +03:00
Used OffersAPI over OfferRepository in MembersAPI
no-issue The OfferRepository deals with domain objects in the Offers module, and as such is not suitable for use with "external" services. This update means that MembersAPI can deal with POJO DTOs so that there is not a dependency on the internals of the Offers module. Just on the contract it holds with the outside world.
This commit is contained in:
parent
8ef752a7f7
commit
5172e40646
@ -55,7 +55,7 @@ module.exports = function MembersAPI({
|
||||
Settings
|
||||
},
|
||||
stripeAPIService,
|
||||
offerRepository,
|
||||
offersAPI,
|
||||
logger,
|
||||
labsService
|
||||
}) {
|
||||
@ -153,7 +153,7 @@ module.exports = function MembersAPI({
|
||||
});
|
||||
|
||||
const routerController = new RouterController({
|
||||
offerRepository,
|
||||
offersAPI,
|
||||
productRepository,
|
||||
memberRepository,
|
||||
StripePrice,
|
||||
|
@ -17,7 +17,7 @@ const _ = require('lodash');
|
||||
*/
|
||||
module.exports = class RouterController {
|
||||
constructor({
|
||||
offerRepository,
|
||||
offersAPI,
|
||||
productRepository,
|
||||
memberRepository,
|
||||
StripePrice,
|
||||
@ -30,7 +30,7 @@ module.exports = class RouterController {
|
||||
config,
|
||||
logging
|
||||
}) {
|
||||
this._offerRepository = offerRepository;
|
||||
this._offersAPI = offersAPI;
|
||||
this._productRepository = productRepository;
|
||||
this._memberRepository = memberRepository;
|
||||
this._StripePrice = StripePrice;
|
||||
@ -137,10 +137,10 @@ module.exports = class RouterController {
|
||||
let coupon = null;
|
||||
if (offerId && this.labsService.isSet('offers')) {
|
||||
try {
|
||||
const offer = await this._offerRepository.getById(offerId);
|
||||
const offer = await this._offersAPI.getOffer({id: offerId});
|
||||
const tier = (await this._productRepository.get(offer.tier)).toJSON();
|
||||
|
||||
if (offer.cadence.value === 'month') {
|
||||
if (offer.cadence === 'month') {
|
||||
ghostPriceId = tier.monthly_price_id;
|
||||
} else {
|
||||
ghostPriceId = tier.yearly_price_id;
|
||||
|
Loading…
Reference in New Issue
Block a user