AW-82-singlePaymentProductsBugDev

This commit is contained in:
Денис Катаев 2024-05-27 20:43:52 +00:00 committed by Daniil Chemerkin
parent b3707593c6
commit 44afa048a8
9 changed files with 27 additions and 19 deletions

View File

@ -32,10 +32,18 @@ export interface PayloadPost extends Payload {
} }
export interface ResponseGet { export interface ResponseGet {
key: string; _id: string,
productId: string; key: string,
amount: number; name: string,
currency: string; type: string,
description: string,
discountPrice: null | unknown,
isDiscount: boolean,
isFreeTrial: boolean,
isTrial: boolean,
price: number,
trialDuration: number,
trialPrice: number
} }
interface ResponsePostNewPaymentData { interface ResponsePostNewPaymentData {

View File

@ -47,9 +47,9 @@ function AddConsultationPage() {
const handleClick = async () => { const handleClick = async () => {
if (!userFromStore || !currentProduct) return; if (!userFromStore || !currentProduct) return;
setIsLoading(true); setIsLoading(true);
const { productId, key } = currentProduct; const { _id, key } = currentProduct;
const paymentInfo = { const paymentInfo = {
productId, productId: _id,
key, key,
}; };
const paymentIntent = await createSinglePayment( const paymentIntent = await createSinglePayment(
@ -86,7 +86,7 @@ function AddConsultationPage() {
onClose={() => setPaymentIntent(null)} onClose={() => setPaymentIntent(null)}
> >
<Title variant="h1" className={styles["modal-title"]}> <Title variant="h1" className={styles["modal-title"]}>
{getPriceCentsToDollars(currentProduct?.amount || 0)}$ {getPriceCentsToDollars(currentProduct?.price || 0)}$
</Title> </Title>
<PaymentForm <PaymentForm
stripePublicKey={paymentIntent.paymentIntent.data.public_key} stripePublicKey={paymentIntent.paymentIntent.data.public_key}

View File

@ -52,9 +52,9 @@ function AddReportPage() {
const currentProduct = getCurrentProduct(activeOffer?.productKey); const currentProduct = getCurrentProduct(activeOffer?.productKey);
if (!currentProduct) return; if (!currentProduct) return;
setIsLoading(true); setIsLoading(true);
const { productId, key } = currentProduct; const { _id, key } = currentProduct;
const paymentInfo = { const paymentInfo = {
productId, productId: _id,
key, key,
}; };
const paymentIntent = await createSinglePayment( const paymentIntent = await createSinglePayment(

View File

@ -62,9 +62,9 @@ function UnlimitedReadingsPage() {
const handleClick = async () => { const handleClick = async () => {
if (!userFromStore || !currentProduct) return; if (!userFromStore || !currentProduct) return;
setIsLoading(true); setIsLoading(true);
const { productId, key } = currentProduct; const { _id, key } = currentProduct;
const paymentInfo = { const paymentInfo = {
productId, productId: _id,
key, key,
}; };
const paymentIntent = await createSinglePayment( const paymentIntent = await createSinglePayment(
@ -102,7 +102,7 @@ function UnlimitedReadingsPage() {
onClose={() => setPaymentIntent(null)} onClose={() => setPaymentIntent(null)}
> >
<Title variant="h1" className={styles["modal-title"]}> <Title variant="h1" className={styles["modal-title"]}>
{getPriceCentsToDollars(currentProduct?.amount || 0)}$ {getPriceCentsToDollars(currentProduct?.price || 0)}$
</Title> </Title>
<PaymentForm <PaymentForm
stripePublicKey={paymentIntent.paymentIntent.data.public_key} stripePublicKey={paymentIntent.paymentIntent.data.public_key}

View File

@ -179,7 +179,7 @@ function PaymentWithEmailPage() {
!!tokenFromStore.length && ( !!tokenFromStore.length && (
<> <>
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>
{getPriceCentsToDollars(product?.amount || 0)}$ {getPriceCentsToDollars(product?.price || 0)}$
</Title> </Title>
<PaymentForm <PaymentForm
stripePublicKey={paymentIntent.paymentIntent.data.public_key} stripePublicKey={paymentIntent.paymentIntent.data.public_key}

View File

@ -59,7 +59,7 @@ function SinglePaymentPage({ productId, isForce = false }: ISinglePaymentPage) {
!!tokenFromStore.length && ( !!tokenFromStore.length && (
<> <>
<Title variant="h1" className={styles.title}> <Title variant="h1" className={styles.title}>
{getPriceCentsToDollars(product?.amount || 0)}$ {getPriceCentsToDollars(product?.price || 0)}$
</Title> </Title>
<PaymentForm <PaymentForm
stripePublicKey={paymentIntent.paymentIntent.data.public_key} stripePublicKey={paymentIntent.paymentIntent.data.public_key}

View File

@ -72,9 +72,9 @@ export default function DiscountScreen() {
const buy = async () => { const buy = async () => {
if (!user?.id || !product) return; if (!user?.id || !product) return;
const { productId, key } = product; const { _id, key } = product;
const paymentInfo = { const paymentInfo = {
productId, productId: _id,
key, key,
}; };

View File

@ -52,7 +52,7 @@ export default function PremiumBundleScreen() {
const buy = async () => { const buy = async () => {
if (!user?.id || !product) return; if (!user?.id || !product) return;
const { productId, key } = product; const { _id, key } = product;
const response = await api.createSinglePayment({ const response = await api.createSinglePayment({
token: token, token: token,
@ -69,7 +69,7 @@ export default function PremiumBundleScreen() {
age: 0, age: 0,
}, },
paymentInfo: { paymentInfo: {
productId, productId: _id,
key, key,
}, },
return_url: returnUrl, return_url: returnUrl,

View File

@ -130,7 +130,7 @@ export const useSinglePayment = () => {
age: null, age: null,
}, },
paymentInfo: { paymentInfo: {
productId: product?.productId || "", productId: product?._id || "",
key: product?.key || "", key: product?.key || "",
}, },
return_url: returnUrl, return_url: returnUrl,