Skip to content

Commit 438f449

Browse files
committed
feat(client): improve iOS subscription management
1 parent 481e3b3 commit 438f449

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

apps/client/src/pages/home/Account/Billing/Billing.vue

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
label="Manage subscription"
2727
color="secondary"
2828
type="submit"
29-
@click="createPortalSession()"
29+
@click="manageSubscription()"
3030
/>
3131

3232
<template v-if="$q.platform.is.capacitor && $q.platform.is.ios">
@@ -91,10 +91,25 @@ onMounted(async () => {
9191
loading.value = false;
9292
});
9393
94+
async function manageSubscription() {
95+
if ($quasar().platform.is.capacitor && $quasar().platform.is.ios) {
96+
await manageIOSSubscription();
97+
} else {
98+
await createPortalSession();
99+
}
100+
}
101+
102+
async function manageIOSSubscription() {
103+
const managementURL = (await Purchases.getCustomerInfo()).customerInfo
104+
.managementURL!;
105+
106+
window.open(managementURL, '_blank');
107+
}
108+
94109
async function createPortalSession() {
95110
const { portalSessionUrl } =
96111
await trpcClient.users.account.stripe.createPortalSession.mutate();
97112
98-
location.href = portalSessionUrl;
113+
window.open(portalSessionUrl, '_blank');
99114
}
100115
</script>

apps/client/src/pages/home/Pricing/Pricing.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,19 @@ async function buyPackage() {
238238
239239
async function manageSubscription() {
240240
if ($quasar().platform.is.capacitor && $quasar().platform.is.ios) {
241-
await buyPackage();
241+
await manageIOSSubscription();
242242
} else {
243243
await createPortalSession();
244244
}
245245
}
246246
247+
async function manageIOSSubscription() {
248+
const managementURL = (await Purchases.getCustomerInfo()).customerInfo
249+
.managementURL!;
250+
251+
window.open(managementURL, '_blank');
252+
}
253+
247254
async function createPortalSession() {
248255
const { portalSessionUrl } =
249256
await trpcClient.users.account.stripe.createPortalSession.mutate();

0 commit comments

Comments
 (0)