fixed manage billing
This commit is contained in:
parent
380ece7ed3
commit
c593f5c061
@ -43,6 +43,8 @@ export default class Stripe extends BaseAdmin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async getClientPortalSession(stripe_subscription_id: string) {
|
public async getClientPortalSession(stripe_subscription_id: string) {
|
||||||
|
console.log(stripe_subscription_id);
|
||||||
|
|
||||||
const url = new URL(this.baseURl.concat(`/${stripe_subscription_id}`));
|
const url = new URL(this.baseURl.concat(`/${stripe_subscription_id}`));
|
||||||
try {
|
try {
|
||||||
return await this.getRequest<IGetClientPortalSessionResponse>(url);
|
return await this.getRequest<IGetClientPortalSessionResponse>(url);
|
||||||
|
@ -26,7 +26,7 @@ export default class Subscriptions extends BaseAdmin {
|
|||||||
const query = { q };
|
const query = { q };
|
||||||
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
if (q) Object.entries(query).forEach(([key, value]) => url.searchParams.set(key, JSON.stringify(value)));
|
||||||
try {
|
try {
|
||||||
return await this.getRequest<Subscription>(url);
|
return await this.getRequest<Subscription[]>(url);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.onError(err);
|
this.onError(err);
|
||||||
return Promise.reject(err);
|
return Promise.reject(err);
|
||||||
|
@ -32,8 +32,9 @@ export default function SubscriptionFacturation() {
|
|||||||
const manageBilling = async () => {
|
const manageBilling = async () => {
|
||||||
try {
|
try {
|
||||||
const jwt = JwtService.getInstance().decodeJwt();
|
const jwt = JwtService.getInstance().decodeJwt();
|
||||||
const subscription = await Subscriptions.getInstance().get({ officeId: jwt?.office_Id });
|
const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } } });
|
||||||
const stripe_client_portal = await Stripe.getInstance().getClientPortalSession(subscription.stripe_subscription_id!);
|
if (!subscription[0]) return;
|
||||||
|
const stripe_client_portal = await Stripe.getInstance().getClientPortalSession(subscription[0].stripe_subscription_id!);
|
||||||
router.push(stripe_client_portal.url);
|
router.push(stripe_client_portal.url);
|
||||||
} catch (error) {}
|
} catch (error) {}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user