Skip to content

Commit 8a463c6

Browse files
committed
fix(stripe): fixed subscription change bug
1 parent 70db042 commit 8a463c6

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

src/stripe/stripe.service.ts

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,23 @@ export class StripeService {
205205
currentSubscription.externalId,
206206
);
207207

208+
if (currentSubscription.tier === "starter") {
209+
return {
210+
success: true,
211+
message: "Subscription is starter",
212+
data: {
213+
jobstash: null,
214+
extraSeats: null,
215+
veri: null,
216+
stashAlert: null,
217+
stashPool: null,
218+
atsIntegration: null,
219+
jobPromotions: null,
220+
cancellationDate: null,
221+
},
222+
};
223+
}
224+
208225
if (subscription.canceled_at) {
209226
return {
210227
success: true,
@@ -1113,6 +1130,20 @@ export class StripeService {
11131130
return { success: true, message: "No change required" };
11141131
}
11151132

1133+
if (currentTier === "starter") {
1134+
return this.initiateNewSubscription({
1135+
wallet,
1136+
email,
1137+
dto: {
1138+
jobstash: dto.jobstash,
1139+
veri: dto.veri,
1140+
stashAlert: dto.stashAlert,
1141+
extraSeats: dto.extraSeats,
1142+
orgId,
1143+
},
1144+
});
1145+
}
1146+
11161147
const prices = await this.getProductPrices();
11171148
const subscription = (await this.stripe.subscriptions.retrieve(
11181149
externalId,
@@ -1189,25 +1220,11 @@ export class StripeService {
11891220

11901221
const isUpgrade = bundleUpgraded || veriUpgraded || stashAlertActivated;
11911222

1192-
if (currentTier === "starter") {
1193-
return this.initiateNewSubscription({
1194-
wallet,
1195-
email,
1196-
dto: {
1197-
jobstash: dto.jobstash,
1198-
veri: dto.veri,
1199-
stashAlert: dto.stashAlert,
1200-
extraSeats: dto.extraSeats,
1201-
orgId,
1202-
},
1203-
});
1204-
} else {
1205-
await this.stripe.subscriptions.update(externalId, {
1206-
proration_behavior: isUpgrade ? "always_invoice" : "none",
1207-
billing_cycle_anchor: isUpgrade ? "now" : "unchanged",
1208-
items: updateItems,
1209-
});
1210-
}
1223+
await this.stripe.subscriptions.update(externalId, {
1224+
proration_behavior: isUpgrade ? "always_invoice" : "none",
1225+
billing_cycle_anchor: isUpgrade ? "now" : "unchanged",
1226+
items: updateItems,
1227+
});
12111228

12121229
return {
12131230
success: true,

0 commit comments

Comments
 (0)