From 44afa048a844f182b08e2129dbc573cf22a7149a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B5=D0=BD=D0=B8=D1=81=20=D0=9A=D0=B0=D1=82=D0=B0?= =?UTF-8?q?=D0=B5=D0=B2?= Date: Mon, 27 May 2024 20:43:52 +0000 Subject: [PATCH] AW-82-singlePaymentProductsBugDev --- src/api/resources/SinglePayment.ts | 16 ++++++++++++---- .../pages/AddConsultation/index.tsx | 6 +++--- .../pages/AddReport/index.tsx | 4 ++-- .../pages/UnlimitedReadings/index.tsx | 6 +++--- .../pages/PaymentWithEmailPage/index.tsx | 2 +- src/components/pages/SinglePaymentPage/index.tsx | 2 +- .../discount-screen/discount-screen.tsx | 4 ++-- .../premium-bundle-screen.tsx | 4 ++-- src/hooks/payment/useSinglePayment.ts | 2 +- 9 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/api/resources/SinglePayment.ts b/src/api/resources/SinglePayment.ts index f99a6ff..a0cc4ea 100644 --- a/src/api/resources/SinglePayment.ts +++ b/src/api/resources/SinglePayment.ts @@ -32,10 +32,18 @@ export interface PayloadPost extends Payload { } export interface ResponseGet { - key: string; - productId: string; - amount: number; - currency: string; + _id: string, + key: string, + name: string, + type: string, + description: string, + discountPrice: null | unknown, + isDiscount: boolean, + isFreeTrial: boolean, + isTrial: boolean, + price: number, + trialDuration: number, + trialPrice: number } interface ResponsePostNewPaymentData { diff --git a/src/components/pages/AdditionalPurchases/pages/AddConsultation/index.tsx b/src/components/pages/AdditionalPurchases/pages/AddConsultation/index.tsx index b194f3e..68a3fe4 100644 --- a/src/components/pages/AdditionalPurchases/pages/AddConsultation/index.tsx +++ b/src/components/pages/AdditionalPurchases/pages/AddConsultation/index.tsx @@ -47,9 +47,9 @@ function AddConsultationPage() { const handleClick = async () => { if (!userFromStore || !currentProduct) return; setIsLoading(true); - const { productId, key } = currentProduct; + const { _id, key } = currentProduct; const paymentInfo = { - productId, + productId: _id, key, }; const paymentIntent = await createSinglePayment( @@ -86,7 +86,7 @@ function AddConsultationPage() { onClose={() => setPaymentIntent(null)} > - {getPriceCentsToDollars(currentProduct?.amount || 0)}$ + {getPriceCentsToDollars(currentProduct?.price || 0)}$ { if (!userFromStore || !currentProduct) return; setIsLoading(true); - const { productId, key } = currentProduct; + const { _id, key } = currentProduct; const paymentInfo = { - productId, + productId: _id, key, }; const paymentIntent = await createSinglePayment( @@ -102,7 +102,7 @@ function UnlimitedReadingsPage() { onClose={() => setPaymentIntent(null)} > - {getPriceCentsToDollars(currentProduct?.amount || 0)}$ + {getPriceCentsToDollars(currentProduct?.price || 0)}$ - {getPriceCentsToDollars(product?.amount || 0)}$ + {getPriceCentsToDollars(product?.price || 0)}$ - {getPriceCentsToDollars(product?.amount || 0)}$ + {getPriceCentsToDollars(product?.price || 0)}$ { if (!user?.id || !product) return; - const { productId, key } = product; + const { _id, key } = product; const paymentInfo = { - productId, + productId: _id, key, }; diff --git a/src/components/palmistry/premium-bundle-screen/premium-bundle-screen.tsx b/src/components/palmistry/premium-bundle-screen/premium-bundle-screen.tsx index 0d34d81..49589c3 100644 --- a/src/components/palmistry/premium-bundle-screen/premium-bundle-screen.tsx +++ b/src/components/palmistry/premium-bundle-screen/premium-bundle-screen.tsx @@ -52,7 +52,7 @@ export default function PremiumBundleScreen() { const buy = async () => { if (!user?.id || !product) return; - const { productId, key } = product; + const { _id, key } = product; const response = await api.createSinglePayment({ token: token, @@ -69,7 +69,7 @@ export default function PremiumBundleScreen() { age: 0, }, paymentInfo: { - productId, + productId: _id, key, }, return_url: returnUrl, diff --git a/src/hooks/payment/useSinglePayment.ts b/src/hooks/payment/useSinglePayment.ts index df40126..83a3807 100644 --- a/src/hooks/payment/useSinglePayment.ts +++ b/src/hooks/payment/useSinglePayment.ts @@ -130,7 +130,7 @@ export const useSinglePayment = () => { age: null, }, paymentInfo: { - productId: product?.productId || "", + productId: product?._id || "", key: product?.key || "", }, return_url: returnUrl,