@bigbinary/neeto-payments-frontend 4.0.8 → 4.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/javascript/src/translations/en.json +24 -1
- package/dist/AccountsDashboard.js +13 -34
- package/dist/AccountsDashboard.js.map +1 -1
- package/dist/AdminCancelRecurringPaymentButton.js +1 -1
- package/dist/CashPaymentButton.js +2 -2
- package/dist/ConfirmCashPaymentButton.js +2 -2
- package/dist/CustomerCancelRecurringPaymentForm.js +2 -2
- package/dist/{ExportModal-B4zqaXJ1.js → ExportModal-UegCpavy.js} +2 -2
- package/dist/{ExportModal-B4zqaXJ1.js.map → ExportModal-UegCpavy.js.map} +1 -1
- package/dist/ManualUpiConnect.js +2 -2
- package/dist/ManualUpiPayment.js +2 -2
- package/dist/ManualUpiPaymentConfirmButton.js +2 -2
- package/dist/ManualUpiPaymentRejectButton.js +2 -2
- package/dist/PaymentsDashboard.js +3 -3
- package/dist/PayoutsDashboard.js +5 -5
- package/dist/PayoutsPage.js +4 -4
- package/dist/RazorpayPaymentButton.js +2 -2
- package/dist/RecurringPaymentSettings.js +2 -2
- package/dist/RefundsDashboard.js +3 -3
- package/dist/SplitTransfersDashboard.js +3 -3
- package/dist/StripeConnect.js +362 -0
- package/dist/StripeConnect.js.map +1 -0
- package/dist/StripeManage.js +123 -0
- package/dist/StripeManage.js.map +1 -0
- package/dist/TaxesDashboard.js +2 -2
- package/dist/buildStripeTransactionLink.js +1 -1
- package/dist/cjs/AccountsDashboard.js +14 -35
- package/dist/cjs/AccountsDashboard.js.map +1 -1
- package/dist/cjs/AdminCancelRecurringPaymentButton.js +1 -1
- package/dist/cjs/CashPaymentButton.js +2 -2
- package/dist/cjs/ConfirmCashPaymentButton.js +2 -2
- package/dist/cjs/CustomerCancelRecurringPaymentForm.js +2 -2
- package/dist/cjs/{ExportModal-GI2FElh3.js → ExportModal-DxApGBel.js} +2 -2
- package/dist/cjs/{ExportModal-GI2FElh3.js.map → ExportModal-DxApGBel.js.map} +1 -1
- package/dist/cjs/ManualUpiConnect.js +2 -2
- package/dist/cjs/ManualUpiPayment.js +2 -2
- package/dist/cjs/ManualUpiPaymentConfirmButton.js +2 -2
- package/dist/cjs/ManualUpiPaymentRejectButton.js +2 -2
- package/dist/cjs/PaymentsDashboard.js +3 -3
- package/dist/cjs/PayoutsDashboard.js +5 -5
- package/dist/cjs/PayoutsPage.js +4 -4
- package/dist/cjs/RazorpayPaymentButton.js +2 -2
- package/dist/cjs/RecurringPaymentSettings.js +2 -2
- package/dist/cjs/RefundsDashboard.js +3 -3
- package/dist/cjs/SplitTransfersDashboard.js +3 -3
- package/dist/cjs/StripeConnect.js +383 -0
- package/dist/cjs/StripeConnect.js.map +1 -0
- package/dist/cjs/StripeManage.js +125 -0
- package/dist/cjs/StripeManage.js.map +1 -0
- package/dist/cjs/TaxesDashboard.js +2 -2
- package/dist/cjs/buildStripeTransactionLink.js +1 -1
- package/dist/cjs/constants.js +2 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/{dashboard-DDW7FD1Q.js → dashboard-BS8RsSUN.js} +2 -2
- package/dist/cjs/{dashboard-DDW7FD1Q.js.map → dashboard-BS8RsSUN.js.map} +1 -1
- package/dist/cjs/getAmountInSmallestCurrencyUnit.js +1 -1
- package/dist/cjs/getAmountWithAppliedTax.js +1 -1
- package/dist/cjs/getFormattedAmount.js +1 -1
- package/dist/cjs/getFormattedTaxAmount.js +1 -1
- package/dist/cjs/getFormattedTipAmount.js +1 -1
- package/dist/cjs/getQrCodeValue.js +1 -1
- package/dist/cjs/getTaxAmount.js +1 -1
- package/dist/cjs/getTipAmount.js +1 -1
- package/dist/cjs/{index-RKMq21yy.js → index-D0lrwfeJ.js} +3 -1
- package/dist/cjs/{index-RKMq21yy.js.map → index-D0lrwfeJ.js.map} +1 -1
- package/dist/cjs/index.js +20 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/{queryConstants-D2ARfy8-.js → queryConstants-DwAnNVdh.js} +5 -2
- package/dist/cjs/queryConstants-DwAnNVdh.js.map +1 -0
- package/dist/cjs/{renderFunctions-9xNgMpUY.js → renderFunctions-pCev76XN.js} +2 -2
- package/dist/cjs/{renderFunctions-9xNgMpUY.js.map → renderFunctions-pCev76XN.js.map} +1 -1
- package/dist/cjs/useAccountsApi-BZBjuzQ9.js +62 -0
- package/dist/cjs/useAccountsApi-BZBjuzQ9.js.map +1 -0
- package/dist/cjs/useIntegrationsApi-CsGOvw5C.js +26 -0
- package/dist/cjs/useIntegrationsApi-CsGOvw5C.js.map +1 -0
- package/dist/cjs/{usePaymentApi-CMOLq2VR.js → usePaymentApi-CHAcirnx.js} +2 -2
- package/dist/cjs/{usePaymentApi-CMOLq2VR.js.map → usePaymentApi-CHAcirnx.js.map} +1 -1
- package/dist/cjs/{usePaymentApi-D9rbv9km.js → usePaymentApi-DoMBeLfx.js} +2 -2
- package/dist/cjs/{usePaymentApi-D9rbv9km.js.map → usePaymentApi-DoMBeLfx.js.map} +1 -1
- package/dist/cjs/{usePaymentApi-DU3yYSX5.js → usePaymentApi-qdh5LN7u.js} +2 -2
- package/dist/cjs/{usePaymentApi-DU3yYSX5.js.map → usePaymentApi-qdh5LN7u.js.map} +1 -1
- package/dist/cjs/{usePlatformApi-CmetBzFR.js → usePlatformApi-BP0LZThB.js} +3 -3
- package/dist/cjs/{usePlatformApi-CmetBzFR.js.map → usePlatformApi-BP0LZThB.js.map} +1 -1
- package/dist/cjs/useRazorpayPayment.js +2 -2
- package/dist/constants.js +1 -1
- package/dist/{dashboard-W7nZb7Nt.js → dashboard-BmgAk7ZF.js} +2 -2
- package/dist/{dashboard-W7nZb7Nt.js.map → dashboard-BmgAk7ZF.js.map} +1 -1
- package/dist/getAmountInSmallestCurrencyUnit.js +1 -1
- package/dist/getAmountWithAppliedTax.js +1 -1
- package/dist/getFormattedAmount.js +1 -1
- package/dist/getFormattedTaxAmount.js +1 -1
- package/dist/getFormattedTipAmount.js +1 -1
- package/dist/getQrCodeValue.js +1 -1
- package/dist/getTaxAmount.js +1 -1
- package/dist/getTipAmount.js +1 -1
- package/dist/{index-DrwJCsVB.js → index-P40XHLrP.js} +3 -2
- package/dist/{index-DrwJCsVB.js.map → index-P40XHLrP.js.map} +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/{queryConstants-jobxv6K1.js → queryConstants-aYVM1oL2.js} +5 -2
- package/dist/queryConstants-aYVM1oL2.js.map +1 -0
- package/dist/{renderFunctions-CwG8PO6s.js → renderFunctions-ByiZ0trU.js} +2 -2
- package/dist/{renderFunctions-CwG8PO6s.js.map → renderFunctions-ByiZ0trU.js.map} +1 -1
- package/dist/useAccountsApi-CY07Pd2F.js +58 -0
- package/dist/useAccountsApi-CY07Pd2F.js.map +1 -0
- package/dist/useIntegrationsApi-Cm_61Wk1.js +24 -0
- package/dist/useIntegrationsApi-Cm_61Wk1.js.map +1 -0
- package/dist/{usePaymentApi--FTQFayz.js → usePaymentApi-BEsw6xFl.js} +2 -2
- package/dist/{usePaymentApi--FTQFayz.js.map → usePaymentApi-BEsw6xFl.js.map} +1 -1
- package/dist/{usePaymentApi-D57hcC0x.js → usePaymentApi-CnjUFTLo.js} +2 -2
- package/dist/{usePaymentApi-D57hcC0x.js.map → usePaymentApi-CnjUFTLo.js.map} +1 -1
- package/dist/{usePaymentApi-CnXIy7y7.js → usePaymentApi-DTQ8wxiL.js} +2 -2
- package/dist/{usePaymentApi-CnXIy7y7.js.map → usePaymentApi-DTQ8wxiL.js.map} +1 -1
- package/dist/{usePlatformApi-CG6LhSj3.js → usePlatformApi-OKTgTm_o.js} +3 -3
- package/dist/{usePlatformApi-CG6LhSj3.js.map → usePlatformApi-OKTgTm_o.js.map} +1 -1
- package/dist/useRazorpayPayment.js +2 -2
- package/package.json +3 -3
- package/dist/cjs/queryConstants-D2ARfy8-.js.map +0 -1
- package/dist/queryConstants-jobxv6K1.js.map +0 -1
package/dist/PayoutsPage.js
CHANGED
|
@@ -4,11 +4,11 @@ import Spinner from '@bigbinary/neetoui/Spinner';
|
|
|
4
4
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
5
5
|
import { useTranslation } from 'react-i18next';
|
|
6
6
|
import { useParams } from 'react-router-dom/cjs/react-router-dom';
|
|
7
|
-
import { r as renderStatus, a as renderDate } from './renderFunctions-
|
|
8
|
-
import { u as useShowStripePayout, a as useShowStripePlatformPayout } from './usePlatformApi-
|
|
7
|
+
import { r as renderStatus, a as renderDate } from './renderFunctions-ByiZ0trU.js';
|
|
8
|
+
import { u as useShowStripePayout, a as useShowStripePlatformPayout } from './usePlatformApi-OKTgTm_o.js';
|
|
9
9
|
import Button from '@bigbinary/neetoui/Button';
|
|
10
10
|
import { C as CopyButtonWrapper } from './CopyButtonWrapper-B79WRogM.js';
|
|
11
|
-
import { j as buildStripePayoutLink } from './index-
|
|
11
|
+
import { j as buildStripePayoutLink } from './index-P40XHLrP.js';
|
|
12
12
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
13
13
|
import 'i18next';
|
|
14
14
|
import '@bigbinary/neeto-molecules/DateFormat';
|
|
@@ -21,7 +21,7 @@ import '@tanstack/react-query';
|
|
|
21
21
|
import '@bigbinary/neeto-commons-frontend/react-utils';
|
|
22
22
|
import 'axios';
|
|
23
23
|
import 'qs';
|
|
24
|
-
import './queryConstants-
|
|
24
|
+
import './queryConstants-aYVM1oL2.js';
|
|
25
25
|
import '@bigbinary/neeto-commons-frontend/constants';
|
|
26
26
|
import 'decimal.js';
|
|
27
27
|
import '@bigbinary/neeto-commons-frontend/utils';
|
|
@@ -4,8 +4,8 @@ import { noop, findBy, isNotPresent } from '@bigbinary/neeto-cist';
|
|
|
4
4
|
import Button from '@bigbinary/neetoui/Button';
|
|
5
5
|
import { mergeDeepLeft } from 'ramda';
|
|
6
6
|
import { useTranslation } from 'react-i18next';
|
|
7
|
-
import { u as useCreateRazorpayPayment } from './usePaymentApi-
|
|
8
|
-
import { R as RAZORPAY_PAYMENT_BUTTON_OPTIONS } from './index-
|
|
7
|
+
import { u as useCreateRazorpayPayment } from './usePaymentApi-DTQ8wxiL.js';
|
|
8
|
+
import { R as RAZORPAY_PAYMENT_BUTTON_OPTIONS } from './index-P40XHLrP.js';
|
|
9
9
|
import { jsx } from 'react/jsx-runtime';
|
|
10
10
|
import '@babel/runtime/helpers/defineProperty';
|
|
11
11
|
import '@tanstack/react-query';
|
|
@@ -14,8 +14,8 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
14
14
|
import { useQuery } from '@tanstack/react-query';
|
|
15
15
|
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
16
16
|
import axios from 'axios';
|
|
17
|
-
import { B as BASE_URL } from './index-
|
|
18
|
-
import { Q as QUERY_KEYS } from './queryConstants-
|
|
17
|
+
import { B as BASE_URL } from './index-P40XHLrP.js';
|
|
18
|
+
import { Q as QUERY_KEYS } from './queryConstants-aYVM1oL2.js';
|
|
19
19
|
import { t } from 'i18next';
|
|
20
20
|
import * as yup from 'yup';
|
|
21
21
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
package/dist/RefundsDashboard.js
CHANGED
|
@@ -8,11 +8,11 @@ import { buildFiltersFromURL } from '@bigbinary/neeto-filters-frontend/utils';
|
|
|
8
8
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
9
9
|
import { map, curry, mergeDeepWith, concat, mergeLeft, reject, isNil, prop, isEmpty, modify } from 'ramda';
|
|
10
10
|
import { useHistory } from 'react-router-dom';
|
|
11
|
-
import { E as ExportModal } from './ExportModal-
|
|
11
|
+
import { E as ExportModal } from './ExportModal-UegCpavy.js';
|
|
12
12
|
import { useQuery } from '@tanstack/react-query';
|
|
13
13
|
import axios from 'axios';
|
|
14
|
-
import { B as BASE_URL, P as PAYMENT_PROVIDERS, D as DEFAULT_TAG_STYLE,
|
|
15
|
-
import { Q as QUERY_KEYS } from './queryConstants-
|
|
14
|
+
import { B as BASE_URL, P as PAYMENT_PROVIDERS, D as DEFAULT_TAG_STYLE, n as formatAmount, o as formatCurrency, q as buildDefaultTableColumns, S as SORT_DIRECTIONS, r as processDataIndex, A as ASSOCIATED_TABLE_COLUMNS, m as DEFAULT_SORT_PROPERTIES, s as shouldTabsVisible, U as UN_HIDEABLE_COLUMNS, k as DEFAULT_PAGE_VALUES, t as DASHBOARD_KIND } from './index-P40XHLrP.js';
|
|
15
|
+
import { Q as QUERY_KEYS } from './queryConstants-aYVM1oL2.js';
|
|
16
16
|
import { t } from 'i18next';
|
|
17
17
|
import { toLabelAndValue, snakeToCamelCase, humanize, isPresent, isNotPresent, camelToSnakeCase } from '@bigbinary/neeto-cist';
|
|
18
18
|
import { useHiddenColumns } from '@bigbinary/neeto-molecules/Columns';
|
|
@@ -8,12 +8,12 @@ import { buildFiltersFromURL } from '@bigbinary/neeto-filters-frontend/utils';
|
|
|
8
8
|
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
9
9
|
import { mergeLeft, curry, mergeDeepWith, concat, reject, isNil, map, prop, sortBy, isEmpty, modify, pluck } from 'ramda';
|
|
10
10
|
import { useHistory } from 'react-router-dom';
|
|
11
|
-
import { E as ExportModal } from './ExportModal-
|
|
11
|
+
import { E as ExportModal } from './ExportModal-UegCpavy.js';
|
|
12
12
|
import { useQuery } from '@tanstack/react-query';
|
|
13
13
|
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
14
14
|
import axios from 'axios';
|
|
15
|
-
import { B as BASE_URL,
|
|
16
|
-
import { Q as QUERY_KEYS } from './queryConstants-
|
|
15
|
+
import { B as BASE_URL, w as preProcessStatus, x as getTagStyle, n as formatAmount, o as formatCurrency, y as PAYMENT_KIND, r as processDataIndex, S as SORT_DIRECTIONS, m as DEFAULT_SORT_PROPERTIES, s as shouldTabsVisible, U as UN_HIDEABLE_COLUMNS, k as DEFAULT_PAGE_VALUES, t as DASHBOARD_KIND } from './index-P40XHLrP.js';
|
|
16
|
+
import { Q as QUERY_KEYS } from './queryConstants-aYVM1oL2.js';
|
|
17
17
|
import Modal from '@bigbinary/neetoui/Modal';
|
|
18
18
|
import Typography from '@bigbinary/neetoui/Typography';
|
|
19
19
|
import Form from '@bigbinary/neetoui/formik/Form';
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import { humanize, isPresent, isNotPresent, _humanize, noop } from '@bigbinary/neeto-cist';
|
|
2
|
+
import Container from '@bigbinary/neeto-molecules/Container';
|
|
3
|
+
import Header from '@bigbinary/neeto-molecules/Header';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { useHistory, Switch, Route } from 'react-router-dom';
|
|
6
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
7
|
+
import { useState, useEffect } from 'react';
|
|
8
|
+
import DOMPurify from 'dompurify';
|
|
9
|
+
import { buildUrl } from '@bigbinary/neeto-commons-frontend/utils';
|
|
10
|
+
import Stripe from '@bigbinary/neeto-icons/misc/Stripe';
|
|
11
|
+
import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
|
|
12
|
+
import Radio from '@bigbinary/neetoui/Radio';
|
|
13
|
+
import Button from '@bigbinary/neetoui/Button';
|
|
14
|
+
import { u as useFetchPaymentIntegrations } from './useIntegrationsApi-Cm_61Wk1.js';
|
|
15
|
+
import { v as STRIPE_CONNECT_ENDPOINT, B as BASE_URL } from './index-P40XHLrP.js';
|
|
16
|
+
import { t } from 'i18next';
|
|
17
|
+
import * as yup from 'yup';
|
|
18
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
19
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
20
|
+
import Select from '@bigbinary/neetoui/formik/Select';
|
|
21
|
+
import Form from '@bigbinary/neetoui/formik/Form';
|
|
22
|
+
import ActionBlock from '@bigbinary/neetoui/formik/ActionBlock';
|
|
23
|
+
import { a as useCreateStripeAccount, b as usePollingStripeAccountCreationStatus } from './useAccountsApi-CY07Pd2F.js';
|
|
24
|
+
import { useQuery } from '@tanstack/react-query';
|
|
25
|
+
import axios from 'axios';
|
|
26
|
+
import { Q as QUERY_KEYS } from './queryConstants-aYVM1oL2.js';
|
|
27
|
+
import { useQueryParams } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
28
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
29
|
+
import Callout from '@bigbinary/neetoui/Callout';
|
|
30
|
+
import '@babel/runtime/helpers/defineProperty';
|
|
31
|
+
import '@bigbinary/neeto-commons-frontend/constants';
|
|
32
|
+
import 'decimal.js';
|
|
33
|
+
import 'ramda';
|
|
34
|
+
|
|
35
|
+
var INTEGRATION_METHOD = {
|
|
36
|
+
useExistingAccount: "use_existing_account",
|
|
37
|
+
createNewAccount: "create_new_account"
|
|
38
|
+
};
|
|
39
|
+
var POLLING_INTERVAL = 5000;
|
|
40
|
+
var MAX_POLLING_TIME = 30000;
|
|
41
|
+
var INITIAL_VALUES = {
|
|
42
|
+
country: "",
|
|
43
|
+
return_url: ""
|
|
44
|
+
};
|
|
45
|
+
var VALIDATION_SCHEMA = yup.object().shape({
|
|
46
|
+
country: yup.object().required(t("neetoPayments.validations.countryRequired"))
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
var sanitize = DOMPurify.sanitize;
|
|
50
|
+
var Account = function Account(_ref) {
|
|
51
|
+
var processingPageRoute = _ref.processingPageRoute,
|
|
52
|
+
countryPageRoute = _ref.countryPageRoute,
|
|
53
|
+
productNameLabel = _ref.productNameLabel,
|
|
54
|
+
getStripeAccount = _ref.getStripeAccount,
|
|
55
|
+
manageRoute = _ref.manageRoute;
|
|
56
|
+
var _useTranslation = useTranslation(),
|
|
57
|
+
t = _useTranslation.t;
|
|
58
|
+
var _useState = useState(INTEGRATION_METHOD.createNewAccount),
|
|
59
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
60
|
+
selectedOption = _useState2[0],
|
|
61
|
+
setSelectedOption = _useState2[1];
|
|
62
|
+
var history = useHistory();
|
|
63
|
+
var _useFetchPaymentInteg = useFetchPaymentIntegrations(),
|
|
64
|
+
_useFetchPaymentInteg2 = _useFetchPaymentInteg.data,
|
|
65
|
+
_useFetchPaymentInteg3 = _useFetchPaymentInteg2 === void 0 ? {} : _useFetchPaymentInteg2,
|
|
66
|
+
stripeStandardAccounts = _useFetchPaymentInteg3.stripeStandardAccounts;
|
|
67
|
+
var stripeAccount = getStripeAccount(stripeStandardAccounts);
|
|
68
|
+
var stripeConnectUrl = buildUrl(STRIPE_CONNECT_ENDPOINT, {
|
|
69
|
+
return_url: "".concat(window.location.origin).concat(processingPageRoute)
|
|
70
|
+
});
|
|
71
|
+
var handleSubmit = function handleSubmit() {
|
|
72
|
+
if (selectedOption !== INTEGRATION_METHOD.useExistingAccount) {
|
|
73
|
+
return history.push(countryPageRoute);
|
|
74
|
+
}
|
|
75
|
+
return window.location.href = sanitize(stripeConnectUrl);
|
|
76
|
+
};
|
|
77
|
+
useEffect(function () {
|
|
78
|
+
if (stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected) {
|
|
79
|
+
history.push(manageRoute);
|
|
80
|
+
}
|
|
81
|
+
}, [stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.isConnected]);
|
|
82
|
+
return /*#__PURE__*/jsx(CardLayout, {
|
|
83
|
+
icon: /*#__PURE__*/jsx(Stripe, {
|
|
84
|
+
size: 48
|
|
85
|
+
}),
|
|
86
|
+
title: t("neetoPayments.stripeConnect.title"),
|
|
87
|
+
actionBlock: /*#__PURE__*/jsx(Button, {
|
|
88
|
+
label: t("neetoPayments.common.continue"),
|
|
89
|
+
onClick: handleSubmit
|
|
90
|
+
}),
|
|
91
|
+
description: t("neetoPayments.stripeConnect.unlinkedDescription", {
|
|
92
|
+
productNameLabel: productNameLabel
|
|
93
|
+
}),
|
|
94
|
+
children: /*#__PURE__*/jsxs(Radio, {
|
|
95
|
+
value: selectedOption,
|
|
96
|
+
onChange: function onChange(_ref2) {
|
|
97
|
+
var value = _ref2.target.value;
|
|
98
|
+
return setSelectedOption(value);
|
|
99
|
+
},
|
|
100
|
+
children: [/*#__PURE__*/jsx(Radio.Item, {
|
|
101
|
+
label: t("neetoPayments.stripeConnect.createNewAccount"),
|
|
102
|
+
name: "accountMethod",
|
|
103
|
+
value: INTEGRATION_METHOD.createNewAccount
|
|
104
|
+
}), /*#__PURE__*/jsx(Radio.Item, {
|
|
105
|
+
label: t("neetoPayments.stripeConnect.useExistingAccount"),
|
|
106
|
+
name: "accountMethod",
|
|
107
|
+
value: INTEGRATION_METHOD.useExistingAccount
|
|
108
|
+
})]
|
|
109
|
+
})
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var fetchCountries = function fetchCountries() {
|
|
114
|
+
return axios.get("".concat(BASE_URL, "/api/v1/stripe/countries"));
|
|
115
|
+
};
|
|
116
|
+
var countriesApi = {
|
|
117
|
+
fetchCountries: fetchCountries
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
var useFetchStripeCountries = function useFetchStripeCountries() {
|
|
121
|
+
return useQuery({
|
|
122
|
+
queryKey: [QUERY_KEYS.STRIPE_COUNTRIES],
|
|
123
|
+
queryFn: countriesApi.fetchCountries
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var buildRefreshUrl = function buildRefreshUrl(accountId, returnUrl) {
|
|
128
|
+
return "/payments/api/v1/stripe/callbacks/".concat(accountId, "/refresh?return_url=").concat(returnUrl);
|
|
129
|
+
};
|
|
130
|
+
var buildCountryOptions = function buildCountryOptions(countries) {
|
|
131
|
+
var _Object$entries;
|
|
132
|
+
return (_Object$entries = Object.entries(countries)) === null || _Object$entries === void 0 ? void 0 : _Object$entries.map(function (country) {
|
|
133
|
+
return {
|
|
134
|
+
label: humanize(country[0]),
|
|
135
|
+
value: country[1]
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
var Country = function Country(_ref) {
|
|
141
|
+
var processingPageRoute = _ref.processingPageRoute,
|
|
142
|
+
productNameLabel = _ref.productNameLabel;
|
|
143
|
+
var _useState = useState(false),
|
|
144
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
145
|
+
isPolling = _useState2[0],
|
|
146
|
+
setIsPolling = _useState2[1];
|
|
147
|
+
var _useTranslation = useTranslation(),
|
|
148
|
+
t = _useTranslation.t;
|
|
149
|
+
var history = useHistory();
|
|
150
|
+
var refetchInterval = function refetchInterval(query) {
|
|
151
|
+
var _ref2 = query.state.data || {},
|
|
152
|
+
jobStatus = _ref2.jobStatus,
|
|
153
|
+
onboarding = _ref2.onboarding;
|
|
154
|
+
if (jobStatus === "complete") {
|
|
155
|
+
window.open(onboarding === null || onboarding === void 0 ? void 0 : onboarding.url, "_self");
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
return POLLING_INTERVAL;
|
|
159
|
+
};
|
|
160
|
+
var _useCreateStripeAccou = useCreateStripeAccount({
|
|
161
|
+
onSuccess: function onSuccess() {
|
|
162
|
+
return setIsPolling(true);
|
|
163
|
+
}
|
|
164
|
+
}),
|
|
165
|
+
isCreating = _useCreateStripeAccou.isPending,
|
|
166
|
+
_useCreateStripeAccou2 = _useCreateStripeAccou.data,
|
|
167
|
+
_useCreateStripeAccou3 = _useCreateStripeAccou2 === void 0 ? {} : _useCreateStripeAccou2,
|
|
168
|
+
jobId = _useCreateStripeAccou3.jobId,
|
|
169
|
+
createStripeAccount = _useCreateStripeAccou.mutate;
|
|
170
|
+
var _useFetchStripeCountr = useFetchStripeCountries(),
|
|
171
|
+
isLoading = _useFetchStripeCountr.isLoading,
|
|
172
|
+
_useFetchStripeCountr2 = _useFetchStripeCountr.data,
|
|
173
|
+
_useFetchStripeCountr3 = _useFetchStripeCountr2 === void 0 ? {} : _useFetchStripeCountr2,
|
|
174
|
+
_useFetchStripeCountr4 = _useFetchStripeCountr3.countries,
|
|
175
|
+
countries = _useFetchStripeCountr4 === void 0 ? {} : _useFetchStripeCountr4;
|
|
176
|
+
usePollingStripeAccountCreationStatus(jobId, {
|
|
177
|
+
refetchInterval: refetchInterval,
|
|
178
|
+
enabled: isPresent(jobId)
|
|
179
|
+
});
|
|
180
|
+
var handleSubmit = function handleSubmit(values) {
|
|
181
|
+
var payload = {
|
|
182
|
+
returnUrl: "".concat(window.location.origin).concat(processingPageRoute),
|
|
183
|
+
country: values.country.value
|
|
184
|
+
};
|
|
185
|
+
createStripeAccount(payload);
|
|
186
|
+
};
|
|
187
|
+
if (isLoading) {
|
|
188
|
+
return /*#__PURE__*/jsx("div", {
|
|
189
|
+
className: "flex items-center justify-center flex-grow w-full",
|
|
190
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
return /*#__PURE__*/jsx(Form, {
|
|
194
|
+
className: "w-full",
|
|
195
|
+
formikProps: {
|
|
196
|
+
enableReinitialize: true,
|
|
197
|
+
initialValues: INITIAL_VALUES,
|
|
198
|
+
validationSchema: VALIDATION_SCHEMA,
|
|
199
|
+
onSubmit: handleSubmit
|
|
200
|
+
},
|
|
201
|
+
children: /*#__PURE__*/jsx(CardLayout, {
|
|
202
|
+
icon: /*#__PURE__*/jsx(Stripe, {
|
|
203
|
+
size: 48
|
|
204
|
+
}),
|
|
205
|
+
title: t("neetoPayments.stripeConnect.title"),
|
|
206
|
+
actionBlock: /*#__PURE__*/jsx(ActionBlock, {
|
|
207
|
+
cancelButtonProps: {
|
|
208
|
+
onClick: function onClick() {
|
|
209
|
+
return history.goBack();
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
isSubmitting: isCreating || isPolling,
|
|
213
|
+
submitButtonProps: {
|
|
214
|
+
label: t("neetoPayments.common.connect")
|
|
215
|
+
}
|
|
216
|
+
}),
|
|
217
|
+
description: t("neetoPayments.stripeConnect.unlinkedDescription", {
|
|
218
|
+
productNameLabel: productNameLabel
|
|
219
|
+
}),
|
|
220
|
+
children: /*#__PURE__*/jsx(Select, {
|
|
221
|
+
required: true,
|
|
222
|
+
helpText: t("neetoPayments.stripeConnect.countryHelpText"),
|
|
223
|
+
label: t("neetoPayments.common.country"),
|
|
224
|
+
name: "country",
|
|
225
|
+
options: buildCountryOptions(countries),
|
|
226
|
+
placeholder: t("neetoPayments.stripeConnect.countryPlaceholder")
|
|
227
|
+
})
|
|
228
|
+
})
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
var Processing = function Processing(_ref) {
|
|
233
|
+
var getStripeAccount = _ref.getStripeAccount,
|
|
234
|
+
productNameLabel = _ref.productNameLabel,
|
|
235
|
+
manageRoute = _ref.manageRoute;
|
|
236
|
+
var _useState = useState(false),
|
|
237
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
238
|
+
isPolling = _useState2[0],
|
|
239
|
+
setIsPolling = _useState2[1];
|
|
240
|
+
var _useTranslation = useTranslation(),
|
|
241
|
+
t = _useTranslation.t;
|
|
242
|
+
var history = useHistory();
|
|
243
|
+
var _useQueryParams = useQueryParams(),
|
|
244
|
+
error = _useQueryParams.error,
|
|
245
|
+
errorDescription = _useQueryParams.errorDescription;
|
|
246
|
+
var refetchInterval = function refetchInterval(query) {
|
|
247
|
+
var _ref2 = query.state.data || {},
|
|
248
|
+
stripeStandardAccounts = _ref2.stripeStandardAccounts;
|
|
249
|
+
var stripeAccount = getStripeAccount(stripeStandardAccounts);
|
|
250
|
+
if (!(stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected) && isPolling) {
|
|
251
|
+
return POLLING_INTERVAL;
|
|
252
|
+
}
|
|
253
|
+
if (stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected) {
|
|
254
|
+
setIsPolling(false);
|
|
255
|
+
history.push(manageRoute);
|
|
256
|
+
}
|
|
257
|
+
return false;
|
|
258
|
+
};
|
|
259
|
+
var _useFetchPaymentInteg = useFetchPaymentIntegrations({
|
|
260
|
+
refetchInterval: refetchInterval,
|
|
261
|
+
enabled: isNotPresent(error)
|
|
262
|
+
}),
|
|
263
|
+
_useFetchPaymentInteg2 = _useFetchPaymentInteg.data,
|
|
264
|
+
_useFetchPaymentInteg3 = _useFetchPaymentInteg2 === void 0 ? {} : _useFetchPaymentInteg2,
|
|
265
|
+
stripeStandardAccounts = _useFetchPaymentInteg3.stripeStandardAccounts;
|
|
266
|
+
var stripeAccount = getStripeAccount(stripeStandardAccounts);
|
|
267
|
+
var isAccountProcessingFailed = isPresent(error) && isPresent(errorDescription) || !isPolling && !(stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected);
|
|
268
|
+
useEffect(function () {
|
|
269
|
+
if (stripeAccount !== null && stripeAccount !== void 0 && stripeAccount.isConnected) {
|
|
270
|
+
history.push(manageRoute);
|
|
271
|
+
}
|
|
272
|
+
if (isNotPresent(error)) {
|
|
273
|
+
setIsPolling(true);
|
|
274
|
+
}
|
|
275
|
+
setInterval(function () {
|
|
276
|
+
setIsPolling(false);
|
|
277
|
+
}, MAX_POLLING_TIME);
|
|
278
|
+
}, []);
|
|
279
|
+
return /*#__PURE__*/jsxs(CardLayout, {
|
|
280
|
+
icon: /*#__PURE__*/jsx(Stripe, {
|
|
281
|
+
size: 48
|
|
282
|
+
}),
|
|
283
|
+
title: t("neetoPayments.stripeConnect.title"),
|
|
284
|
+
actionBlock: isAccountProcessingFailed && /*#__PURE__*/jsx(Button, {
|
|
285
|
+
href: buildRefreshUrl(stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.id),
|
|
286
|
+
label: t("neetoPayments.common.tryAgain")
|
|
287
|
+
}),
|
|
288
|
+
description: t("neetoPayments.stripeConnect.linkedDescription", {
|
|
289
|
+
productNameLabel: productNameLabel
|
|
290
|
+
}),
|
|
291
|
+
children: [isPolling && /*#__PURE__*/jsx(Callout, {
|
|
292
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
293
|
+
className: "flex space-x-4",
|
|
294
|
+
children: [/*#__PURE__*/jsx(Spinner, {}), /*#__PURE__*/jsx(Typography, {
|
|
295
|
+
style: "body1",
|
|
296
|
+
children: t("neetoPayments.stripeConnect.verifyingMessage")
|
|
297
|
+
})]
|
|
298
|
+
})
|
|
299
|
+
}), isAccountProcessingFailed && /*#__PURE__*/jsx(Callout, {
|
|
300
|
+
style: "danger",
|
|
301
|
+
children: /*#__PURE__*/jsx(Typography, {
|
|
302
|
+
style: "body1",
|
|
303
|
+
children: isPresent(errorDescription) ? _humanize(errorDescription) : t("neetoPayments.stripeConnect.failedProcessing")
|
|
304
|
+
})
|
|
305
|
+
})]
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
var StripeConnect = function StripeConnect(_ref) {
|
|
310
|
+
var baseRoute = _ref.baseRoute,
|
|
311
|
+
manageRoute = _ref.manageRoute,
|
|
312
|
+
breadcrumbs = _ref.breadcrumbs,
|
|
313
|
+
productNameLabel = _ref.productNameLabel,
|
|
314
|
+
_ref$getStripeAccount = _ref.getStripeAccount,
|
|
315
|
+
getStripeAccount = _ref$getStripeAccount === void 0 ? noop : _ref$getStripeAccount;
|
|
316
|
+
var _useTranslation = useTranslation(),
|
|
317
|
+
t = _useTranslation.t;
|
|
318
|
+
var countryPageRoute = "".concat(baseRoute, "/countries");
|
|
319
|
+
var processingPageRoute = "".concat(baseRoute, "/processing");
|
|
320
|
+
return /*#__PURE__*/jsxs(Container, {
|
|
321
|
+
children: [/*#__PURE__*/jsx(Header, {
|
|
322
|
+
breadcrumbs: breadcrumbs,
|
|
323
|
+
title: t("neetoPayments.common.connect")
|
|
324
|
+
}), /*#__PURE__*/jsxs(Switch, {
|
|
325
|
+
children: [/*#__PURE__*/jsx(Route, {
|
|
326
|
+
exact: true,
|
|
327
|
+
path: baseRoute,
|
|
328
|
+
render: function render() {
|
|
329
|
+
return /*#__PURE__*/jsx(Account, {
|
|
330
|
+
countryPageRoute: countryPageRoute,
|
|
331
|
+
getStripeAccount: getStripeAccount,
|
|
332
|
+
manageRoute: manageRoute,
|
|
333
|
+
processingPageRoute: processingPageRoute,
|
|
334
|
+
productNameLabel: productNameLabel
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}), /*#__PURE__*/jsx(Route, {
|
|
338
|
+
exact: true,
|
|
339
|
+
path: countryPageRoute,
|
|
340
|
+
component: function component() {
|
|
341
|
+
return /*#__PURE__*/jsx(Country, {
|
|
342
|
+
processingPageRoute: processingPageRoute,
|
|
343
|
+
productNameLabel: productNameLabel
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}), /*#__PURE__*/jsx(Route, {
|
|
347
|
+
exact: true,
|
|
348
|
+
path: processingPageRoute,
|
|
349
|
+
component: function component() {
|
|
350
|
+
return /*#__PURE__*/jsx(Processing, {
|
|
351
|
+
getStripeAccount: getStripeAccount,
|
|
352
|
+
manageRoute: manageRoute,
|
|
353
|
+
productNameLabel: productNameLabel
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
})]
|
|
357
|
+
})]
|
|
358
|
+
});
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
export { StripeConnect as default };
|
|
362
|
+
//# sourceMappingURL=StripeConnect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeConnect.js","sources":["../app/javascript/src/components/StripeConnect/constants.js","../app/javascript/src/components/StripeConnect/Account.jsx","../app/javascript/src/apis/countries.js","../app/javascript/src/hooks/reactQuery/useCountriesApi.js","../app/javascript/src/components/StripeConnect/utils.js","../app/javascript/src/components/StripeConnect/Country.jsx","../app/javascript/src/components/StripeConnect/Processing.jsx","../app/javascript/src/components/StripeConnect/index.jsx"],"sourcesContent":["import { t } from \"i18next\";\nimport * as yup from \"yup\";\n\nexport const VALID_ERROR_CODES = [\n \"account_already_exists\",\n \"account_not_activated\",\n];\n\nexport const INTEGRATION_METHOD = {\n useExistingAccount: \"use_existing_account\",\n createNewAccount: \"create_new_account\",\n};\nexport const POLLING_INTERVAL = 5000;\nexport const MAX_POLLING_TIME = 30000;\nexport const INITIAL_VALUES = { country: \"\", return_url: \"\" };\n\nexport const VALIDATION_SCHEMA = yup.object().shape({\n country: yup\n .object()\n .required(t(\"neetoPayments.validations.countryRequired\")),\n});\n","import { useEffect, useState } from \"react\";\n\nimport DOMPurify from \"dompurify\";\nimport { buildUrl } from \"neetocommons/utils\";\nimport { Stripe } from \"neetoicons/misc\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport { Radio, Button } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport { useFetchPaymentIntegrations } from \"hooks/reactQuery/useIntegrationsApi\";\nimport { STRIPE_CONNECT_ENDPOINT } from \"src/constants\";\n\nimport { INTEGRATION_METHOD } from \"./constants\";\n\nconst sanitize = DOMPurify.sanitize;\n\nconst Account = ({\n processingPageRoute,\n countryPageRoute,\n productNameLabel,\n getStripeAccount,\n manageRoute,\n}) => {\n const { t } = useTranslation();\n const [selectedOption, setSelectedOption] = useState(\n INTEGRATION_METHOD.createNewAccount\n );\n\n const history = useHistory();\n\n const { data: { stripeStandardAccounts } = {} } =\n useFetchPaymentIntegrations();\n const stripeAccount = getStripeAccount(stripeStandardAccounts);\n\n const stripeConnectUrl = buildUrl(STRIPE_CONNECT_ENDPOINT, {\n return_url: `${window.location.origin}${processingPageRoute}`,\n });\n\n const handleSubmit = () => {\n if (selectedOption !== INTEGRATION_METHOD.useExistingAccount) {\n return history.push(countryPageRoute);\n }\n\n return (window.location.href = sanitize(stripeConnectUrl));\n };\n\n useEffect(() => {\n if (stripeAccount?.isConnected) {\n history.push(manageRoute);\n }\n }, [stripeAccount?.isConnected]);\n\n return (\n <CardLayout\n icon={<Stripe size={48} />}\n title={t(\"neetoPayments.stripeConnect.title\")}\n actionBlock={\n <Button\n label={t(\"neetoPayments.common.continue\")}\n onClick={handleSubmit}\n />\n }\n description={t(\"neetoPayments.stripeConnect.unlinkedDescription\", {\n productNameLabel,\n })}\n >\n <Radio\n value={selectedOption}\n onChange={({ target: { value } }) => setSelectedOption(value)}\n >\n <Radio.Item\n label={t(\"neetoPayments.stripeConnect.createNewAccount\")}\n name=\"accountMethod\"\n value={INTEGRATION_METHOD.createNewAccount}\n />\n <Radio.Item\n label={t(\"neetoPayments.stripeConnect.useExistingAccount\")}\n name=\"accountMethod\"\n value={INTEGRATION_METHOD.useExistingAccount}\n />\n </Radio>\n </CardLayout>\n );\n};\n\nexport default Account;\n","import axios from \"axios\";\n\nimport { BASE_URL } from \"src/constants\";\n\nconst fetchCountries = () => axios.get(`${BASE_URL}/api/v1/stripe/countries`);\n\nconst countriesApi = { fetchCountries };\n\nexport default countriesApi;\n","import { useQuery } from \"@tanstack/react-query\";\n\nimport countriesApi from \"apis/countries\";\nimport { QUERY_KEYS } from \"src/common/queryConstants\";\n\nexport const useFetchStripeCountries = () =>\n useQuery({\n queryKey: [QUERY_KEYS.STRIPE_COUNTRIES],\n queryFn: countriesApi.fetchCountries,\n });\n","import { humanize } from \"neetocist\";\n\nexport const buildRefreshUrl = (accountId, returnUrl) =>\n `/payments/api/v1/stripe/callbacks/${accountId}/refresh?return_url=${returnUrl}`;\n\nexport const buildCountryOptions = countries =>\n Object.entries(countries)?.map(country => ({\n label: humanize(country[0]),\n value: country[1],\n }));\n","import { useState } from \"react\";\n\nimport { isPresent } from \"neetocist\";\nimport { Stripe } from \"neetoicons/misc\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport { Spinner } from \"neetoui\";\nimport { Select, Form, ActionBlock } from \"neetoui/formik\";\nimport { useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport {\n usePollingStripeAccountCreationStatus,\n useCreateStripeAccount,\n} from \"hooks/reactQuery/stripe/useAccountsApi\";\nimport { useFetchStripeCountries } from \"hooks/reactQuery/useCountriesApi\";\n\nimport {\n INITIAL_VALUES,\n POLLING_INTERVAL,\n VALIDATION_SCHEMA,\n} from \"./constants\";\nimport { buildCountryOptions } from \"./utils\";\n\nconst Country = ({ processingPageRoute, productNameLabel }) => {\n const [isPolling, setIsPolling] = useState(false);\n\n const { t } = useTranslation();\n const history = useHistory();\n\n const refetchInterval = query => {\n const { jobStatus, onboarding } = query.state.data || {};\n if (jobStatus === \"complete\") {\n window.open(onboarding?.url, \"_self\");\n\n return false;\n }\n\n return POLLING_INTERVAL;\n };\n\n const {\n isPending: isCreating,\n data: { jobId } = {},\n mutate: createStripeAccount,\n } = useCreateStripeAccount({ onSuccess: () => setIsPolling(true) });\n\n const { isLoading, data: { countries = {} } = {} } =\n useFetchStripeCountries();\n\n usePollingStripeAccountCreationStatus(jobId, {\n refetchInterval,\n enabled: isPresent(jobId),\n });\n\n const handleSubmit = values => {\n const payload = {\n returnUrl: `${window.location.origin}${processingPageRoute}`,\n country: values.country.value,\n };\n createStripeAccount(payload);\n };\n\n if (isLoading) {\n return (\n <div className=\"flex items-center justify-center flex-grow w-full\">\n <Spinner />\n </div>\n );\n }\n\n return (\n <Form\n className=\"w-full\"\n formikProps={{\n enableReinitialize: true,\n initialValues: INITIAL_VALUES,\n validationSchema: VALIDATION_SCHEMA,\n onSubmit: handleSubmit,\n }}\n >\n <CardLayout\n icon={<Stripe size={48} />}\n title={t(\"neetoPayments.stripeConnect.title\")}\n actionBlock={\n <ActionBlock\n cancelButtonProps={{ onClick: () => history.goBack() }}\n isSubmitting={isCreating || isPolling}\n submitButtonProps={{ label: t(\"neetoPayments.common.connect\") }}\n />\n }\n description={t(\"neetoPayments.stripeConnect.unlinkedDescription\", {\n productNameLabel,\n })}\n >\n <Select\n required\n helpText={t(\"neetoPayments.stripeConnect.countryHelpText\")}\n label={t(\"neetoPayments.common.country\")}\n name=\"country\"\n options={buildCountryOptions(countries)}\n placeholder={t(\"neetoPayments.stripeConnect.countryPlaceholder\")}\n />\n </CardLayout>\n </Form>\n );\n};\n\nexport default Country;\n","import { useEffect, useState } from \"react\";\n\nimport { isPresent, _humanize, isNotPresent } from \"neetocist\";\nimport { useQueryParams } from \"neetocommons/react-utils\";\nimport { Stripe } from \"neetoicons/misc\";\nimport CardLayout from \"neetomolecules/CardLayout\";\nimport { Typography, Callout, Spinner, Button } from \"neetoui\";\nimport { useTranslation } from \"react-i18next\";\nimport { useHistory } from \"react-router-dom\";\n\nimport { useFetchPaymentIntegrations } from \"hooks/reactQuery/useIntegrationsApi\";\n\nimport { MAX_POLLING_TIME, POLLING_INTERVAL } from \"./constants\";\nimport { buildRefreshUrl } from \"./utils\";\n\nconst Processing = ({ getStripeAccount, productNameLabel, manageRoute }) => {\n const [isPolling, setIsPolling] = useState(false);\n const { t } = useTranslation();\n const history = useHistory();\n const { error, errorDescription } = useQueryParams();\n\n const refetchInterval = query => {\n const { stripeStandardAccounts } = query.state.data || {};\n const stripeAccount = getStripeAccount(stripeStandardAccounts);\n if (!stripeAccount?.isConnected && isPolling) {\n return POLLING_INTERVAL;\n }\n\n if (stripeAccount?.isConnected) {\n setIsPolling(false);\n history.push(manageRoute);\n }\n\n return false;\n };\n\n const { data: { stripeStandardAccounts } = {} } = useFetchPaymentIntegrations(\n { refetchInterval, enabled: isNotPresent(error) }\n );\n\n const stripeAccount = getStripeAccount(stripeStandardAccounts);\n const isAccountProcessingFailed =\n (isPresent(error) && isPresent(errorDescription)) ||\n (!isPolling && !stripeAccount?.isConnected);\n\n useEffect(() => {\n if (stripeAccount?.isConnected) {\n history.push(manageRoute);\n }\n\n if (isNotPresent(error)) {\n setIsPolling(true);\n }\n\n setInterval(() => {\n setIsPolling(false);\n }, MAX_POLLING_TIME);\n }, []);\n\n return (\n <CardLayout\n icon={<Stripe size={48} />}\n title={t(\"neetoPayments.stripeConnect.title\")}\n actionBlock={\n isAccountProcessingFailed && (\n <Button\n href={buildRefreshUrl(stripeAccount?.id)}\n label={t(\"neetoPayments.common.tryAgain\")}\n />\n )\n }\n description={t(\"neetoPayments.stripeConnect.linkedDescription\", {\n productNameLabel,\n })}\n >\n {isPolling && (\n <Callout>\n <div className=\"flex space-x-4\">\n <Spinner />\n <Typography style=\"body1\">\n {t(\"neetoPayments.stripeConnect.verifyingMessage\")}\n </Typography>\n </div>\n </Callout>\n )}\n {isAccountProcessingFailed && (\n <Callout style=\"danger\">\n <Typography style=\"body1\">\n {isPresent(errorDescription)\n ? _humanize(errorDescription)\n : t(\"neetoPayments.stripeConnect.failedProcessing\")}\n </Typography>\n </Callout>\n )}\n </CardLayout>\n );\n};\n\nexport default Processing;\n","import { noop } from \"neetocist\";\nimport Container from \"neetomolecules/Container\";\nimport Header from \"neetomolecules/Header\";\nimport { useTranslation } from \"react-i18next\";\nimport { Route, Switch } from \"react-router-dom\";\n\nimport Account from \"./Account\";\nimport Country from \"./Country\";\nimport Processing from \"./Processing\";\n\nconst StripeConnect = ({\n baseRoute,\n manageRoute,\n breadcrumbs,\n productNameLabel,\n getStripeAccount = noop,\n}) => {\n const { t } = useTranslation();\n const countryPageRoute = `${baseRoute}/countries`;\n const processingPageRoute = `${baseRoute}/processing`;\n\n return (\n <Container>\n <Header {...{ breadcrumbs }} title={t(\"neetoPayments.common.connect\")} />\n <Switch>\n <Route\n exact\n path={baseRoute}\n render={() => (\n <Account\n {...{\n countryPageRoute,\n getStripeAccount,\n manageRoute,\n processingPageRoute,\n productNameLabel,\n }}\n />\n )}\n />\n <Route\n exact\n path={countryPageRoute}\n component={() => (\n <Country {...{ processingPageRoute, productNameLabel }} />\n )}\n />\n <Route\n exact\n path={processingPageRoute}\n component={() => (\n <Processing\n {...{ getStripeAccount, manageRoute, productNameLabel }}\n />\n )}\n />\n </Switch>\n </Container>\n );\n};\n\nexport default StripeConnect;\n"],"names":["INTEGRATION_METHOD","useExistingAccount","createNewAccount","POLLING_INTERVAL","MAX_POLLING_TIME","INITIAL_VALUES","country","return_url","VALIDATION_SCHEMA","yup","object","shape","required","t","sanitize","DOMPurify","Account","_ref","processingPageRoute","countryPageRoute","productNameLabel","getStripeAccount","manageRoute","_useTranslation","useTranslation","_useState","useState","_useState2","_slicedToArray","selectedOption","setSelectedOption","history","useHistory","_useFetchPaymentInteg","useFetchPaymentIntegrations","_useFetchPaymentInteg2","data","_useFetchPaymentInteg3","stripeStandardAccounts","stripeAccount","stripeConnectUrl","buildUrl","STRIPE_CONNECT_ENDPOINT","concat","window","location","origin","handleSubmit","push","href","useEffect","isConnected","_jsx","CardLayout","icon","Stripe","size","title","actionBlock","Button","label","onClick","description","children","_jsxs","Radio","value","onChange","_ref2","target","Item","name","fetchCountries","axios","get","BASE_URL","countriesApi","useFetchStripeCountries","useQuery","queryKey","QUERY_KEYS","STRIPE_COUNTRIES","queryFn","buildRefreshUrl","accountId","returnUrl","buildCountryOptions","countries","_Object$entries","Object","entries","map","humanize","Country","isPolling","setIsPolling","refetchInterval","query","state","jobStatus","onboarding","open","url","_useCreateStripeAccou","useCreateStripeAccount","onSuccess","isCreating","isPending","_useCreateStripeAccou2","_useCreateStripeAccou3","jobId","createStripeAccount","mutate","_useFetchStripeCountr","isLoading","_useFetchStripeCountr2","_useFetchStripeCountr3","_useFetchStripeCountr4","usePollingStripeAccountCreationStatus","enabled","isPresent","values","payload","className","Spinner","Form","formikProps","enableReinitialize","initialValues","validationSchema","onSubmit","ActionBlock","cancelButtonProps","goBack","isSubmitting","submitButtonProps","Select","helpText","options","placeholder","Processing","_useQueryParams","useQueryParams","error","errorDescription","isNotPresent","isAccountProcessingFailed","setInterval","id","Callout","Typography","style","_humanize","StripeConnect","baseRoute","breadcrumbs","_ref$getStripeAccount","noop","Container","Header","Switch","Route","exact","path","render","component"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQO,IAAMA,kBAAkB,GAAG;AAChCC,EAAAA,kBAAkB,EAAE,sBAAsB;AAC1CC,EAAAA,gBAAgB,EAAE;AACpB,CAAC;AACM,IAAMC,gBAAgB,GAAG,IAAI;AAC7B,IAAMC,gBAAgB,GAAG,KAAK;AAC9B,IAAMC,cAAc,GAAG;AAAEC,EAAAA,OAAO,EAAE,EAAE;AAAEC,EAAAA,UAAU,EAAE;AAAG,CAAC;AAEtD,IAAMC,iBAAiB,GAAGC,GAAG,CAACC,MAAM,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gBAAgB;AAChBE,YAAAA,gBAAgB,EAAhBA,gBAAgB;AAChBC,YAAAA,WAAW,EAAXA,WAAW;AACXJ,YAAAA,mBAAmB,EAAnBA,mBAAmB;AACnBE,YAAAA,gBAAgB,EAAhBA;AAAgB,WAEnB,CAAC;AAAA;AACF,OACH,CAAC,eACFgC,GAAA,CAAC6G,KAAK,EAAA;QACJC,KAAK,EAAA,IAAA;AACLC,QAAAA,IAAI,EAAEhJ,gBAAiB;QACvBkJ,SAAS,EAAE,SAAXA,SAASA,GAAA;UAAA,oBACPjH,GAAA,CAACyC,OAAO,EAAA;AAAO3E,YAAAA,mBAAmB,EAAnBA,mBAAmB;AAAEE,YAAAA,gBAAgB,EAAhBA;AAAgB,WAAK,CAAC;AAAA;AAC1D,OACH,CAAC,eACFgC,GAAA,CAAC6G,KAAK,EAAA;QACJC,KAAK,EAAA,IAAA;AACLC,QAAAA,IAAI,EAAEjJ,mBAAoB;QAC1BmJ,SAAS,EAAE,SAAXA,SAASA,GAAA;UAAA,oBACPjH,GAAA,CAACwF,UAAU,EAAA;AACHvH,YAAAA,gBAAgB,EAAhBA,gBAAgB;AAAEC,YAAAA,WAAW,EAAXA,WAAW;AAAEF,YAAAA,gBAAgB,EAAhBA;AAAgB,WACtD,CAAC;AAAA;AACF,OACH,CAAC;AAAA,KACI,CAAC;AAAA,GACA,CAAC;AAEhB;;;;"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
|
|
2
|
+
import Switch from '@bigbinary/neetoui/Switch';
|
|
3
|
+
import Typography from '@bigbinary/neetoui/Typography';
|
|
4
|
+
import Spinner from '@bigbinary/neetoui/Spinner';
|
|
5
|
+
import Tooltip from '@bigbinary/neetoui/Tooltip';
|
|
6
|
+
import { useTranslation } from 'react-i18next';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
8
|
+
import { useQuery } from '@tanstack/react-query';
|
|
9
|
+
import { useMutationWithInvalidation } from '@bigbinary/neeto-commons-frontend/react-utils';
|
|
10
|
+
import { isNotNil } from 'ramda';
|
|
11
|
+
import axios from 'axios';
|
|
12
|
+
import { B as BASE_URL } from './index-P40XHLrP.js';
|
|
13
|
+
import { Q as QUERY_KEYS } from './queryConstants-aYVM1oL2.js';
|
|
14
|
+
import { u as useFetchPaymentIntegrations } from './useIntegrationsApi-Cm_61Wk1.js';
|
|
15
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
16
|
+
import 'i18next';
|
|
17
|
+
import '@bigbinary/neeto-commons-frontend/constants';
|
|
18
|
+
import 'decimal.js';
|
|
19
|
+
import '@bigbinary/neeto-cist';
|
|
20
|
+
import '@bigbinary/neeto-commons-frontend/utils';
|
|
21
|
+
|
|
22
|
+
var show = function show(integrationId) {
|
|
23
|
+
return axios.get("".concat(BASE_URL, "/api/v1/integrations/").concat(integrationId, "/checkout_setting"));
|
|
24
|
+
};
|
|
25
|
+
var update = function update(integrationId, payload) {
|
|
26
|
+
return axios.put("".concat(BASE_URL, "/api/v1/integrations/").concat(integrationId, "/checkout_setting"), {
|
|
27
|
+
checkoutSetting: payload
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var checkoutSettingsApi = {
|
|
31
|
+
show: show,
|
|
32
|
+
update: update
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
36
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
37
|
+
var useFetchCheckoutSetting = function useFetchCheckoutSetting(integrationId) {
|
|
38
|
+
return useQuery({
|
|
39
|
+
queryKey: [QUERY_KEYS.CHECKOUT_SETTING, integrationId],
|
|
40
|
+
queryFn: function queryFn() {
|
|
41
|
+
return checkoutSettingsApi.show(integrationId);
|
|
42
|
+
},
|
|
43
|
+
enabled: isNotNil(integrationId)
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
var useUpdateCheckoutSetting = function useUpdateCheckoutSetting(integrationId) {
|
|
47
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
48
|
+
return useMutationWithInvalidation(function (payload) {
|
|
49
|
+
return checkoutSettingsApi.update(integrationId, payload);
|
|
50
|
+
}, _objectSpread({
|
|
51
|
+
keysToInvalidate: [QUERY_KEYS.CHECKOUT_SETTING, integrationId]
|
|
52
|
+
}, options));
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var StripeManage = function StripeManage(_ref) {
|
|
56
|
+
var _stripeAccount$countr;
|
|
57
|
+
var getStripeAccount = _ref.getStripeAccount;
|
|
58
|
+
var _useTranslation = useTranslation(),
|
|
59
|
+
t = _useTranslation.t;
|
|
60
|
+
var _useFetchPaymentInteg = useFetchPaymentIntegrations(),
|
|
61
|
+
_useFetchPaymentInteg2 = _useFetchPaymentInteg.data,
|
|
62
|
+
_useFetchPaymentInteg3 = _useFetchPaymentInteg2 === void 0 ? {} : _useFetchPaymentInteg2,
|
|
63
|
+
stripeStandardAccounts = _useFetchPaymentInteg3.stripeStandardAccounts;
|
|
64
|
+
var stripeAccount = getStripeAccount(stripeStandardAccounts);
|
|
65
|
+
var isAddressRequired = (stripeAccount === null || stripeAccount === void 0 || (_stripeAccount$countr = stripeAccount.country) === null || _stripeAccount$countr === void 0 ? void 0 : _stripeAccount$countr.toLowerCase()) === "india";
|
|
66
|
+
var _useFetchCheckoutSett = useFetchCheckoutSetting(stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.id),
|
|
67
|
+
isLoading = _useFetchCheckoutSett.isLoading,
|
|
68
|
+
_useFetchCheckoutSett2 = _useFetchCheckoutSett.data,
|
|
69
|
+
_useFetchCheckoutSett3 = _useFetchCheckoutSett2 === void 0 ? {} : _useFetchCheckoutSett2,
|
|
70
|
+
checkoutSetting = _useFetchCheckoutSett3.checkoutSetting;
|
|
71
|
+
var _useUpdateCheckoutSet = useUpdateCheckoutSetting(stripeAccount === null || stripeAccount === void 0 ? void 0 : stripeAccount.id),
|
|
72
|
+
isPending = _useUpdateCheckoutSet.isPending,
|
|
73
|
+
updateCheckoutSetting = _useUpdateCheckoutSet.mutate;
|
|
74
|
+
if (isLoading) {
|
|
75
|
+
return /*#__PURE__*/jsx("div", {
|
|
76
|
+
className: "flex items-center justify-center w-full h-full",
|
|
77
|
+
children: /*#__PURE__*/jsx(Spinner, {})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return /*#__PURE__*/jsx(CardLayout, {
|
|
81
|
+
children: /*#__PURE__*/jsxs("div", {
|
|
82
|
+
className: "space-y-6",
|
|
83
|
+
children: [/*#__PURE__*/jsx(Typography, {
|
|
84
|
+
style: "h3",
|
|
85
|
+
children: t("neetoPayments.stripeManage.checkoutSettings.title")
|
|
86
|
+
}), /*#__PURE__*/jsxs("div", {
|
|
87
|
+
className: "space-y-4",
|
|
88
|
+
children: [/*#__PURE__*/jsx(Tooltip, {
|
|
89
|
+
disabled: !isAddressRequired,
|
|
90
|
+
placement: "bottom",
|
|
91
|
+
content: t("neetoPayments.stripeManage.checkoutSettings.addressDisabledMessage"),
|
|
92
|
+
children: /*#__PURE__*/jsx(Switch, {
|
|
93
|
+
checked: checkoutSetting === null || checkoutSetting === void 0 ? void 0 : checkoutSetting.isAddressEnabled,
|
|
94
|
+
disabled: isAddressRequired || isPending,
|
|
95
|
+
label: t("neetoPayments.stripeManage.checkoutSettings.address"),
|
|
96
|
+
onChange: function onChange() {
|
|
97
|
+
return updateCheckoutSetting({
|
|
98
|
+
isAddressEnabled: !(checkoutSetting !== null && checkoutSetting !== void 0 && checkoutSetting.isAddressEnabled)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
}), /*#__PURE__*/jsx(Tooltip, {
|
|
103
|
+
disabled: checkoutSetting === null || checkoutSetting === void 0 ? void 0 : checkoutSetting.isAddressEnabled,
|
|
104
|
+
placement: "bottom",
|
|
105
|
+
content: t("neetoPayments.stripeManage.checkoutSettings.phoneNumberDisabledMessage"),
|
|
106
|
+
children: /*#__PURE__*/jsx(Switch, {
|
|
107
|
+
checked: checkoutSetting === null || checkoutSetting === void 0 ? void 0 : checkoutSetting.isPhoneNumberEnabled,
|
|
108
|
+
disabled: isPending || !(checkoutSetting !== null && checkoutSetting !== void 0 && checkoutSetting.isAddressEnabled),
|
|
109
|
+
label: t("neetoPayments.stripeManage.checkoutSettings.phoneNumber"),
|
|
110
|
+
onChange: function onChange() {
|
|
111
|
+
return updateCheckoutSetting({
|
|
112
|
+
isPhoneNumberEnabled: !(checkoutSetting !== null && checkoutSetting !== void 0 && checkoutSetting.isPhoneNumberEnabled)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
})]
|
|
117
|
+
})]
|
|
118
|
+
})
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
export { StripeManage as default };
|
|
123
|
+
//# sourceMappingURL=StripeManage.js.map
|