Created Stripe Coupons when Offers are created

refs https://github.com/TryGhost/Team/issues/1166

We've moved the Stripe Coupon creation out of the Offers module as part
of the work for Stripe disconnect, so we have to make sure that we are
still creating coupons when an Offer is created.
This commit is contained in:
Fabien O'Carroll 2021-10-21 15:34:52 +02:00 committed by Fabien 'egg' O'Carroll
parent ff2da8a417
commit dbf564d137
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,6 @@
const DomainEvents = require('@tryghost/domain-events');
const OfferCreatedEvent = require('@tryghost/members-offers').events.OfferCreatedEvent;
class PaymentsService {
/**
* @param {object} deps
@ -12,6 +15,10 @@ class PaymentsService {
this.offersAPI = deps.offersAPI;
/** @private */
this.stripeAPIService = deps.stripeAPIService;
DomainEvents.subscribe(OfferCreatedEvent, async (event) => {
await this.getCouponForOffer(event.data.offer.id);
});
}
/**

View File

@ -24,5 +24,8 @@
"should": "13.2.3",
"sinon": "11.1.2"
},
"dependencies": {}
"dependencies": {
"@tryghost/domain-events": "^0.1.2",
"@tryghost/members-offers": "^0.7.2"
}
}