mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-04 04:59:40 +00:00
add console.log statements for debugging
This commit is contained in:
parent
207e3476e6
commit
f3fab88f0b
1 changed files with 12 additions and 0 deletions
|
|
@ -287,9 +287,11 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||
if (stripeInc) stripeApi = stripeInc;
|
||||
|
||||
const eventJSON = JSON.parse(requestBody);
|
||||
console.log(eventJSON);
|
||||
|
||||
// Verify the event by fetching it from Stripe
|
||||
const event = await stripeApi.events.retrieve(eventJSON.id);
|
||||
console.log(event);
|
||||
|
||||
switch (event.type) {
|
||||
case 'customer.subscription.deleted': {
|
||||
|
|
@ -305,6 +307,7 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||
let groupId;
|
||||
|
||||
if (isGroupSub) {
|
||||
console.log('is group sub');
|
||||
let groupFields = basicGroupFields.concat(' purchased');
|
||||
let group = await Group.findOne({
|
||||
'purchased.plan.customerId': customerId,
|
||||
|
|
@ -316,6 +319,7 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||
|
||||
user = await User.findById(group.leader).exec();
|
||||
} else {
|
||||
console.log('is not group sub');
|
||||
user = await User.findOne({
|
||||
'purchased.plan.customerId': customerId,
|
||||
paymentMethod: this.constants.PAYMENT_METHOD,
|
||||
|
|
@ -324,13 +328,21 @@ api.handleWebhooks = async function handleWebhooks (options, stripeInc) {
|
|||
|
||||
if (!user) throw new NotFound(i18n.t('groupNotFound'));
|
||||
|
||||
console.log('groupId', groupId);
|
||||
console.log('userId', user._id);
|
||||
|
||||
await stripeApi.customers.del(customerId);
|
||||
|
||||
console.log('deleted stripe customer');
|
||||
|
||||
await payments.cancelSubscription({
|
||||
user,
|
||||
groupId,
|
||||
paymentMethod: this.constants.PAYMENT_METHOD,
|
||||
});
|
||||
|
||||
console.log('cancelled subscription');
|
||||
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue