mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
breaking changes promisifying amazon payments
This commit is contained in:
@@ -92,7 +92,7 @@ describe('amazonPayments', () => {
|
||||
});
|
||||
|
||||
describe.only('#executePayment', () => {
|
||||
it('succeeds', () => {
|
||||
it('succeeds not as a gift', () => {
|
||||
});
|
||||
|
||||
it('succeeds as a gift', () => {
|
||||
|
||||
11
test/api/v3/unit/libs/paymentsIndex.test.js
Normal file
11
test/api/v3/unit/libs/paymentsIndex.test.js
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
describe('payments/index', () => {
|
||||
beforeEach(() => {
|
||||
});
|
||||
|
||||
describe('#createSubscription', async () => {
|
||||
});
|
||||
|
||||
describe('#buyGems', async () => {
|
||||
});
|
||||
});
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
} from '../../../libs/api-v3/errors';
|
||||
import amzLib from '../../../libs/api-v3/amazonPayments';
|
||||
import { authWithHeaders } from '../../../middlewares/api-v3/auth';
|
||||
var payments = require('./index');
|
||||
|
||||
let api = {};
|
||||
|
||||
@@ -130,31 +131,22 @@ api.checkout = {
|
||||
|
||||
await amzLib.closeOrderReference({ AmazonOrderReferenceId: orderReferenceId });
|
||||
|
||||
// execute payment
|
||||
let giftUser = await User.findById(gift ? gift.uuid : undefined);
|
||||
let data = { giftUser, paymentMethod: 'Amazon Payments' };
|
||||
let method = 'buyGems';
|
||||
if (gift) {
|
||||
if (gift.type === 'subscription') method = 'createSubscription';
|
||||
gift.member = giftUser;
|
||||
data.gift = gift;
|
||||
data.paymentMethod = 'Gift';
|
||||
}
|
||||
await payments[method](data);
|
||||
|
||||
res.respond(200);
|
||||
} catch(error) {
|
||||
throw new BadRequest(error);
|
||||
}
|
||||
|
||||
/*
|
||||
executePayment (cb) {
|
||||
async.waterfall([
|
||||
function findUser (cb2) {
|
||||
User.findById(gift ? gift.uuid : undefined, cb2);
|
||||
},
|
||||
function executeAmazonPayment (member, cb2) {
|
||||
let data = {user, paymentMethod: 'Amazon Payments'};
|
||||
let method = 'buyGems';
|
||||
|
||||
if (gift) {
|
||||
if (gift.type === 'subscription') method = 'createSubscription';
|
||||
gift.member = member;
|
||||
data.gift = gift;
|
||||
data.paymentMethod = 'Gift';
|
||||
}
|
||||
|
||||
payments[method](data, cb2);
|
||||
}, */
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ function revealMysteryItems (user) {
|
||||
});
|
||||
}
|
||||
|
||||
// @TODO: HEREHERE
|
||||
api.createSubscription = async function createSubscription (data) {
|
||||
}
|
||||
api.createSubscription = function createSubscription (data, cb) {
|
||||
let recipient = data.gift ? data.gift.member : data.user;
|
||||
let plan = recipient.purchased.plan;
|
||||
@@ -150,6 +153,9 @@ api.cancelSubscription = function cancelSubscription (data, cb) {
|
||||
analytics.track('unsubscribe', analyticsData);
|
||||
};
|
||||
|
||||
// @TODO: HEREHERE
|
||||
api.buyGems = async function buyGems (data) {
|
||||
};
|
||||
api.buyGems = function buyGems (data, cb) {
|
||||
let amt = data.amount || 5;
|
||||
amt = data.gift ? data.gift.gems.amount / 4 : amt;
|
||||
@@ -229,5 +235,4 @@ api.amazonSubscribeCancel = amazon.subscribeCancel;
|
||||
api.iapAndroidVerify = iap.androidVerify;
|
||||
api.iapIosVerify = iap.iosVerify;
|
||||
|
||||
// module.exports = api;
|
||||
module.exports = {}; // @TODO HEREHERE
|
||||
module.exports = api;
|
||||
|
||||
Reference in New Issue
Block a user