Skip to content

Commit

Permalink
fix(subs): gifts DON't renew
Browse files Browse the repository at this point in the history
  • Loading branch information
SabreCat committed Oct 17, 2024
1 parent 1946930 commit b90b0bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions test/api/unit/libs/payments/stripe/subscriptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ describe('Stripe - Subscriptions', () => {
paymentMethod: 'Stripe',
sub: sinon.match({ ...sub }),
groupId: null,
autoRenews: true,
});
});

Expand All @@ -197,6 +198,7 @@ describe('Stripe - Subscriptions', () => {
paymentMethod: 'Stripe',
sub: sinon.match({ ...sub }),
groupId,
autoRenews: true,
});
});

Expand Down Expand Up @@ -231,6 +233,7 @@ describe('Stripe - Subscriptions', () => {
paymentMethod: 'Stripe',
sub: sinon.match({ ...sub }),
groupId,
autoRenews: true,
});
});
});
Expand Down
9 changes: 7 additions & 2 deletions website/server/libs/payments/stripe/subscriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ export async function checkSubData (sub, isGroup = false, coupon) {

export async function applySubscription (session) {
const { metadata, customer: customerId, subscription: subscriptionId } = session;
const { sub: subStringified, userId, groupId, gift } = metadata;
const {
sub: subStringified,
userId,
groupId,
gift,
} = metadata;

const sub = subStringified ? JSON.parse(subStringified) : undefined;

Expand All @@ -49,7 +54,7 @@ export async function applySubscription (session) {
sub,
groupId,
subscriptionId,
autoRenews: Boolean(gift),
autoRenews: gift ? false : true,

Check failure on line 57 in website/server/libs/payments/stripe/subscriptions.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

Unnecessary use of boolean literals in conditional expression

Check failure on line 57 in website/server/libs/payments/stripe/subscriptions.js

View workflow job for this annotation

GitHub Actions / lint (21.x)

Unnecessary use of boolean literals in conditional expression
});
}

Expand Down

0 comments on commit b90b0bb

Please sign in to comment.