diff --git a/src/config/routes.tsx b/src/config/routes.tsx index 64820bfc..15a67b41 100644 --- a/src/config/routes.tsx +++ b/src/config/routes.tsx @@ -35,6 +35,12 @@ const ADS_APIS = { staging: 'https://ads-test.insports.tv/v1/ads', } +const PAYMENT_APIS = { + preproduction: 'https://pay.insports.tv', + production: 'https://pay.insports.tv', + staging: 'https://pay.test.insports.tv', +} + const env = isProduction ? ENV : readSelectedApi() ?? ENV export const VIEWS_API = VIEWS_APIS[env] @@ -44,3 +50,4 @@ export const DATA_URL = `${API_ROOT}/data` export const URL_AWS = 'https://cf-aws.insports.tv' export const STATS_API_URL = STATS_APIS[env] export const ADS_API_URL = ADS_APIS[env] +export const PAYMENT_API_URL = PAYMENT_APIS[env] diff --git a/src/helpers/callApi/parseJSON.tsx b/src/helpers/callApi/parseJSON.tsx index 12709130..067ade9e 100644 --- a/src/helpers/callApi/parseJSON.tsx +++ b/src/helpers/callApi/parseJSON.tsx @@ -1 +1,6 @@ -export const parseJSON = (response: Response) => response.json() +export const parseJSON = (response: Response) => { + if (response.status === 204) { + return Promise.resolve() + } + return response.json() +} diff --git a/src/requests/cancelSubscribe.tsx b/src/requests/cancelSubscribe.tsx index 183f0b6e..9f33b9fb 100644 --- a/src/requests/cancelSubscribe.tsx +++ b/src/requests/cancelSubscribe.tsx @@ -1,15 +1,13 @@ -import { API_ROOT } from 'config' +import { PAYMENT_API_URL } from 'config' import { callApi } from 'helpers' export const cancelSubscribe = (id: number): Promise => { const config = { - body: { - id, - }, + method: 'DELETE', } return callApi({ config, - url: `${API_ROOT}/account/subscription/cancel`, + url: `${PAYMENT_API_URL}/api/v2/general/subscription/${id}`, }) }