fix(#2806): change action for brazil payment

keep-around/b214ac7012ef42593bee62c207888a2593bc5a38
Andrei Dekterev 3 years ago
parent c0f9adc930
commit d115fae7bf
  1. 7
      src/features/BuyMatchPopup/components/BrazilPayment/hooks.tsx
  2. 9
      src/requests/getBrazilPaymentUrl.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')

@ -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}`,

Loading…
Cancel
Save