Paiement success not mocked anymore
This commit is contained in:
parent
82d10c8f9c
commit
c9be69f0ab
@ -14,6 +14,11 @@ export type IGetClientPortalSessionResponse = {
|
||||
url: string;
|
||||
};
|
||||
|
||||
export interface IGetCustomerBySubscriptionIdParams {
|
||||
email: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export default class Stripe extends BaseAdmin {
|
||||
private static instance: Stripe;
|
||||
private readonly baseURl = this.namespaceUrl.concat("/stripe");
|
||||
@ -53,4 +58,14 @@ export default class Stripe extends BaseAdmin {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
|
||||
public async getCustomerBySubscriptionId(subscriptionId: string) {
|
||||
const url = new URL(this.baseURl.concat(`/${subscriptionId}/customer`));
|
||||
try {
|
||||
return await this.getRequest<IGetCustomerBySubscriptionIdParams>(url);
|
||||
} catch (err) {
|
||||
this.onError(err);
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,30 @@
|
||||
import Typography, { ITypo, ITypoColor } from "@Front/Components/DesignSystem/Typography";
|
||||
import classes from "./classes.module.scss";
|
||||
import { IGetCustomerBySubscriptionIdParams } from "@Front/Api/LeCoffreApi/Admin/Stripe/Stripe";
|
||||
|
||||
export default function SubscriptionClientInfos() {
|
||||
type IProps = {
|
||||
customer: IGetCustomerBySubscriptionIdParams;
|
||||
};
|
||||
|
||||
export default function SubscriptionClientInfos(props: IProps) {
|
||||
const { customer } = props;
|
||||
return (
|
||||
<div className={classes["root"]}>
|
||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||
Informations client
|
||||
</Typography>
|
||||
<Typography typo={ITypo.P_18} color={ITypoColor.BLACK}>
|
||||
john.doe@contact.fr
|
||||
{customer.email}
|
||||
</Typography>
|
||||
<Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||
{/* <Typography typo={ITypo.P_SB_18} color={ITypoColor.BLACK}>
|
||||
Adresse de facturation
|
||||
</Typography>
|
||||
</Typography> */}
|
||||
<Typography typo={ITypo.P_18} color={ITypoColor.BLACK}>
|
||||
John Doe <br />
|
||||
23 rue taitbout,
|
||||
{customer.name} <br />
|
||||
{/* 23 rue taitbout,
|
||||
<br />
|
||||
75009 Paris
|
||||
<br />
|
||||
<br /> */}
|
||||
France
|
||||
</Typography>
|
||||
</div>
|
||||
|
@ -12,15 +12,19 @@ import { useCallback, useEffect, useState } from "react";
|
||||
import Subscriptions from "@Front/Api/LeCoffreApi/Admin/Subscriptions/Subscriptions";
|
||||
import JwtService from "@Front/Services/JwtService/JwtService";
|
||||
import { Subscription } from "le-coffre-resources/dist/Admin";
|
||||
import Stripe from "@Front/Api/LeCoffreApi/Admin/Stripe/Stripe";
|
||||
|
||||
export default function SubscriptionSuccess() {
|
||||
const [subscription, setSubscription] = useState<Subscription | null>(null);
|
||||
const [customer, setCustomer] = useState<any | null>(null);
|
||||
|
||||
const loadSubscription = useCallback(async () => {
|
||||
const jwt = JwtService.getInstance().decodeJwt();
|
||||
const subscription = await Subscriptions.getInstance().get({ where: { office: { uid: jwt?.office_Id } } });
|
||||
if (!subscription[0]) return;
|
||||
setSubscription(subscription[0]);
|
||||
const customer = await Stripe.getInstance().getCustomerBySubscriptionId(subscription[0].stripe_subscription_id!);
|
||||
setCustomer(customer);
|
||||
}, []);
|
||||
|
||||
const getFrequency = useCallback(() => {
|
||||
@ -39,7 +43,7 @@ export default function SubscriptionSuccess() {
|
||||
|
||||
return (
|
||||
<DefaultTemplate title="Abonnement réussi">
|
||||
{subscription && (
|
||||
{subscription && customer && (
|
||||
<div className={classes["root"]}>
|
||||
<div className={classes["left"]}>
|
||||
<div className={classes["title"]}>
|
||||
@ -57,7 +61,7 @@ export default function SubscriptionSuccess() {
|
||||
</div>
|
||||
<div className={classes["separator"]} />
|
||||
<div className={classes["client-infos"]}>
|
||||
<SubscriptionClientInfos />
|
||||
<SubscriptionClientInfos customer={customer} />
|
||||
</div>
|
||||
<div className={classes["separator"]} />
|
||||
{subscription.type === "STANDARD" && (
|
||||
|
Loading…
x
Reference in New Issue
Block a user