mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
start upgrading eslint
This commit is contained in:
@@ -10,23 +10,23 @@ import {
|
||||
} from '../../../libs/errors';
|
||||
import apiError from '../../../libs/apiError';
|
||||
|
||||
let api = {};
|
||||
const api = {};
|
||||
|
||||
/**
|
||||
* @apiIgnore Payments are considered part of the private API
|
||||
* @api {get} /paypal/checkout Paypal: checkout
|
||||
* @apiName PaypalCheckout
|
||||
* @apiGroup Payments
|
||||
**/
|
||||
* */
|
||||
api.checkout = {
|
||||
method: 'GET',
|
||||
url: '/paypal/checkout',
|
||||
middlewares: [authWithSession],
|
||||
async handler (req, res) {
|
||||
let gift = req.query.gift ? JSON.parse(req.query.gift) : undefined;
|
||||
const gift = req.query.gift ? JSON.parse(req.query.gift) : undefined;
|
||||
req.session.gift = req.query.gift;
|
||||
|
||||
let link = await paypalPayments.checkout({gift, user: res.locals.user});
|
||||
const link = await paypalPayments.checkout({ gift, user: res.locals.user });
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
res.respond(200);
|
||||
@@ -41,22 +41,24 @@ api.checkout = {
|
||||
* @api {get} /paypal/checkout/success Paypal: checkout success
|
||||
* @apiName PaypalCheckoutSuccess
|
||||
* @apiGroup Payments
|
||||
**/
|
||||
* */
|
||||
api.checkoutSuccess = {
|
||||
method: 'GET',
|
||||
url: '/paypal/checkout/success',
|
||||
middlewares: [authWithSession],
|
||||
async handler (req, res) {
|
||||
let paymentId = req.query.paymentId;
|
||||
let customerId = req.query.PayerID;
|
||||
let user = res.locals.user;
|
||||
let gift = req.session.gift ? JSON.parse(req.session.gift) : undefined;
|
||||
const { paymentId } = req.query;
|
||||
const customerId = req.query.PayerID;
|
||||
const { user } = res.locals;
|
||||
const gift = req.session.gift ? JSON.parse(req.session.gift) : undefined;
|
||||
delete req.session.gift;
|
||||
|
||||
if (!paymentId) throw new BadRequest(apiError('missingPaymentId'));
|
||||
if (!customerId) throw new BadRequest(apiError('missingCustomerId'));
|
||||
|
||||
await paypalPayments.checkoutSuccess({user, gift, paymentId, customerId});
|
||||
await paypalPayments.checkoutSuccess({
|
||||
user, gift, paymentId, customerId,
|
||||
});
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
res.respond(200);
|
||||
@@ -71,7 +73,7 @@ api.checkoutSuccess = {
|
||||
* @api {get} /paypal/subscribe Paypal: subscribe
|
||||
* @apiName PaypalSubscribe
|
||||
* @apiGroup Payments
|
||||
**/
|
||||
* */
|
||||
api.subscribe = {
|
||||
method: 'GET',
|
||||
url: '/paypal/subscribe',
|
||||
@@ -79,10 +81,10 @@ api.subscribe = {
|
||||
async handler (req, res) {
|
||||
if (!req.query.sub) throw new BadRequest(apiError('missingSubKey'));
|
||||
|
||||
let sub = shared.content.subscriptionBlocks[req.query.sub];
|
||||
let coupon = req.query.coupon;
|
||||
const sub = shared.content.subscriptionBlocks[req.query.sub];
|
||||
const { coupon } = req.query;
|
||||
|
||||
let link = await paypalPayments.subscribe({sub, coupon});
|
||||
const link = await paypalPayments.subscribe({ sub, coupon });
|
||||
|
||||
req.session.paypalBlock = req.query.sub;
|
||||
req.session.groupId = req.query.groupId;
|
||||
@@ -100,24 +102,26 @@ api.subscribe = {
|
||||
* @api {get} /paypal/subscribe/success Paypal: subscribe success
|
||||
* @apiName PaypalSubscribeSuccess
|
||||
* @apiGroup Payments
|
||||
**/
|
||||
* */
|
||||
api.subscribeSuccess = {
|
||||
method: 'GET',
|
||||
url: '/paypal/subscribe/success',
|
||||
middlewares: [authWithSession],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
const { user } = res.locals;
|
||||
|
||||
if (!req.session.paypalBlock) throw new BadRequest(apiError('missingPaypalBlock'));
|
||||
|
||||
let block = shared.content.subscriptionBlocks[req.session.paypalBlock];
|
||||
let groupId = req.session.groupId;
|
||||
let token = req.query.token;
|
||||
const block = shared.content.subscriptionBlocks[req.session.paypalBlock];
|
||||
const { groupId } = req.session;
|
||||
const { token } = req.query;
|
||||
|
||||
delete req.session.paypalBlock;
|
||||
delete req.session.groupId;
|
||||
|
||||
await paypalPayments.subscribeSuccess({user, block, groupId, token, headers: req.headers});
|
||||
await paypalPayments.subscribeSuccess({
|
||||
user, block, groupId, token, headers: req.headers,
|
||||
});
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
res.respond(200);
|
||||
@@ -132,16 +136,16 @@ api.subscribeSuccess = {
|
||||
* @api {get} /paypal/subscribe/cancel Paypal: subscribe cancel
|
||||
* @apiName PaypalSubscribeCancel
|
||||
* @apiGroup Payments
|
||||
**/
|
||||
* */
|
||||
api.subscribeCancel = {
|
||||
method: 'GET',
|
||||
url: '/paypal/subscribe/cancel',
|
||||
middlewares: [authWithHeaders()],
|
||||
async handler (req, res) {
|
||||
let user = res.locals.user;
|
||||
let groupId = req.query.groupId;
|
||||
const { user } = res.locals;
|
||||
const { groupId } = req.query;
|
||||
|
||||
await paypalPayments.subscribeCancel({user, groupId});
|
||||
await paypalPayments.subscribeCancel({ user, groupId });
|
||||
|
||||
if (req.query.noRedirect) {
|
||||
res.respond(200);
|
||||
@@ -159,7 +163,7 @@ api.subscribeCancel = {
|
||||
* @api {post} /paypal/ipn Paypal IPN
|
||||
* @apiName PaypalIpn
|
||||
* @apiGroup Payments
|
||||
**/
|
||||
* */
|
||||
api.ipn = {
|
||||
method: 'POST',
|
||||
url: '/paypal/ipn',
|
||||
|
||||
Reference in New Issue
Block a user