@bigbinary/neeto-payments-frontend 6.3.8 → 6.4.0
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/dist/AccountsDashboard.js +5 -5
- package/dist/AdminCancelRecurringPaymentButton.js +2 -2
- package/dist/CashPaymentButton.js +2 -2
- package/dist/ConfirmCashPaymentButton.js +2 -2
- package/dist/CustomerCancelRecurringPaymentForm.js +2 -2
- package/dist/{ExportModal-k--5vSLt.js → ExportModal-Imx5pEqt.js} +3 -3
- package/dist/{ExportModal-k--5vSLt.js.map → ExportModal-Imx5pEqt.js.map} +1 -1
- package/dist/{ExportModal-Bun3pMGn.js → ExportModal-hqjn7q4w.js} +3 -3
- package/dist/{ExportModal-Bun3pMGn.js.map → ExportModal-hqjn7q4w.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 +5 -5
- package/dist/PayoutsDashboard.js +5 -5
- package/dist/PayoutsPage.js +4 -4
- package/dist/RazorpayConnect.js +2 -2
- package/dist/RazorpayLinkedAccountForm.js +2 -2
- package/dist/RazorpayPaymentButton.js +20 -11
- package/dist/RazorpayPaymentButton.js.map +1 -1
- package/dist/RecurringPaymentSettings.js +2 -2
- package/dist/RefundsDashboard.js +5 -5
- package/dist/SplitTransfersDashboard.js +4 -4
- package/dist/StripeCheckoutSetting.js +2 -2
- package/dist/StripeConnect.js +4 -4
- package/dist/StripeManage.js +2 -2
- package/dist/TaxesDashboard.js +2 -2
- package/dist/buildStripeTransactionLink.js +1 -1
- package/dist/cjs/RazorpayPaymentButton.js +19 -10
- package/dist/cjs/RazorpayPaymentButton.js.map +1 -1
- package/dist/cjs/index.js +9 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/razorpayCheckoutOutcome-DwerRK1B.js +96 -0
- package/dist/cjs/razorpayCheckoutOutcome-DwerRK1B.js.map +1 -0
- package/dist/cjs/useRazorpayPayment.js +20 -11
- package/dist/cjs/useRazorpayPayment.js.map +1 -1
- package/dist/cjs/v2/RazorpayPaymentButton.js +19 -10
- package/dist/cjs/v2/RazorpayPaymentButton.js.map +1 -1
- package/dist/cjs/v2/index.js +1 -1
- package/dist/constants.js +1 -1
- package/dist/{dashboard-Ba2uhKXD.js → dashboard-BP47wvu-.js} +2 -2
- package/dist/{dashboard-Ba2uhKXD.js.map → dashboard-BP47wvu-.js.map} +1 -1
- package/dist/getAddressElementOptions.js +1 -1
- package/dist/getAmountInLargestCurrencyUnit.js +1 -1
- package/dist/getAmountInSmallestCurrencyUnit.js +1 -1
- package/dist/getAmountWithAppliedTax.js +1 -1
- package/dist/getFormattedAmount.js +1 -1
- package/dist/getFormattedDiscountedAmount.js +1 -1
- package/dist/getFormattedDiscountedPercentage.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/hasAmountToPay.js +1 -1
- package/dist/{index-CajHy3NQ.js → index-CpGnAY9G.js} +2 -2
- package/dist/{index-CajHy3NQ.js.map → index-CpGnAY9G.js.map} +1 -1
- package/dist/index.js +34 -28
- package/dist/index.js.map +1 -1
- package/dist/razorpayCheckoutOutcome-ChPKzUYJ.js +91 -0
- package/dist/razorpayCheckoutOutcome-ChPKzUYJ.js.map +1 -0
- package/dist/{renderFunctions-B9mVn_ag.js → renderFunctions-CcLI5Jq6.js} +2 -2
- package/dist/{renderFunctions-B9mVn_ag.js.map → renderFunctions-CcLI5Jq6.js.map} +1 -1
- package/dist/{useAccountsApi-CZyJ4R8Z.js → useAccountsApi-DF78k_sA.js} +2 -2
- package/dist/{useAccountsApi-CZyJ4R8Z.js.map → useAccountsApi-DF78k_sA.js.map} +1 -1
- package/dist/{useBusinessTypesApi-CS2aPq7Y.js → useBusinessTypesApi-DwddCKIb.js} +2 -2
- package/dist/{useBusinessTypesApi-CS2aPq7Y.js.map → useBusinessTypesApi-DwddCKIb.js.map} +1 -1
- package/dist/{useCheckoutSettingsApi-D1ZvMA4B.js → useCheckoutSettingsApi-B29sE02j.js} +2 -2
- package/dist/{useCheckoutSettingsApi-D1ZvMA4B.js.map → useCheckoutSettingsApi-B29sE02j.js.map} +1 -1
- package/dist/{useCountriesApi-ClXgwNgC.js → useCountriesApi-CSfkzWgq.js} +2 -2
- package/dist/{useCountriesApi-ClXgwNgC.js.map → useCountriesApi-CSfkzWgq.js.map} +1 -1
- package/dist/{useExportsApi-C1wjoVYy.js → useExportsApi-BCnxSe7P.js} +2 -2
- package/dist/{useExportsApi-C1wjoVYy.js.map → useExportsApi-BCnxSe7P.js.map} +1 -1
- package/dist/{useExportsApi-DA6ThV9b.js → useExportsApi-B_ABJiMX.js} +2 -2
- package/dist/{useExportsApi-DA6ThV9b.js.map → useExportsApi-B_ABJiMX.js.map} +1 -1
- package/dist/{useFetchData-8LLdmA74.js → useFetchData-Cleas8Tk.js} +2 -2
- package/dist/{useFetchData-8LLdmA74.js.map → useFetchData-Cleas8Tk.js.map} +1 -1
- package/dist/{useIntegrationsApi-BqU-lJql.js → useIntegrationsApi-BEZaeW9w.js} +2 -2
- package/dist/{useIntegrationsApi-BqU-lJql.js.map → useIntegrationsApi-BEZaeW9w.js.map} +1 -1
- package/dist/{usePaymentApi-gvPmTOWg.js → usePaymentApi-B0BXE-4o.js} +2 -2
- package/dist/{usePaymentApi-gvPmTOWg.js.map → usePaymentApi-B0BXE-4o.js.map} +1 -1
- package/dist/{usePaymentApi-CjtkL3IU.js → usePaymentApi-BfoBBuRN.js} +2 -2
- package/dist/{usePaymentApi-CjtkL3IU.js.map → usePaymentApi-BfoBBuRN.js.map} +1 -1
- package/dist/{usePaymentsApi-C2xbgHmw.js → usePaymentsApi-Ctl1XsA1.js} +2 -2
- package/dist/{usePaymentsApi-C2xbgHmw.js.map → usePaymentsApi-Ctl1XsA1.js.map} +1 -1
- package/dist/{usePlatformApi-Dug1pxaH.js → usePlatformApi-B29AJb-p.js} +2 -2
- package/dist/{usePlatformApi-Dug1pxaH.js.map → usePlatformApi-B29AJb-p.js.map} +1 -1
- package/dist/useRazorpayPayment.js +21 -12
- package/dist/useRazorpayPayment.js.map +1 -1
- package/dist/{useRecurringPaymentsApi-dbdBrh4V.js → useRecurringPaymentsApi-B6zvIYkm.js} +2 -2
- package/dist/{useRecurringPaymentsApi-dbdBrh4V.js.map → useRecurringPaymentsApi-B6zvIYkm.js.map} +1 -1
- package/dist/{useRecurringPaymentsApi-CkxjkZd2.js → useRecurringPaymentsApi-BTOeJ8Xu.js} +2 -2
- package/dist/{useRecurringPaymentsApi-CkxjkZd2.js.map → useRecurringPaymentsApi-BTOeJ8Xu.js.map} +1 -1
- package/dist/{useRecurringSettingsApi-B_kTDES9.js → useRecurringSettingsApi-Dkjo_BKx.js} +2 -2
- package/dist/{useRecurringSettingsApi-B_kTDES9.js.map → useRecurringSettingsApi-Dkjo_BKx.js.map} +1 -1
- package/dist/{useRefundsApi-DSMKTWIQ.js → useRefundsApi-Ce4HmQgn.js} +2 -2
- package/dist/{useRefundsApi-DSMKTWIQ.js.map → useRefundsApi-Ce4HmQgn.js.map} +1 -1
- package/dist/{useSplitTransfersApi-DlRs4wYh.js → useSplitTransfersApi-CDzhSH8q.js} +2 -2
- package/dist/{useSplitTransfersApi-DlRs4wYh.js.map → useSplitTransfersApi-CDzhSH8q.js.map} +1 -1
- package/dist/{useTaxesApi-BuPeVUxI.js → useTaxesApi-CNyTbsgK.js} +2 -2
- package/dist/{useTaxesApi-BuPeVUxI.js.map → useTaxesApi-CNyTbsgK.js.map} +1 -1
- package/dist/{useVpasApi-wicZ6o_z.js → useVpasApi-X1KhsMZl.js} +2 -2
- package/dist/{useVpasApi-wicZ6o_z.js.map → useVpasApi-X1KhsMZl.js.map} +1 -1
- package/dist/v2/AccountsDashboard.js +4 -4
- package/dist/v2/AdminCancelRecurringPaymentButton.js +2 -2
- package/dist/v2/CashPaymentButton.js +2 -2
- package/dist/v2/ConfirmCashPaymentButton.js +2 -2
- package/dist/v2/CustomerCancelRecurringPaymentForm.js +2 -2
- package/dist/v2/ManualUpiConnect.js +2 -2
- package/dist/v2/ManualUpiPayment.js +2 -2
- package/dist/v2/ManualUpiPaymentConfirmButton.js +2 -2
- package/dist/v2/ManualUpiPaymentRejectButton.js +2 -2
- package/dist/v2/PaymentsDashboard.js +5 -5
- package/dist/v2/PayoutsDashboard.js +4 -4
- package/dist/v2/PayoutsPage.js +3 -3
- package/dist/v2/RazorpayConnect.js +2 -2
- package/dist/v2/RazorpayLinkedAccountForm.js +2 -2
- package/dist/v2/RazorpayPaymentButton.js +20 -11
- package/dist/v2/RazorpayPaymentButton.js.map +1 -1
- package/dist/v2/RecurringPaymentSettings.js +2 -2
- package/dist/v2/RefundsDashboard.js +5 -5
- package/dist/v2/SplitTransfersDashboard.js +4 -4
- package/dist/v2/StripeCheckoutSetting.js +2 -2
- package/dist/v2/StripeConnect.js +4 -4
- package/dist/v2/StripeManage.js +2 -2
- package/dist/v2/TaxesDashboard.js +2 -2
- package/dist/v2/index.js +23 -23
- package/package.json +14 -14
- package/dist/cjs/usePaymentApi-B198Hd_a.js +0 -21
- package/dist/cjs/usePaymentApi-B198Hd_a.js.map +0 -1
- package/dist/usePaymentApi-BzB3rzNe.js +0 -19
- package/dist/usePaymentApi-BzB3rzNe.js.map +0 -1
package/dist/StripeConnect.js
CHANGED
|
@@ -9,14 +9,14 @@ import { buildUrl } from 'neetocommons/utils';
|
|
|
9
9
|
import { Stripe } from '@bigbinary/neeto-icons/misc';
|
|
10
10
|
import CardLayout from '@bigbinary/neeto-molecules/CardLayout';
|
|
11
11
|
import { Radio, Button, Spinner, Callout, Typography } from '@bigbinary/neetoui';
|
|
12
|
-
import { u as useFetchPaymentIntegrations } from './useIntegrationsApi-
|
|
13
|
-
import { F as STRIPE_CONNECT_ENDPOINT, P as POLLING_INTERVAL, E as ERROR_TYPE, M as MAX_POLLING_TIME } from './index-
|
|
12
|
+
import { u as useFetchPaymentIntegrations } from './useIntegrationsApi-BEZaeW9w.js';
|
|
13
|
+
import { F as STRIPE_CONNECT_ENDPOINT, P as POLLING_INTERVAL, E as ERROR_TYPE, M as MAX_POLLING_TIME } from './index-CpGnAY9G.js';
|
|
14
14
|
import { t } from 'i18next';
|
|
15
15
|
import * as yup from 'yup';
|
|
16
16
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
17
17
|
import { Form, Select, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
18
|
-
import { u as useCreateStripeAccount, a as usePollingStripeAccountCreationStatus } from './useAccountsApi-
|
|
19
|
-
import { u as useFetchStripeCountries } from './useCountriesApi-
|
|
18
|
+
import { u as useCreateStripeAccount, a as usePollingStripeAccountCreationStatus } from './useAccountsApi-DF78k_sA.js';
|
|
19
|
+
import { u as useFetchStripeCountries } from './useCountriesApi-CSfkzWgq.js';
|
|
20
20
|
import { useQueryClient } from '@tanstack/react-query';
|
|
21
21
|
import { useQueryParams } from 'neetocommons/react-utils';
|
|
22
22
|
import { Q as QUERY_KEYS } from './queryConstants-8c7Nd8ML.js';
|
package/dist/StripeManage.js
CHANGED
|
@@ -5,11 +5,11 @@ import { Typography, Button } from '@bigbinary/neetoui';
|
|
|
5
5
|
import StripeCheckoutSetting from './StripeCheckoutSetting.js';
|
|
6
6
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
7
7
|
import 'react-i18next';
|
|
8
|
-
import './useCheckoutSettingsApi-
|
|
8
|
+
import './useCheckoutSettingsApi-B29sE02j.js';
|
|
9
9
|
import '@tanstack/react-query';
|
|
10
10
|
import 'ramda';
|
|
11
11
|
import 'axios';
|
|
12
|
-
import './index-
|
|
12
|
+
import './index-CpGnAY9G.js';
|
|
13
13
|
import 'i18next';
|
|
14
14
|
import 'neetocommons/constants';
|
|
15
15
|
import 'decimal.js';
|
package/dist/TaxesDashboard.js
CHANGED
|
@@ -5,7 +5,7 @@ import Header$1 from '@bigbinary/neeto-molecules/Header';
|
|
|
5
5
|
import TableWrapper from '@bigbinary/neeto-molecules/TableWrapper';
|
|
6
6
|
import { isEmpty } from 'ramda';
|
|
7
7
|
import { useTranslation, Trans } from 'react-i18next';
|
|
8
|
-
import { u as useCreateTax, a as useUpdateTax, b as useFetchTaxes, c as useDeleteTax } from './useTaxesApi-
|
|
8
|
+
import { u as useCreateTax, a as useUpdateTax, b as useFetchTaxes, c as useDeleteTax } from './useTaxesApi-CNyTbsgK.js';
|
|
9
9
|
import { Pane, Typography, Callout, Label, Spinner, Button, NoData, Table, Alert } from '@bigbinary/neetoui';
|
|
10
10
|
import { Form, Input, Radio, ActionBlock } from '@bigbinary/neetoui/formik';
|
|
11
11
|
import { t } from 'i18next';
|
|
@@ -15,7 +15,7 @@ import MoreDropdown from '@bigbinary/neeto-molecules/MoreDropdown';
|
|
|
15
15
|
import '@tanstack/react-query';
|
|
16
16
|
import 'neetocommons/react-utils';
|
|
17
17
|
import 'axios';
|
|
18
|
-
import './index-
|
|
18
|
+
import './index-CpGnAY9G.js';
|
|
19
19
|
import 'neetocommons/constants';
|
|
20
20
|
import 'decimal.js';
|
|
21
21
|
import 'neetocommons/utils';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var react = require('react');
|
|
3
4
|
var neetocist = require('neetocist');
|
|
4
5
|
var ramda = require('ramda');
|
|
5
6
|
var reactI18next = require('react-i18next');
|
|
6
|
-
var
|
|
7
|
+
var razorpayCheckoutOutcome = require('./razorpayCheckoutOutcome-DwerRK1B.js');
|
|
7
8
|
var neetoui = require('@bigbinary/neetoui');
|
|
8
9
|
var constants = require('./index-CpEnC-Gq.js');
|
|
9
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -43,11 +44,13 @@ const RazorpayPaymentButton = ({
|
|
|
43
44
|
onBeforePayment = neetocist.noop,
|
|
44
45
|
onSuccessfulPayment = neetocist.noop,
|
|
45
46
|
onFailedPayment = neetocist.noop,
|
|
47
|
+
onPaymentCreated = neetocist.noop,
|
|
46
48
|
onError = neetocist.noop
|
|
47
49
|
}) => {
|
|
48
50
|
const {
|
|
49
51
|
t
|
|
50
52
|
} = reactI18next.useTranslation();
|
|
53
|
+
const paymentRef = react.useRef(null);
|
|
51
54
|
const openRazorpayCheckout = async options => {
|
|
52
55
|
const script = await loadScript("https://checkout.razorpay.com/v1/checkout.js");
|
|
53
56
|
if (!script) {
|
|
@@ -71,16 +74,22 @@ const RazorpayPaymentButton = ({
|
|
|
71
74
|
});
|
|
72
75
|
checkout.open();
|
|
73
76
|
};
|
|
74
|
-
const handlePayment = response => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
const handlePayment = response => razorpayCheckoutOutcome.verifyCheckoutPayment({
|
|
78
|
+
payment: paymentRef.current,
|
|
79
|
+
response,
|
|
80
|
+
onSuccessfulPayment,
|
|
81
|
+
onFailedPayment
|
|
82
|
+
});
|
|
83
|
+
const handleDismiss = () => razorpayCheckoutOutcome.resolveDismissedCheckout({
|
|
84
|
+
payment: paymentRef.current,
|
|
85
|
+
onSuccessfulPayment,
|
|
86
|
+
onFailedPayment
|
|
87
|
+
});
|
|
81
88
|
const handleSuccess = ({
|
|
82
89
|
payment
|
|
83
90
|
}) => {
|
|
91
|
+
paymentRef.current = payment;
|
|
92
|
+
onPaymentCreated(payment);
|
|
84
93
|
if (payment?.status === "successful") {
|
|
85
94
|
return onSuccessfulPayment();
|
|
86
95
|
}
|
|
@@ -98,7 +107,7 @@ const RazorpayPaymentButton = ({
|
|
|
98
107
|
},
|
|
99
108
|
modal: {
|
|
100
109
|
confirm_close: true,
|
|
101
|
-
ondismiss:
|
|
110
|
+
ondismiss: handleDismiss
|
|
102
111
|
},
|
|
103
112
|
handler: handlePayment,
|
|
104
113
|
theme: {
|
|
@@ -113,7 +122,7 @@ const RazorpayPaymentButton = ({
|
|
|
113
122
|
const {
|
|
114
123
|
isPending,
|
|
115
124
|
mutate: createRazorpayOrder
|
|
116
|
-
} =
|
|
125
|
+
} = razorpayCheckoutOutcome.useCreateRazorpayPayment({
|
|
117
126
|
onSuccess: handleSuccess,
|
|
118
127
|
onError
|
|
119
128
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../../app/javascript/src/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../../app/javascript/src/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { useRef } from \"react\";\n\nimport { noop, findBy } from \"neetocist\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useCreateRazorpayPayment } from \"hooks/reactQuery/razorpay/usePaymentApi\";\nimport { Button } from \"neetoui\";\nimport { RAZORPAY_PAYMENT_BUTTON_OPTIONS } from \"src/constants\";\nimport {\n verifyCheckoutPayment,\n resolveDismissedCheckout,\n} from \"utils/razorpayCheckoutOutcome\";\n\nconst loadScript = src =>\n new Promise(resolve => {\n const script = document.createElement(\"script\");\n script.src = src;\n script.onload = () => {\n resolve(true);\n };\n\n script.onerror = () => {\n resolve(false);\n };\n document.body.appendChild(script);\n });\n\nconst RazorpayPaymentButton = ({\n label,\n payableId,\n discountCode,\n email,\n contact,\n customAmount,\n isDisabled,\n isLoading,\n name,\n tip,\n theme = {},\n isPreserveDetailsChecked = false,\n numberOfInstallments = 1,\n payableType = null,\n onBeforePayment = noop,\n onSuccessfulPayment = noop,\n onFailedPayment = noop,\n onPaymentCreated = noop,\n onError = noop,\n}) => {\n const { t } = useTranslation();\n const paymentRef = useRef(null);\n\n const openRazorpayCheckout = async options => {\n const script = await loadScript(\n \"https://checkout.razorpay.com/v1/checkout.js\"\n );\n\n if (!script) {\n logger.error(t(\"neetoPayments.razorpay.loadError\"));\n\n return;\n }\n const checkout = new window.Razorpay(options);\n\n // Listen for payment failure events to capture error details\n checkout.on(\"payment.failed\", response => {\n const errorDescription = response?.error?.description;\n const errorReason = response?.error?.reason;\n logger.error(\"Razorpay payment failed:\", {\n description: errorDescription,\n reason: errorReason,\n });\n onFailedPayment({ errorDescription, errorReason });\n });\n\n checkout.open();\n };\n\n const handlePayment = response =>\n verifyCheckoutPayment({\n payment: paymentRef.current,\n response,\n onSuccessfulPayment,\n onFailedPayment,\n });\n\n const handleDismiss = () =>\n resolveDismissedCheckout({\n payment: paymentRef.current,\n onSuccessfulPayment,\n onFailedPayment,\n });\n\n const handleSuccess = ({ payment }) => {\n paymentRef.current = payment;\n onPaymentCreated(payment);\n\n if (payment?.status === \"successful\") {\n return onSuccessfulPayment();\n }\n\n const themePrimaryColor = findBy(\n { key: \"primary_color\" },\n theme?.properties\n )?.value;\n\n const options = {\n key: payment.publicKey,\n order_id: payment.orderIdentifier,\n remember_customer: true,\n customer_id: payment.customerIdentifier,\n prefill: { name, email },\n modal: { confirm_close: true, ondismiss: handleDismiss },\n handler: handlePayment,\n theme: { color: themePrimaryColor ?? \"#0da84c\" },\n };\n\n if (isPreserveDetailsChecked) {\n options[\"recurring\"] = \"1\";\n }\n\n return openRazorpayCheckout(\n mergeDeepLeft(RAZORPAY_PAYMENT_BUTTON_OPTIONS, options)\n );\n };\n\n const { isPending, mutate: createRazorpayOrder } = useCreateRazorpayPayment({\n onSuccess: handleSuccess,\n onError,\n });\n\n const handleClick = () => {\n onBeforePayment();\n const payload = {\n payableId,\n payableType,\n discountCode,\n customAmount,\n tipAttributes: tip,\n numberOfInstallments,\n customerAttributes: { email, name, contact },\n isCardPreservingEnabled: isPreserveDetailsChecked,\n };\n createRazorpayOrder(payload);\n };\n\n return (\n <Button\n disabled={isPending || isDisabled}\n label={label || t(\"neetoPayments.common.pay\")}\n loading={isPending || isLoading}\n onClick={handleClick}\n />\n );\n};\n\nexport default RazorpayPaymentButton;\n"],"names":["loadScript","src","Promise","resolve","script","document","createElement","onload","onerror","body","appendChild","RazorpayPaymentButton","label","payableId","discountCode","email","contact","customAmount","isDisabled","isLoading","name","tip","theme","isPreserveDetailsChecked","numberOfInstallments","payableType","onBeforePayment","noop","onSuccessfulPayment","onFailedPayment","onPaymentCreated","onError","t","useTranslation","paymentRef","useRef","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","on","response","errorDescription","description","errorReason","reason","open","handlePayment","verifyCheckoutPayment","payment","current","handleDismiss","resolveDismissedCheckout","handleSuccess","status","themePrimaryColor","findBy","key","properties","value","publicKey","order_id","orderIdentifier","remember_customer","customer_id","customerIdentifier","prefill","modal","confirm_close","ondismiss","handler","color","mergeDeepLeft","RAZORPAY_PAYMENT_BUTTON_OPTIONS","isPending","mutate","createRazorpayOrder","useCreateRazorpayPayment","onSuccess","handleClick","payload","tipAttributes","customerAttributes","isCardPreservingEnabled","_jsx","Button","disabled","loading","onClick"],"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAMA,UAAU,GAAGC,GAAG,IACpB,IAAIC,OAAO,CAACC,OAAO,IAAI;AACrB,EAAA,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/CF,MAAM,CAACH,GAAG,GAAGA,GAAG;EAChBG,MAAM,CAACG,MAAM,GAAG,MAAM;IACpBJ,OAAO,CAAC,IAAI,CAAC;EACf,CAAC;EAEDC,MAAM,CAACI,OAAO,GAAG,MAAM;IACrBL,OAAO,CAAC,KAAK,CAAC;EAChB,CAAC;AACDE,EAAAA,QAAQ,CAACI,IAAI,CAACC,WAAW,CAACN,MAAM,CAAC;AACnC,CAAC,CAAC;AAEJ,MAAMO,qBAAqB,GAAGA,CAAC;EAC7BC,KAAK;EACLC,SAAS;EACTC,YAAY;EACZC,KAAK;EACLC,OAAO;EACPC,YAAY;EACZC,UAAU;EACVC,SAAS;EACTC,IAAI;EACJC,GAAG;EACHC,KAAK,GA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,oBAAoB,CACzBuC,mBAAa,CAACC,yCAA+B,EAAEvC,OAAO,CACxD,CAAC;EACH,CAAC;EAED,MAAM;IAAEwC,SAAS;AAAEC,IAAAA,MAAM,EAAEC;GAAqB,GAAGC,gDAAwB,CAAC;AAC1EC,IAAAA,SAAS,EAAEzB,aAAa;AACxBzB,IAAAA;AACF,GAAC,CAAC;EAEF,MAAMmD,WAAW,GAAGA,MAAM;AACxBxD,IAAAA,eAAe,EAAE;AACjB,IAAA,MAAMyD,OAAO,GAAG;MACdtE,SAAS;MACTY,WAAW;MACXX,YAAY;MACZG,YAAY;AACZmE,MAAAA,aAAa,EAAE/D,GAAG;MAClBG,oBAAoB;AACpB6D,MAAAA,kBAAkB,EAAE;QAAEtE,KAAK;QAAEK,IAAI;AAAEJ,QAAAA;OAAS;AAC5CsE,MAAAA,uBAAuB,EAAE/D;KAC1B;IACDwD,mBAAmB,CAACI,OAAO,CAAC;EAC9B,CAAC;EAED,oBACEI,cAAA,CAACC,cAAM,EAAA;IACLC,QAAQ,EAAEZ,SAAS,IAAI3D,UAAW;AAClCN,IAAAA,KAAK,EAAEA,KAAK,IAAIoB,CAAC,CAAC,0BAA0B,CAAE;IAC9C0D,OAAO,EAAEb,SAAS,IAAI1D,SAAU;AAChCwE,IAAAA,OAAO,EAAET;AAAY,GACtB,CAAC;AAEN;;;;"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var razorpayCheckoutOutcome = require('./razorpayCheckoutOutcome-DwerRK1B.js');
|
|
3
4
|
var AccountsDashboard = require('./AccountsDashboard.js');
|
|
4
5
|
var AdminCancelRecurringPaymentButton = require('./AdminCancelRecurringPaymentButton.js');
|
|
5
6
|
var CashPaymentButton = require('./CashPaymentButton.js');
|
|
@@ -28,9 +29,11 @@ var useRazorpayPayment = require('./useRazorpayPayment.js');
|
|
|
28
29
|
var useStripePromise = require('./useStripePromise.js');
|
|
29
30
|
var constants = require('./index-CpEnC-Gq.js');
|
|
30
31
|
require('./main-BnTRneCH.js');
|
|
32
|
+
require('@tanstack/react-query');
|
|
33
|
+
require('neetocist');
|
|
34
|
+
require('axios');
|
|
31
35
|
require('react');
|
|
32
36
|
require('i18next');
|
|
33
|
-
require('neetocist');
|
|
34
37
|
require('neetocommons/react-utils');
|
|
35
38
|
require('@bigbinary/neeto-filters-frontend');
|
|
36
39
|
require('@bigbinary/neeto-molecules/Header');
|
|
@@ -38,11 +41,9 @@ require('@bigbinary/neeto-molecules/SubHeader');
|
|
|
38
41
|
require('@bigbinary/neetoui');
|
|
39
42
|
require('react-i18next');
|
|
40
43
|
require('./useExportsApi-CupgYUpS.js');
|
|
41
|
-
require('@tanstack/react-query');
|
|
42
44
|
require('@tanstack/react-query-devtools');
|
|
43
45
|
require('neetocommons/constants');
|
|
44
46
|
require('react/jsx-runtime');
|
|
45
|
-
require('axios');
|
|
46
47
|
require('./exportChannel-BL2RGGhP.js');
|
|
47
48
|
require('neetocommons/utils');
|
|
48
49
|
require('@bigbinary/neeto-icons');
|
|
@@ -59,6 +60,7 @@ require('@bigbinary/neeto-molecules/TableWrapper');
|
|
|
59
60
|
require('./useAccountsApi-DaOq20gj.js');
|
|
60
61
|
require('./queryConstants-CGUF7zol.js');
|
|
61
62
|
require('./useRecurringPaymentsApi-Dow6RjiT.js');
|
|
63
|
+
require('decimal.js');
|
|
62
64
|
require('./usePaymentApi-DZYqqfhc.js');
|
|
63
65
|
require('@bigbinary/neetoui/formik');
|
|
64
66
|
require('./useRecurringPaymentsApi-DQpypVjt.js');
|
|
@@ -82,7 +84,6 @@ require('@bigbinary/neeto-molecules/Container');
|
|
|
82
84
|
require('./useIntegrationsApi-CNrrE2OH.js');
|
|
83
85
|
require('@bigbinary/neeto-molecules/PhoneNumber');
|
|
84
86
|
require('./useBusinessTypesApi-D_td8mux.js');
|
|
85
|
-
require('./usePaymentApi-B198Hd_a.js');
|
|
86
87
|
require('neetocommons/initializers');
|
|
87
88
|
require('./useRecurringSettingsApi-CDA5wZnB.js');
|
|
88
89
|
require('./useRefundsApi-enBsXWAk.js');
|
|
@@ -92,9 +93,10 @@ require('./useCheckoutSettingsApi-fGVkfRBQ.js');
|
|
|
92
93
|
require('dompurify');
|
|
93
94
|
require('./useCountriesApi-CWsN_NIT.js');
|
|
94
95
|
require('./useTaxesApi-BBinhUYT.js');
|
|
95
|
-
require('decimal.js');
|
|
96
|
-
|
|
97
96
|
|
|
97
|
+
// For host-side recovery flows (e.g. mobile full-page-redirect return) that
|
|
98
|
+
// must check whether money was captured before declaring a payment failed.
|
|
99
|
+
const verifyRazorpayPayment = razorpayCheckoutOutcome.paymentsApi.verify;
|
|
98
100
|
|
|
99
101
|
exports.AccountsDashboard = AccountsDashboard;
|
|
100
102
|
exports.AdminCancelRecurringPaymentButton = AdminCancelRecurringPaymentButton;
|
|
@@ -137,4 +139,5 @@ exports.getQrCodeValue = constants.getQrCodeValue;
|
|
|
137
139
|
exports.getTaxAmount = constants.getTaxAmount;
|
|
138
140
|
exports.getTipAmount = constants.getTipAmount;
|
|
139
141
|
exports.hasAmountToPay = constants.hasAmountToPay;
|
|
142
|
+
exports.verifyRazorpayPayment = verifyRazorpayPayment;
|
|
140
143
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../index.js"],"sourcesContent":["import razorpayPaymentsApi from \"apis/razorpay/payments\";\nimport AccountsDashboard from \"components/AccountsDashboard\";\nimport AdminCancelRecurringPaymentButton from \"components/AdminCancelRecurringPaymentButton\";\nimport CashPaymentButton from \"components/CashPaymentButton\";\nimport ConfirmCashPaymentButton from \"components/ConfirmCashPaymentButton\";\nimport CustomerCancelRecurringPaymentForm from \"components/CustomerCancelRecurringPaymentForm\";\nimport ManualUpiConnect from \"components/ManualUpiConnect\";\nimport ManualUpiPayment from \"components/ManualUpiPayment\";\nimport ManualUpiPaymentConfirmButton from \"components/ManualUpiPaymentConfirmButton\";\nimport ManualUpiPaymentRejectButton from \"components/ManualUpiPaymentRejectButton\";\nimport PaymentKindRestrictionAlert from \"components/PaymentKindRestrictionAlert\";\nimport PaymentsDashboard from \"components/PaymentsDashboard\";\nimport PayoutsDashboard from \"components/PayoutsDashboard\";\nimport PayoutsPage from \"components/PayoutsPage\";\nimport RazorpayConnect from \"components/RazorpayConnect\";\nimport RazorpayLinkedAccountForm from \"components/RazorpayLinkedAccountForm\";\nimport RazorpayPaymentButton from \"components/RazorpayPaymentButton\";\nimport RazorpayWebsiteNotice from \"components/RazorpayWebsiteNotice\";\nimport RecurringPaymentSettings from \"components/RecurringPaymentSettings\";\nimport RefundsDashboard from \"components/RefundsDashboard\";\nimport SplitTransfersDashboard from \"components/SplitTransfersDashboard\";\nimport StripeCheckoutSetting from \"components/StripeCheckoutSetting\";\nimport StripeConnect from \"components/StripeConnect\";\nimport StripeManage from \"components/StripeManage\";\nimport TaxesDashboard from \"components/TaxesDashboard\";\nimport useRazorpayPayment from \"hooks/useRazorpayPayment\";\nimport useStripePromise from \"hooks/useStripePromise\";\nimport { CURRENCY_OPTIONS } from \"src/constants\";\nimport {\n buildStripeTransactionLink,\n getTaxAmount,\n getAmountWithAppliedTax,\n getQrCodeValue,\n getAmountInSmallestCurrencyUnit,\n getAmountInLargestCurrencyUnit,\n getFormattedAmount,\n getTipAmount,\n getFormattedTipAmount,\n getFormattedTaxAmount,\n getAddressElementOptions,\n getFormattedDiscountedPercentage,\n hasAmountToPay,\n getFormattedDiscountedAmount,\n} from \"utils\";\n\nimport \"./app/javascript/src/stylesheets/main.css\";\n\n// For host-side recovery flows (e.g. mobile full-page-redirect return) that\n// must check whether money was captured before declaring a payment failed.\nconst verifyRazorpayPayment = razorpayPaymentsApi.verify;\n\nexport {\n // Dashboards\n StripeConnect,\n StripeManage,\n StripeCheckoutSetting,\n AccountsDashboard,\n PayoutsDashboard,\n PaymentsDashboard,\n RefundsDashboard,\n SplitTransfersDashboard,\n RazorpayConnect,\n RazorpayWebsiteNotice,\n // Hooks\n useStripePromise,\n useRazorpayPayment,\n // Components\n RecurringPaymentSettings,\n PayoutsPage,\n PaymentKindRestrictionAlert,\n RazorpayPaymentButton,\n ManualUpiConnect,\n ManualUpiPayment,\n ConfirmCashPaymentButton,\n CashPaymentButton,\n ManualUpiPaymentConfirmButton,\n ManualUpiPaymentRejectButton,\n TaxesDashboard,\n AdminCancelRecurringPaymentButton,\n CustomerCancelRecurringPaymentForm,\n RazorpayLinkedAccountForm,\n // utils\n buildStripeTransactionLink,\n getAmountInSmallestCurrencyUnit,\n getAmountInLargestCurrencyUnit,\n getTaxAmount,\n getAmountWithAppliedTax,\n getFormattedAmount,\n getTipAmount,\n getFormattedTipAmount,\n getFormattedTaxAmount,\n getFormattedDiscountedAmount,\n getFormattedDiscountedPercentage,\n hasAmountToPay,\n getQrCodeValue,\n getAddressElementOptions,\n verifyRazorpayPayment,\n // constants\n CURRENCY_OPTIONS,\n};\n"],"names":["verifyRazorpayPayment","razorpayPaymentsApi","verify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA;AACA;AACA,MAAMA,qBAAqB,GAAGC,mCAAmB,CAACC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactQuery = require('@tanstack/react-query');
|
|
4
|
+
var neetocist = require('neetocist');
|
|
5
|
+
var axios = require('axios');
|
|
6
|
+
var constants = require('./index-CpEnC-Gq.js');
|
|
7
|
+
|
|
8
|
+
const create = payload => axios.post(`${constants.BASE_URL}/api/v1/public/razorpay/payments`, {
|
|
9
|
+
payment: payload
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
// Server-side confirmation against Razorpay's API — webhook delivery is
|
|
13
|
+
// per-account and unreliable, so checkout completion must not depend on it.
|
|
14
|
+
// razorpayPaymentId is optional: without it the server checks the payment's
|
|
15
|
+
// order for a captured attempt (dismiss/recovery flows). Errors are silent
|
|
16
|
+
// (showToastr: false) — the backend self-verify job is the correctness net;
|
|
17
|
+
// this call is a latency optimization for the waiting customer.
|
|
18
|
+
const verify = (paymentId, payload = {}) => axios.post(`${constants.BASE_URL}/api/v1/public/razorpay/payments/${paymentId}/verify`, {
|
|
19
|
+
payment: payload
|
|
20
|
+
}, {
|
|
21
|
+
showToastr: false
|
|
22
|
+
});
|
|
23
|
+
const defaultList = payload => axios.get(`${constants.BASE_URL}/api/v1/razorpay/holdable/payments`, {
|
|
24
|
+
params: payload
|
|
25
|
+
});
|
|
26
|
+
const list = (holdableId, payload) => axios.get(`${constants.BASE_URL}/api/v1/razorpay/holdables/${holdableId}/payments`, {
|
|
27
|
+
params: payload
|
|
28
|
+
});
|
|
29
|
+
const paymentsApi = {
|
|
30
|
+
defaultList,
|
|
31
|
+
list,
|
|
32
|
+
create,
|
|
33
|
+
verify
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const useCreateRazorpayPayment = options => reactQuery.useMutation({
|
|
37
|
+
mutationFn: paymentsApi.create,
|
|
38
|
+
...options
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Confirms server-side against Razorpay's API instead of relying on webhook
|
|
42
|
+
// delivery (per-account, silently unreliable). The success callback fires
|
|
43
|
+
// regardless of the verify outcome — the backend self-verify job is the
|
|
44
|
+
// correctness net, so a failed/slow verify must never strand the customer.
|
|
45
|
+
const verifyCheckoutPayment = async ({
|
|
46
|
+
payment,
|
|
47
|
+
response,
|
|
48
|
+
onSuccessfulPayment,
|
|
49
|
+
onFailedPayment
|
|
50
|
+
}) => {
|
|
51
|
+
if (neetocist.isNotPresent(response?.razorpay_signature)) {
|
|
52
|
+
onFailedPayment();
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
if (payment?.id) {
|
|
57
|
+
await paymentsApi.verify(payment.id, {
|
|
58
|
+
razorpayPaymentId: response.razorpay_payment_id
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
} catch {
|
|
62
|
+
// Silent: self-verify job completes the confirmation asynchronously.
|
|
63
|
+
} finally {
|
|
64
|
+
onSuccessfulPayment();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
// Dismiss can fire after money was captured (UPI intent app-switch glitches)
|
|
69
|
+
// — ask the server to check the order before declaring failure.
|
|
70
|
+
const resolveDismissedCheckout = async ({
|
|
71
|
+
payment: localPayment,
|
|
72
|
+
onSuccessfulPayment,
|
|
73
|
+
onFailedPayment
|
|
74
|
+
}) => {
|
|
75
|
+
if (localPayment?.id) {
|
|
76
|
+
try {
|
|
77
|
+
// Host axios interceptors resolve with response.data directly.
|
|
78
|
+
const {
|
|
79
|
+
payment
|
|
80
|
+
} = await paymentsApi.verify(localPayment.id);
|
|
81
|
+
if (payment?.status === "successful") {
|
|
82
|
+
onSuccessfulPayment();
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
} catch {
|
|
86
|
+
// Fall through to the failure callback.
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
onFailedPayment();
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
exports.paymentsApi = paymentsApi;
|
|
93
|
+
exports.resolveDismissedCheckout = resolveDismissedCheckout;
|
|
94
|
+
exports.useCreateRazorpayPayment = useCreateRazorpayPayment;
|
|
95
|
+
exports.verifyCheckoutPayment = verifyCheckoutPayment;
|
|
96
|
+
//# sourceMappingURL=razorpayCheckoutOutcome-DwerRK1B.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"razorpayCheckoutOutcome-DwerRK1B.js","sources":["../../app/javascript/src/apis/razorpay/payments.js","../../app/javascript/src/hooks/reactQuery/razorpay/usePaymentApi.js","../../app/javascript/src/utils/razorpayCheckoutOutcome.js"],"sourcesContent":["import axios from \"axios\";\n\nimport { BASE_URL } from \"src/constants\";\n\nconst create = payload =>\n axios.post(`${BASE_URL}/api/v1/public/razorpay/payments`, {\n payment: payload,\n });\n\n// Server-side confirmation against Razorpay's API — webhook delivery is\n// per-account and unreliable, so checkout completion must not depend on it.\n// razorpayPaymentId is optional: without it the server checks the payment's\n// order for a captured attempt (dismiss/recovery flows). Errors are silent\n// (showToastr: false) — the backend self-verify job is the correctness net;\n// this call is a latency optimization for the waiting customer.\nconst verify = (paymentId, payload = {}) =>\n axios.post(\n `${BASE_URL}/api/v1/public/razorpay/payments/${paymentId}/verify`,\n { payment: payload },\n { showToastr: false }\n );\n\nconst defaultList = payload =>\n axios.get(`${BASE_URL}/api/v1/razorpay/holdable/payments`, {\n params: payload,\n });\n\nconst list = (holdableId, payload) =>\n axios.get(`${BASE_URL}/api/v1/razorpay/holdables/${holdableId}/payments`, {\n params: payload,\n });\n\nconst paymentsApi = { defaultList, list, create, verify };\n\nexport default paymentsApi;\n","import { useQuery, useMutation } from \"@tanstack/react-query\";\nimport { isPresent } from \"neetocist\";\n\nimport paymentsApi from \"apis/razorpay/payments\";\nimport { QUERY_KEYS } from \"src/common/queryConstants\";\n\nexport const useFetchRazorpayPayments = (\n holdableId = \"\",\n payload = {},\n options = {}\n) =>\n useQuery({\n queryKey: [QUERY_KEYS.RAZORPAY_ACCOUNT_DETAILS, payload],\n queryFn: () => {\n if (isPresent(holdableId)) return paymentsApi.list(holdableId, payload);\n\n return paymentsApi.defaultList(payload);\n },\n ...options,\n });\n\nexport const useCreateRazorpayPayment = options =>\n useMutation({ mutationFn: paymentsApi.create, ...options });\n","import { isNotPresent } from \"neetocist\";\n\nimport paymentsApi from \"apis/razorpay/payments\";\n\n// Confirms server-side against Razorpay's API instead of relying on webhook\n// delivery (per-account, silently unreliable). The success callback fires\n// regardless of the verify outcome — the backend self-verify job is the\n// correctness net, so a failed/slow verify must never strand the customer.\nexport const verifyCheckoutPayment = async ({\n payment,\n response,\n onSuccessfulPayment,\n onFailedPayment,\n}) => {\n if (isNotPresent(response?.razorpay_signature)) {\n onFailedPayment();\n\n return;\n }\n\n try {\n if (payment?.id) {\n await paymentsApi.verify(payment.id, {\n razorpayPaymentId: response.razorpay_payment_id,\n });\n }\n } catch {\n // Silent: self-verify job completes the confirmation asynchronously.\n } finally {\n onSuccessfulPayment();\n }\n};\n\n// Dismiss can fire after money was captured (UPI intent app-switch glitches)\n// — ask the server to check the order before declaring failure.\nexport const resolveDismissedCheckout = async ({\n payment: localPayment,\n onSuccessfulPayment,\n onFailedPayment,\n}) => {\n if (localPayment?.id) {\n try {\n // Host axios interceptors resolve with response.data directly.\n const { payment } = await paymentsApi.verify(localPayment.id);\n if (payment?.status === \"successful\") {\n onSuccessfulPayment();\n\n return;\n }\n } catch {\n // Fall through to the failure callback.\n }\n }\n\n onFailedPayment();\n};\n"],"names":["create","payload","axios","post","BASE_URL","payment","verify","paymentId","showToastr","defaultList","get","params","list","holdableId","paymentsApi","useCreateRazorpayPayment","options","useMutation","mutationFn","verifyCheckoutPayment","response","onSuccessfulPayment","onFailedPayment","isNotPresent","razorpay_signature","id","razorpayPaymentId","razorpay_payment_id","resolveDismissedCheckout","localPayment","status"],"mappings":";;;;;;;AAIA,MAAMA,MAAM,GAAGC,OAAO,IACpBC,KAAK,CAACC,IAAI,CAAC,CAAA,EAAGC,kBAAQ,CAAA,gCAAA,CAAkC,EAAE;AACxDC,EAAAA,OAAO,EAAEJ;AACX,CAAC,CAAC;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,MAAM,GAAGA,CAACC,SAAS,EAAEN,OAAO,GAAG,EAAE,KACrCC,KAAK,CAACC,IAAI,CACR,CAAA,EAAGC,kBAAQ,CAAA,iCAAA,EAAoCG,SAAS,SAAS,EACjE;AAAEF,EAAAA,OAAO,EAAEJ;AAAQ,CAAC,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BR,mBAAmB;AACnBC,EAAAA;AACF,CAAC,KAAK;EACJ,IAAIO,YAAY,EAAEJ,EAAE,EAAE;IACpB,IAAI;AACF;MACA,MAAM;AAAEpB,QAAAA;OAAS,GAAG,MAAMS,WAAW,CAACR,MAAM,CAACuB,YAAY,CAACJ,EAAE,CAAC;AAC7D,MAAA,IAAIpB,OAAO,EAAEyB,MAAM,KAAK,YAAY,EAAE;AACpCT,QAAAA,mBAAmB,EAAE;AAErB,QAAA;AACF,MAAA;AACF,IAAA,CAAC,CAAC,MAAM;AACN;AAAA,IAAA;AAEJ,EAAA;AAEAC,EAAAA,eAAe,EAAE;AACnB;;;;;;;"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var react = require('react');
|
|
3
4
|
var neetocist = require('neetocist');
|
|
4
5
|
var ramda = require('ramda');
|
|
5
6
|
var reactI18next = require('react-i18next');
|
|
6
|
-
var
|
|
7
|
+
var razorpayCheckoutOutcome = require('./razorpayCheckoutOutcome-DwerRK1B.js');
|
|
7
8
|
var constants = require('./index-CpEnC-Gq.js');
|
|
8
9
|
require('@tanstack/react-query');
|
|
9
10
|
require('axios');
|
|
@@ -28,11 +29,13 @@ const useRazorpayPayment = ({
|
|
|
28
29
|
customAmount = null,
|
|
29
30
|
onBeforePayment = neetocist.noop,
|
|
30
31
|
onSuccessfulPayment = neetocist.noop,
|
|
31
|
-
onFailedPayment = neetocist.noop
|
|
32
|
+
onFailedPayment = neetocist.noop,
|
|
33
|
+
onPaymentCreated = neetocist.noop
|
|
32
34
|
}) => {
|
|
33
35
|
const {
|
|
34
36
|
t
|
|
35
37
|
} = reactI18next.useTranslation();
|
|
38
|
+
const paymentRef = react.useRef(null);
|
|
36
39
|
const openRazorpayCheckout = async options => {
|
|
37
40
|
const script = await loadScript("https://checkout.razorpay.com/v1/checkout.js");
|
|
38
41
|
if (!script) {
|
|
@@ -42,16 +45,22 @@ const useRazorpayPayment = ({
|
|
|
42
45
|
const checkout = new window.Razorpay(options);
|
|
43
46
|
checkout.open();
|
|
44
47
|
};
|
|
45
|
-
const handlePayment = response => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
const handlePayment = response => razorpayCheckoutOutcome.verifyCheckoutPayment({
|
|
49
|
+
payment: paymentRef.current,
|
|
50
|
+
response,
|
|
51
|
+
onSuccessfulPayment,
|
|
52
|
+
onFailedPayment
|
|
53
|
+
});
|
|
54
|
+
const handleDismiss = () => razorpayCheckoutOutcome.resolveDismissedCheckout({
|
|
55
|
+
payment: paymentRef.current,
|
|
56
|
+
onSuccessfulPayment,
|
|
57
|
+
onFailedPayment
|
|
58
|
+
});
|
|
52
59
|
const handleSuccess = ({
|
|
53
60
|
payment
|
|
54
61
|
}) => {
|
|
62
|
+
paymentRef.current = payment;
|
|
63
|
+
onPaymentCreated(payment);
|
|
55
64
|
if (payment?.status === "successful") {
|
|
56
65
|
return onSuccessfulPayment();
|
|
57
66
|
}
|
|
@@ -61,7 +70,7 @@ const useRazorpayPayment = ({
|
|
|
61
70
|
customer_id: payment.customerIdentifier,
|
|
62
71
|
modal: {
|
|
63
72
|
confirm_close: true,
|
|
64
|
-
ondismiss:
|
|
73
|
+
ondismiss: handleDismiss
|
|
65
74
|
},
|
|
66
75
|
handler: handlePayment
|
|
67
76
|
};
|
|
@@ -69,7 +78,7 @@ const useRazorpayPayment = ({
|
|
|
69
78
|
};
|
|
70
79
|
const {
|
|
71
80
|
mutate: createRazorpayOrder
|
|
72
|
-
} =
|
|
81
|
+
} = razorpayCheckoutOutcome.useCreateRazorpayPayment({
|
|
73
82
|
onSuccess: handleSuccess
|
|
74
83
|
});
|
|
75
84
|
const makePayment = () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRazorpayPayment.js","sources":["../../app/javascript/src/hooks/useRazorpayPayment.js"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"useRazorpayPayment.js","sources":["../../app/javascript/src/hooks/useRazorpayPayment.js"],"sourcesContent":["import { useRef } from \"react\";\n\nimport { noop } from \"neetocist\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useCreateRazorpayPayment } from \"hooks/reactQuery/razorpay/usePaymentApi\";\nimport { RAZORPAY_PAYMENT_BUTTON_OPTIONS } from \"src/constants\";\nimport {\n verifyCheckoutPayment,\n resolveDismissedCheckout,\n} from \"utils/razorpayCheckoutOutcome\";\n\nconst loadScript = src =>\n new Promise(resolve => {\n const script = document.createElement(\"script\");\n script.src = src;\n script.onload = () => {\n resolve(true);\n };\n\n script.onerror = () => {\n resolve(false);\n };\n document.body.appendChild(script);\n });\n\nconst useRazorpayPayment = ({\n payableId,\n customAmount = null,\n onBeforePayment = noop,\n onSuccessfulPayment = noop,\n onFailedPayment = noop,\n onPaymentCreated = noop,\n}) => {\n const { t } = useTranslation();\n const paymentRef = useRef(null);\n\n const openRazorpayCheckout = async options => {\n const script = await loadScript(\n \"https://checkout.razorpay.com/v1/checkout.js\"\n );\n\n if (!script) {\n logger.error(t(\"neetoPayments.razorpay.loadError\"));\n\n return;\n }\n const checkout = new window.Razorpay(options);\n checkout.open();\n };\n\n const handlePayment = response =>\n verifyCheckoutPayment({\n payment: paymentRef.current,\n response,\n onSuccessfulPayment,\n onFailedPayment,\n });\n\n const handleDismiss = () =>\n resolveDismissedCheckout({\n payment: paymentRef.current,\n onSuccessfulPayment,\n onFailedPayment,\n });\n\n const handleSuccess = ({ payment }) => {\n paymentRef.current = payment;\n onPaymentCreated(payment);\n\n if (payment?.status === \"successful\") {\n return onSuccessfulPayment();\n }\n\n const options = {\n key: payment.publicKey,\n order_id: payment.orderIdentifier,\n customer_id: payment.customerIdentifier,\n modal: { confirm_close: true, ondismiss: handleDismiss },\n handler: handlePayment,\n };\n\n return openRazorpayCheckout(\n mergeDeepLeft(RAZORPAY_PAYMENT_BUTTON_OPTIONS, options)\n );\n };\n\n const { mutate: createRazorpayOrder } = useCreateRazorpayPayment({\n onSuccess: handleSuccess,\n });\n\n const makePayment = () => {\n onBeforePayment();\n createRazorpayOrder({ payableId, customAmount });\n };\n\n return { makePayment };\n};\n\nexport default useRazorpayPayment;\n"],"names":["loadScript","src","Promise","resolve","script","document","createElement","onload","onerror","body","appendChild","useRazorpayPayment","payableId","customAmount","onBeforePayment","noop","onSuccessfulPayment","onFailedPayment","onPaymentCreated","t","useTranslation","paymentRef","useRef","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","open","handlePayment","response","verifyCheckoutPayment","payment","current","handleDismiss","resolveDismissedCheckout","handleSuccess","status","key","publicKey","order_id","orderIdentifier","customer_id","customerIdentifier","modal","confirm_close","ondismiss","handler","mergeDeepLeft","RAZORPAY_PAYMENT_BUTTON_OPTIONS","mutate","createRazorpayOrder","useCreateRazorpayPayment","onSuccess","makePayment"],"mappings":";;;;;;;;;;;;;;;AAaA,MAAMA,UAAU,GAAGC,GAAG,IACpB,IAAIC,OAAO,CAACC,OAAO,IAAI;AACrB,EAAA,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/CF,MAAM,CAACH,GAAG,GAAGA,GAAG;EAChBG,MAAM,CAACG,MAAM,GAAG,MAAM;IACpBJ,OAAO,CAAC,IAAI,CAAC;EACf,CAAC;EAEDC,MAAM,CAACI,OAAO,GAAG,MAAM;IACrBL,OAAO,CAAC,KAAK,CAAC;EAChB,CAAC;AACDE,EAAAA,QAAQ,CAACI,IAAI,CAACC,WAAW,CAACN,MAAM,CAAC;AACnC,CAAC,CAAC;AAEJ,MAAMO,kBAAkB,GAAGA,CAAC;EAC1BC,SAAS;AACTC,EAAAA,YAAY,GAAG,IAAI;AACnBC,EAAAA,eAAe,GAAGC,cAAI;AACtBC,EAAAA,mBAAmB,GAAGD,cAAI;AAC1BE,EAAAA,eAAe,GAAGF,cAAI;AACtBG,EAAAA,gBAAgB,GAAGH;AACrB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Aa,EAAE,IAAI;AAAEC,QAAAA,SAAS,EAAEZ;OAAe;AACxDa,MAAAA,OAAO,EAAElB;KACV;IAED,OAAOR,oBAAoB,CACzB2B,mBAAa,CAACC,yCAA+B,EAAE3B,OAAO,CACxD,CAAC;EACH,CAAC;EAED,MAAM;AAAE4B,IAAAA,MAAM,EAAEC;GAAqB,GAAGC,gDAAwB,CAAC;AAC/DC,IAAAA,SAAS,EAAEjB;AACb,GAAC,CAAC;EAEF,MAAMkB,WAAW,GAAGA,MAAM;AACxB1C,IAAAA,eAAe,EAAE;AACjBuC,IAAAA,mBAAmB,CAAC;MAAEzC,SAAS;AAAEC,MAAAA;AAAa,KAAC,CAAC;EAClD,CAAC;EAED,OAAO;AAAE2C,IAAAA;GAAa;AACxB;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var react = require('react');
|
|
3
4
|
var neetoAtoms = require('@bigbinary/neeto-atoms');
|
|
4
5
|
var neetocist = require('neetocist');
|
|
5
6
|
var ramda = require('ramda');
|
|
6
7
|
var reactI18next = require('react-i18next');
|
|
7
|
-
var
|
|
8
|
+
var razorpayCheckoutOutcome = require('../razorpayCheckoutOutcome-DwerRK1B.js');
|
|
8
9
|
var constants = require('../index-CpEnC-Gq.js');
|
|
9
10
|
var jsxRuntime = require('react/jsx-runtime');
|
|
10
11
|
require('@tanstack/react-query');
|
|
@@ -43,11 +44,13 @@ const RazorpayPaymentButton = ({
|
|
|
43
44
|
onBeforePayment = neetocist.noop,
|
|
44
45
|
onSuccessfulPayment = neetocist.noop,
|
|
45
46
|
onFailedPayment = neetocist.noop,
|
|
47
|
+
onPaymentCreated = neetocist.noop,
|
|
46
48
|
onError = neetocist.noop
|
|
47
49
|
}) => {
|
|
48
50
|
const {
|
|
49
51
|
t
|
|
50
52
|
} = reactI18next.useTranslation();
|
|
53
|
+
const paymentRef = react.useRef(null);
|
|
51
54
|
const openRazorpayCheckout = async options => {
|
|
52
55
|
const script = await loadScript("https://checkout.razorpay.com/v1/checkout.js");
|
|
53
56
|
if (!script) {
|
|
@@ -69,16 +72,22 @@ const RazorpayPaymentButton = ({
|
|
|
69
72
|
});
|
|
70
73
|
checkout.open();
|
|
71
74
|
};
|
|
72
|
-
const handlePayment = response => {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const handlePayment = response => razorpayCheckoutOutcome.verifyCheckoutPayment({
|
|
76
|
+
payment: paymentRef.current,
|
|
77
|
+
response,
|
|
78
|
+
onSuccessfulPayment,
|
|
79
|
+
onFailedPayment
|
|
80
|
+
});
|
|
81
|
+
const handleDismiss = () => razorpayCheckoutOutcome.resolveDismissedCheckout({
|
|
82
|
+
payment: paymentRef.current,
|
|
83
|
+
onSuccessfulPayment,
|
|
84
|
+
onFailedPayment
|
|
85
|
+
});
|
|
79
86
|
const handleSuccess = ({
|
|
80
87
|
payment
|
|
81
88
|
}) => {
|
|
89
|
+
paymentRef.current = payment;
|
|
90
|
+
onPaymentCreated(payment);
|
|
82
91
|
if (payment?.status === "successful") {
|
|
83
92
|
return onSuccessfulPayment();
|
|
84
93
|
}
|
|
@@ -96,7 +105,7 @@ const RazorpayPaymentButton = ({
|
|
|
96
105
|
},
|
|
97
106
|
modal: {
|
|
98
107
|
confirm_close: true,
|
|
99
|
-
ondismiss:
|
|
108
|
+
ondismiss: handleDismiss
|
|
100
109
|
},
|
|
101
110
|
handler: handlePayment,
|
|
102
111
|
theme: {
|
|
@@ -111,7 +120,7 @@ const RazorpayPaymentButton = ({
|
|
|
111
120
|
const {
|
|
112
121
|
isPending,
|
|
113
122
|
mutate: createRazorpayOrder
|
|
114
|
-
} =
|
|
123
|
+
} = razorpayCheckoutOutcome.useCreateRazorpayPayment({
|
|
115
124
|
onSuccess: handleSuccess,
|
|
116
125
|
onError
|
|
117
126
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../../../app/javascript/src/v2/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { Button } from \"@bigbinary/neeto-atoms\";\nimport {
|
|
1
|
+
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../../../app/javascript/src/v2/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { useRef } from \"react\";\n\nimport { Button } from \"@bigbinary/neeto-atoms\";\nimport { noop, findBy } from \"neetocist\";\nimport { mergeDeepLeft } from \"ramda\";\nimport { useTranslation } from \"react-i18next\";\n\nimport { useCreateRazorpayPayment } from \"hooks/reactQuery/razorpay/usePaymentApi\";\nimport { RAZORPAY_PAYMENT_BUTTON_OPTIONS } from \"src/constants\";\nimport {\n verifyCheckoutPayment,\n resolveDismissedCheckout,\n} from \"utils/razorpayCheckoutOutcome\";\n\nconst loadScript = src =>\n new Promise(resolve => {\n const script = document.createElement(\"script\");\n script.src = src;\n script.onload = () => {\n resolve(true);\n };\n\n script.onerror = () => {\n resolve(false);\n };\n document.body.appendChild(script);\n });\n\nconst RazorpayPaymentButton = ({\n label,\n payableId,\n discountCode,\n email,\n contact,\n customAmount,\n isDisabled,\n isLoading,\n name,\n tip,\n theme = {},\n isPreserveDetailsChecked = false,\n numberOfInstallments = 1,\n payableType = null,\n onBeforePayment = noop,\n onSuccessfulPayment = noop,\n onFailedPayment = noop,\n onPaymentCreated = noop,\n onError = noop,\n}) => {\n const { t } = useTranslation();\n const paymentRef = useRef(null);\n\n const openRazorpayCheckout = async options => {\n const script = await loadScript(\n \"https://checkout.razorpay.com/v1/checkout.js\"\n );\n\n if (!script) {\n logger.error(t(\"neetoPayments.razorpay.loadError\"));\n\n return;\n }\n const checkout = new window.Razorpay(options);\n\n checkout.on(\"payment.failed\", response => {\n const errorDescription = response?.error?.description;\n const errorReason = response?.error?.reason;\n logger.error(\"Razorpay payment failed:\", {\n description: errorDescription,\n reason: errorReason,\n });\n onFailedPayment({ errorDescription, errorReason });\n });\n\n checkout.open();\n };\n\n const handlePayment = response =>\n verifyCheckoutPayment({\n payment: paymentRef.current,\n response,\n onSuccessfulPayment,\n onFailedPayment,\n });\n\n const handleDismiss = () =>\n resolveDismissedCheckout({\n payment: paymentRef.current,\n onSuccessfulPayment,\n onFailedPayment,\n });\n\n const handleSuccess = ({ payment }) => {\n paymentRef.current = payment;\n onPaymentCreated(payment);\n\n if (payment?.status === \"successful\") {\n return onSuccessfulPayment();\n }\n\n const themePrimaryColor = findBy(\n { key: \"primary_color\" },\n theme?.properties\n )?.value;\n\n const options = {\n key: payment.publicKey,\n order_id: payment.orderIdentifier,\n remember_customer: true,\n customer_id: payment.customerIdentifier,\n prefill: { name, email },\n modal: { confirm_close: true, ondismiss: handleDismiss },\n handler: handlePayment,\n theme: { color: themePrimaryColor ?? \"#0da84c\" },\n };\n\n if (isPreserveDetailsChecked) {\n options[\"recurring\"] = \"1\";\n }\n\n return openRazorpayCheckout(\n mergeDeepLeft(RAZORPAY_PAYMENT_BUTTON_OPTIONS, options)\n );\n };\n\n const { isPending, mutate: createRazorpayOrder } = useCreateRazorpayPayment({\n onSuccess: handleSuccess,\n onError,\n });\n\n const handleClick = () => {\n onBeforePayment();\n const payload = {\n payableId,\n payableType,\n discountCode,\n customAmount,\n tipAttributes: tip,\n numberOfInstallments,\n customerAttributes: { email, name, contact },\n isCardPreservingEnabled: isPreserveDetailsChecked,\n };\n createRazorpayOrder(payload);\n };\n\n return (\n <Button\n disabled={isPending || isDisabled}\n label={label || t(\"neetoPayments.common.pay\")}\n loading={isPending || isLoading}\n onClick={handleClick}\n />\n );\n};\n\nexport default RazorpayPaymentButton;\n"],"names":["loadScript","src","Promise","resolve","script","document","createElement","onload","onerror","body","appendChild","RazorpayPaymentButton","label","payableId","discountCode","email","contact","customAmount","isDisabled","isLoading","name","tip","theme","isPreserveDetailsChecked","numberOfInstallments","payableType","onBeforePayment","noop","onSuccessfulPayment","onFailedPayment","onPaymentCreated","onError","t","useTranslation","paymentRef","useRef","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","on","response","errorDescription","description","errorReason","reason","open","handlePayment","verifyCheckoutPayment","payment","current","handleDismiss","resolveDismissedCheckout","handleSuccess","status","themePrimaryColor","findBy","key","properties","value","publicKey","order_id","orderIdentifier","remember_customer","customer_id","customerIdentifier","prefill","modal","confirm_close","ondismiss","handler","color","mergeDeepLeft","RAZORPAY_PAYMENT_BUTTON_OPTIONS","isPending","mutate","createRazorpayOrder","useCreateRazorpayPayment","onSuccess","handleClick","payload","tipAttributes","customerAttributes","isCardPreservingEnabled","_jsx","Button","disabled","loading","onClick"],"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAMA,UAAU,GAAGC,GAAG,IACpB,IAAIC,OAAO,CAACC,OAAO,IAAI;AACrB,EAAA,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,QAAQ,CAAC;EAC/CF,MAAM,CAACH,GAAG,GAAGA,GAAG;EAChBG,MAAM,CAACG,MAAM,GAAG,MAAM;IACpBJ,OAAO,CAAC,IAAI,CAAC;EACf,CAAC;EAEDC,MAAM,CAACI,OAAO,GAAG,MAAM;IACrBL,OAAO,CAAC,KAAK,CAAC;EAChB,CAAC;AACDE,EAAAA,QAAQ,CAACI,IAAI,CAACC,WAAW,CAACN,MAAM,CAAC;AACnC,CAAC,CAAC;AAEJ,MAAMO,qBAAqB,GAAGA,CAAC;EAC7BC,KAAK;EACLC,SAAS;EACTC,YAAY;EACZC,KAAK;EACLC,OAAO;EACPC,YAAY;EACZC,UAAU;EACVC,SAAS;EACTC,IAAI;EACJC,GAAG;EACHC,KAAK,GAAG,EAAE;AACVC,EAAAA,wBAAwB,GAAG,KAAK;AAChCC,EAAAA,oBAAoB,GAAG,CAAC;AACxBC,EAAAA,WAAW,GAAG,IAAI;AAClBC,EAAAA,eAAe,GAAGC,cAAI;AACtBC,EAAAA,mBAAmB,GAAGD,cAAI;AAC1BE,EAAAA,eAAe,GAAGF,cAAI;AACtBG,EAAAA,gBAAgB,GAAGH,cAAI;AACvBI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xBxD,IAAAA,eAAe,EAAE;AACjB,IAAA,MAAMyD,OAAO,GAAG;MACdtE,SAAS;MACTY,WAAW;MACXX,YAAY;MACZG,YAAY;AACZmE,MAAAA,aAAa,EAAE/D,GAAG;MAClBG,oBAAoB;AACpB6D,MAAAA,kBAAkB,EAAE;QAAEtE,KAAK;QAAEK,IAAI;AAAEJ,QAAAA;OAAS;AAC5CsE,MAAAA,uBAAuB,EAAE/D;KAC1B;IACDwD,mBAAmB,CAACI,OAAO,CAAC;EAC9B,CAAC;EAED,oBACEI,cAAA,CAACC,iBAAM,EAAA;IACLC,QAAQ,EAAEZ,SAAS,IAAI3D,UAAW;AAClCN,IAAAA,KAAK,EAAEA,KAAK,IAAIoB,CAAC,CAAC,0BAA0B,CAAE;IAC9C0D,OAAO,EAAEb,SAAS,IAAI1D,SAAU;AAChCwE,IAAAA,OAAO,EAAET;AAAY,GACtB,CAAC;AAEN;;;;"}
|
package/dist/cjs/v2/index.js
CHANGED
|
@@ -84,7 +84,7 @@ require('@bigbinary/neeto-molecules/v2/Container');
|
|
|
84
84
|
require('../useIntegrationsApi-CNrrE2OH.js');
|
|
85
85
|
require('@bigbinary/neeto-molecules/v2/PhoneNumber');
|
|
86
86
|
require('../useBusinessTypesApi-D_td8mux.js');
|
|
87
|
-
require('../
|
|
87
|
+
require('../razorpayCheckoutOutcome-DwerRK1B.js');
|
|
88
88
|
require('neetocommons/initializers');
|
|
89
89
|
require('../useRecurringSettingsApi-CDA5wZnB.js');
|
|
90
90
|
require('../useRefundsApi-enBsXWAk.js');
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'i18next';
|
|
2
2
|
import 'neetocommons/constants';
|
|
3
|
-
export { A as ASSOCIATED_TABLE_COLUMNS, B as BASE_URL, C as CURRENCY_OPTIONS, y as DASHBOARD_KIND, D as DEFAULT_PAGE_VALUES, z as DEFAULT_SORT_PROPERTIES,
|
|
3
|
+
export { A as ASSOCIATED_TABLE_COLUMNS, B as BASE_URL, C as CURRENCY_OPTIONS, y as DASHBOARD_KIND, D as DEFAULT_PAGE_VALUES, z as DEFAULT_SORT_PROPERTIES, h as DEFAULT_TAG_STYLE, E as ERROR_TYPE, K as FILTER_COLUMNS, M as MAX_POLLING_TIME, J as PAYMENT_KIND, q as PAYMENT_PROVIDERS, L as PAYMENT_STATUS_TYPE, P as POLLING_INTERVAL, N as RAZORPAY_CURRENCY_OPTIONS, R as RAZORPAY_PAYMENT_BUTTON_OPTIONS, O as REFUND_STATUS_TYPE, S as SORT_DIRECTIONS, F as STRIPE_CONNECT_ENDPOINT, Q as STRIPE_CURRENCY_OPTIONS, V as STRIPE_DASHBOARD_LINK, T as TAG_STYLE, W as TIP_KIND, U as UN_HIDEABLE_COLUMNS, Z as ZERO_DECIMAL_CURRENCIES } from './index-CpGnAY9G.js';
|
|
4
4
|
import 'decimal.js';
|
|
5
5
|
import 'neetocist';
|
|
6
6
|
import 'neetocommons/utils';
|