mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
fix linting
This commit is contained in:
@@ -91,13 +91,7 @@ api.handleWebhooks = {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/stripe/webhooks',
|
url: '/stripe/webhooks',
|
||||||
async handler (req, res) {
|
async handler (req, res) {
|
||||||
console.log('start handling webhook');
|
await stripePayments.handleWebhooks({requestBody: req.body});
|
||||||
|
|
||||||
try {
|
|
||||||
await stripePayments.handleWebhooks({requestBody: req.body});
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.respond(200, {});
|
return res.respond(200, {});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -288,7 +288,6 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||||||
|
|
||||||
// Verify the event by fetching it from Stripe
|
// Verify the event by fetching it from Stripe
|
||||||
const event = await stripeApi.events.retrieve(requestBody.id);
|
const event = await stripeApi.events.retrieve(requestBody.id);
|
||||||
console.log(event);
|
|
||||||
|
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case 'customer.subscription.deleted': {
|
case 'customer.subscription.deleted': {
|
||||||
@@ -304,7 +303,6 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||||||
let groupId;
|
let groupId;
|
||||||
|
|
||||||
if (isGroupSub) {
|
if (isGroupSub) {
|
||||||
console.log('is group sub');
|
|
||||||
let groupFields = basicGroupFields.concat(' purchased');
|
let groupFields = basicGroupFields.concat(' purchased');
|
||||||
let group = await Group.findOne({
|
let group = await Group.findOne({
|
||||||
'purchased.plan.customerId': customerId,
|
'purchased.plan.customerId': customerId,
|
||||||
@@ -316,7 +314,6 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||||||
|
|
||||||
user = await User.findById(group.leader).exec();
|
user = await User.findById(group.leader).exec();
|
||||||
} else {
|
} else {
|
||||||
console.log('is not group sub');
|
|
||||||
user = await User.findOne({
|
user = await User.findOne({
|
||||||
'purchased.plan.customerId': customerId,
|
'purchased.plan.customerId': customerId,
|
||||||
'purchased.plan.paymentMethod': this.constants.PAYMENT_METHOD,
|
'purchased.plan.paymentMethod': this.constants.PAYMENT_METHOD,
|
||||||
@@ -325,21 +322,14 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||||||
|
|
||||||
if (!user) throw new NotFound(i18n.t('userNotFound'));
|
if (!user) throw new NotFound(i18n.t('userNotFound'));
|
||||||
|
|
||||||
console.log('groupId', groupId);
|
|
||||||
console.log('userId', user._id);
|
|
||||||
|
|
||||||
await stripeApi.customers.del(customerId);
|
await stripeApi.customers.del(customerId);
|
||||||
|
|
||||||
console.log('deleted stripe customer');
|
|
||||||
|
|
||||||
await payments.cancelSubscription({
|
await payments.cancelSubscription({
|
||||||
user,
|
user,
|
||||||
groupId,
|
groupId,
|
||||||
paymentMethod: this.constants.PAYMENT_METHOD,
|
paymentMethod: this.constants.PAYMENT_METHOD,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('cancelled subscription');
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
Reference in New Issue
Block a user