mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-03 23:00:14 -05:00
Cleaned up stripe-service package usage
no refs - updates all usages of `stripe-service` package to new correct `members-stripe-service` package
This commit is contained in:
parent
aa0b95528e
commit
fe4fb78830
4 changed files with 42 additions and 42 deletions
|
@ -3,7 +3,7 @@ const body = require('body-parser');
|
|||
const MagicLink = require('@tryghost/magic-link');
|
||||
const common = require('./common');
|
||||
|
||||
const StripeAPIService = require('@tryghost/stripe-service');
|
||||
const StripeAPIService = require('@tryghost/members-stripe-service');
|
||||
const MemberAnalyticsService = require('@tryghost/member-analytics-service');
|
||||
const MembersAnalyticsIngress = require('@tryghost/members-analytics-ingress');
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const errors = require('@tryghost/ignition-errors');
|
|||
* @param {any} deps.StripePrice
|
||||
* @param {boolean} deps.allowSelfSignup
|
||||
* @param {any} deps.magicLinkService
|
||||
* @param {import('@tryghost/stripe-service')} deps.stripeAPIService
|
||||
* @param {import('@tryghost/members-stripe-service')} deps.stripeAPIService
|
||||
* @param {any} deps.tokenService
|
||||
* @param {any} deps.config
|
||||
* @param {any} deps.logging
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"@tryghost/magic-link": "^1.0.12",
|
||||
"@tryghost/member-analytics-service": "^0.1.1",
|
||||
"@tryghost/members-analytics-ingress": "^0.1.2",
|
||||
"@tryghost/stripe-service": "^0.1.0",
|
||||
"@tryghost/members-stripe-service": "^0.1.0",
|
||||
"@tryghost/tpl": "^0.1.2",
|
||||
"@types/jsonwebtoken": "^8.5.1",
|
||||
"bluebird": "^3.5.4",
|
||||
|
|
|
@ -1,45 +1,45 @@
|
|||
// const {describe, it} = require('mocha');
|
||||
// const should = require('should');
|
||||
// const sinon = require('sinon');
|
||||
// const StripeAPIService = require('@tryghost/stripe-service');
|
||||
// const StripeWebhookService = require('../../../../lib/services/stripe-webhook');
|
||||
// const ProductRepository = require('../../../../lib/repositories/product');
|
||||
// const MemberRepository = require('../../../../lib/repositories/member');
|
||||
const {describe, it} = require('mocha');
|
||||
const should = require('should');
|
||||
const sinon = require('sinon');
|
||||
const StripeAPIService = require('@tryghost/members-stripe-service');
|
||||
const StripeWebhookService = require('../../../../lib/services/stripe-webhook');
|
||||
const ProductRepository = require('../../../../lib/repositories/product');
|
||||
const MemberRepository = require('../../../../lib/repositories/member');
|
||||
|
||||
// function mock(Class) {
|
||||
// return sinon.stub(Object.create(Class.prototype));
|
||||
// }
|
||||
function mock(Class) {
|
||||
return sinon.stub(Object.create(Class.prototype));
|
||||
}
|
||||
|
||||
// describe('StripeWebhookService', function () {
|
||||
// describe('invoice.payment_succeeded webhooks', function () {
|
||||
// it('Should throw a 404 error when a member is not found for a valid Ghost Members invoice', async function () {
|
||||
// const stripeWebhookService = new StripeWebhookService({
|
||||
// stripeAPIService: mock(StripeAPIService),
|
||||
// productRepository: mock(ProductRepository),
|
||||
// memberRepository: mock(MemberRepository)
|
||||
// });
|
||||
describe('StripeWebhookService', function () {
|
||||
describe('invoice.payment_succeeded webhooks', function () {
|
||||
it('Should throw a 404 error when a member is not found for a valid Ghost Members invoice', async function () {
|
||||
const stripeWebhookService = new StripeWebhookService({
|
||||
stripeAPIService: mock(StripeAPIService),
|
||||
productRepository: mock(ProductRepository),
|
||||
memberRepository: mock(MemberRepository)
|
||||
});
|
||||
|
||||
// stripeWebhookService._stripeAPIService.getSubscription.resolves({
|
||||
// customer: 'customer_id',
|
||||
// plan: {
|
||||
// product: 'product_id'
|
||||
// }
|
||||
// });
|
||||
stripeWebhookService._stripeAPIService.getSubscription.resolves({
|
||||
customer: 'customer_id',
|
||||
plan: {
|
||||
product: 'product_id'
|
||||
}
|
||||
});
|
||||
|
||||
// stripeWebhookService._memberRepository.get.resolves(null);
|
||||
stripeWebhookService._memberRepository.get.resolves(null);
|
||||
|
||||
// stripeWebhookService._productRepository.get.resolves({
|
||||
// id: 'product_id'
|
||||
// });
|
||||
stripeWebhookService._productRepository.get.resolves({
|
||||
id: 'product_id'
|
||||
});
|
||||
|
||||
// try {
|
||||
// await stripeWebhookService.invoiceEvent({
|
||||
// subscription: 'sub_id'
|
||||
// });
|
||||
// should.fail();
|
||||
// } catch (err) {
|
||||
// should.equal(err.statusCode, 404);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
try {
|
||||
await stripeWebhookService.invoiceEvent({
|
||||
subscription: 'sub_id'
|
||||
});
|
||||
should.fail();
|
||||
} catch (err) {
|
||||
should.equal(err.statusCode, 404);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue