diff --git a/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx b/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx index e7707141..e41d1e70 100644 --- a/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx +++ b/src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx @@ -74,12 +74,15 @@ export const useBrazilPayment = ({ closePopup() } } - useEffect(() => { if (open) { (async () => { try { - const json: ResponsePaymentArray = await getBrazilPaymentUrl({ item: originalObject, product_name: `${pack} ${teams}` }) + const json: ResponsePaymentArray = await getBrazilPaymentUrl({ + action: pass === 'pass_match_access' ? 'one_payment' : 'create_subscription', + item: originalObject, + product_name: `${pack} ${teams}`, + }) setSrc(json?.url || '') } catch (err) { setError('error_payment_unsuccessful') diff --git a/src/requests/getBrazilPaymentUrl.tsx b/src/requests/getBrazilPaymentUrl.tsx index 0b937c6c..88c5699c 100644 --- a/src/requests/getBrazilPaymentUrl.tsx +++ b/src/requests/getBrazilPaymentUrl.tsx @@ -5,14 +5,19 @@ import { callApi } from 'helpers' import type { SubscriptionResponse } from 'requests/getSubscriptions' type Props = { + action: 'one_payment' | 'create_subscription', item: SubscriptionResponse, product_name: string, } -export const getBrazilPaymentUrl = async ({ item, product_name }: Props) => { +export const getBrazilPaymentUrl = async ({ + action, + item, + product_name, +}: Props) => { const config = { body: { - action: 'create_subscription', + action, data: { item: { ...item, product_name }, url_return: `${window.location.origin}${PAGES.thanksForSubscribe}`,