mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 14:17:22 +01:00
feat(event): 10th Birthday Bash
with @CuriousMagpie and @phillipthelen
This commit is contained in:
@@ -75,12 +75,14 @@ api.checkout = {
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
const { user } = res.locals;
|
||||
const { orderReferenceId, gift, gemsBlock } = req.body;
|
||||
const {
|
||||
orderReferenceId, gift, gemsBlock, sku,
|
||||
} = req.body;
|
||||
|
||||
if (!orderReferenceId) throw new BadRequest('Missing req.body.orderReferenceId');
|
||||
|
||||
await amzLib.checkout({
|
||||
gemsBlock, gift, user, orderReferenceId, headers: req.headers,
|
||||
gemsBlock, gift, sku, user, orderReferenceId, headers: req.headers,
|
||||
});
|
||||
|
||||
res.respond(200);
|
||||
|
||||
@@ -23,7 +23,7 @@ api.iapAndroidVerify = {
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
if (!req.body.transaction) throw new BadRequest(res.t('missingReceipt'));
|
||||
const googleRes = await googlePayments.verifyGemPurchase({
|
||||
const googleRes = await googlePayments.verifyPurchase({
|
||||
user: res.locals.user,
|
||||
receipt: req.body.transaction.receipt,
|
||||
signature: req.body.transaction.signature,
|
||||
@@ -120,7 +120,7 @@ api.iapiOSVerify = {
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
if (!req.body.transaction) throw new BadRequest(res.t('missingReceipt'));
|
||||
const appleRes = await applePayments.verifyGemPurchase({
|
||||
const appleRes = await applePayments.verifyPurchase({
|
||||
user: res.locals.user,
|
||||
receipt: req.body.transaction.receipt,
|
||||
gift: req.body.gift,
|
||||
|
||||
@@ -27,10 +27,13 @@ api.checkout = {
|
||||
const gift = req.query.gift ? JSON.parse(req.query.gift) : undefined;
|
||||
req.session.gift = req.query.gift;
|
||||
|
||||
const { gemsBlock } = req.query;
|
||||
const { gemsBlock, sku } = req.query;
|
||||
req.session.gemsBlock = gemsBlock;
|
||||
req.session.sku = sku;
|
||||
|
||||
const link = await paypalPayments.checkout({ gift, gemsBlock, user: res.locals.user });
|
||||
const link = await paypalPayments.checkout({
|
||||
gift, gemsBlock, sku, user: res.locals.user,
|
||||
});
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
res.respond(200);
|
||||
@@ -56,14 +59,15 @@ api.checkoutSuccess = {
|
||||
const { user } = res.locals;
|
||||
const gift = req.session.gift ? JSON.parse(req.session.gift) : undefined;
|
||||
delete req.session.gift;
|
||||
const { gemsBlock } = req.session;
|
||||
const { gemsBlock, sku } = req.session;
|
||||
delete req.session.gemsBlock;
|
||||
delete req.session.sku;
|
||||
|
||||
if (!paymentId) throw new BadRequest(apiError('missingPaymentId'));
|
||||
if (!customerId) throw new BadRequest(apiError('missingCustomerId'));
|
||||
|
||||
await paypalPayments.checkoutSuccess({
|
||||
user, gemsBlock, gift, paymentId, customerId, headers: req.headers,
|
||||
user, gemsBlock, gift, paymentId, customerId, headers: req.headers, sku,
|
||||
});
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
|
||||
@@ -27,13 +27,13 @@ api.createCheckoutSession = {
|
||||
async handler (req, res) {
|
||||
const { user } = res.locals;
|
||||
const {
|
||||
gift, sub: subKey, gemsBlock, coupon, groupId,
|
||||
gift, sub: subKey, gemsBlock, coupon, groupId, sku,
|
||||
} = req.body;
|
||||
|
||||
const sub = subKey ? shared.content.subscriptionBlocks[subKey] : false;
|
||||
|
||||
const session = await stripePayments.createCheckoutSession({
|
||||
user, gemsBlock, gift, sub, groupId, coupon,
|
||||
user, gemsBlock, gift, sub, groupId, coupon, sku,
|
||||
});
|
||||
|
||||
res.respond(200, {
|
||||
|
||||
Reference in New Issue
Block a user