mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 07:37:25 +01:00
add some logging
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
import { model as User } from '../../../../../website/server/models/user';
|
||||
import iapLibrary from 'in-app-purchase';
|
||||
import iap from '../../../../../website/server/libs/api-v3/inAppPurchases';
|
||||
|
||||
describe('In App Purchases', () => {
|
||||
let user;
|
||||
let setupSpy;
|
||||
let validateSpy;
|
||||
|
||||
beforeEach(() => {
|
||||
user = new User();
|
||||
setupSpy = sinon.spy();
|
||||
validateSpy = sinon.spy();
|
||||
|
||||
sandbox.stub(iapLibrary, 'setup').yields();
|
||||
sandbox.stub(iapLibrary, 'validate').yields();
|
||||
sandbox.stub(iapLibrary, 'isValidated').returns();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
describe('Android', () => {
|
||||
it('applies new valid receipt', async () => {
|
||||
iapLibrary.setup.yields(undefined, setupSpy);
|
||||
|
||||
await iap.iapAndroidVerify(user, {
|
||||
receipt: {token: 1},
|
||||
});
|
||||
|
||||
expect(setupSpy).to.have.been.called;
|
||||
expect(validateSpy).to.have.been.called;
|
||||
});
|
||||
|
||||
it('example with stub yielding an error', async () => {
|
||||
iapLibrary.setup.yields(new Error('an error'));
|
||||
|
||||
await iap.iapAndroidVerify(user, {
|
||||
receipt: {token: 1},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,8 @@ import logger from '../../../libs/api-v3/logger';
|
||||
|
||||
let api = {};
|
||||
|
||||
// TODO missing tests
|
||||
|
||||
/**
|
||||
* @apiIgnore Payments are considered part of the private API
|
||||
* @api {post} /iap/android/verify Android Verify IAP
|
||||
@@ -81,7 +83,6 @@ api.iapiOSVerify = {
|
||||
let iapBody = req.body;
|
||||
|
||||
let appleRes;
|
||||
let token;
|
||||
|
||||
try {
|
||||
await iap.setup();
|
||||
@@ -96,8 +97,10 @@ api.iapiOSVerify = {
|
||||
let correctReceipt = true;
|
||||
|
||||
// Purchasing one item at a time (processing of await(s) below is sequential not parallel)
|
||||
for (let purchaseData of purchaseDataList) {
|
||||
token = purchaseData.transactionId;
|
||||
for (let index in purchaseDataList) {
|
||||
let purchaseData = purchaseDataList[index];
|
||||
console.log('purchaseData', purchaseData, index);
|
||||
let token = purchaseData.transactionId;
|
||||
|
||||
let existingReceipt = await IapPurchaseReceipt.findOne({ // eslint-disable-line babel/no-await-in-loop
|
||||
_id: token,
|
||||
|
||||
Reference in New Issue
Block a user