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