mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Paypal refactor lib (#8420)
* Abstracted paypal logic from controller. Added intial tests * Added checkout tests * Added checkout success test * Added subscribe test * Added subscribeSuccess tests * Added subscribeCancel tests * Added ipn tests * Fixed broken test * Added integration tests and fixed linting issues * Added errors for paypal checkout success integration test * Removed extra test * Removed pending status from subscribe cancel test * Added more error checking and tests * Fixed lint issues
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
import {
|
||||
generateUser,
|
||||
} from '../../../../../helpers/api-integration/v3';
|
||||
import paypalPayments from '../../../../../../website/server/libs/paypalPayments';
|
||||
|
||||
describe('payments - paypal - #ipn', () => {
|
||||
let endpoint = '/paypal/ipn';
|
||||
let user;
|
||||
|
||||
beforeEach(async () => {
|
||||
user = await generateUser();
|
||||
});
|
||||
|
||||
it('verifies credentials', async () => {
|
||||
let result = await user.post(endpoint);
|
||||
expect(result).to.eql('OK');
|
||||
});
|
||||
|
||||
describe('success', () => {
|
||||
let ipnStub;
|
||||
|
||||
beforeEach(async () => {
|
||||
ipnStub = sinon.stub(paypalPayments, 'ipn').returnsPromise().resolves({});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
paypalPayments.ipn.restore();
|
||||
});
|
||||
|
||||
it('makes a purchase', async () => {
|
||||
user = await generateUser({
|
||||
'profile.name': 'sender',
|
||||
'purchased.plan.customerId': 'customer-id',
|
||||
'purchased.plan.planId': 'basic_3mo',
|
||||
'purchased.plan.lastBillingDate': new Date(),
|
||||
balance: 2,
|
||||
});
|
||||
|
||||
await user.post(endpoint);
|
||||
|
||||
expect(ipnStub).to.be.calledOnce;
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user