@bigbinary/neeto-payments-frontend 6.1.16 → 6.1.18
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.
|
@@ -28,6 +28,7 @@ const RazorpayPaymentButton = ({
|
|
|
28
28
|
payableId,
|
|
29
29
|
discountCode,
|
|
30
30
|
email,
|
|
31
|
+
contact,
|
|
31
32
|
customAmount,
|
|
32
33
|
isDisabled,
|
|
33
34
|
isLoading,
|
|
@@ -51,6 +52,20 @@ const RazorpayPaymentButton = ({
|
|
|
51
52
|
return;
|
|
52
53
|
}
|
|
53
54
|
const checkout = new window.Razorpay(options);
|
|
55
|
+
|
|
56
|
+
// Listen for payment failure events to capture error details
|
|
57
|
+
checkout.on("payment.failed", response => {
|
|
58
|
+
const errorDescription = response?.error?.description;
|
|
59
|
+
const errorReason = response?.error?.reason;
|
|
60
|
+
logger.error("Razorpay payment failed:", {
|
|
61
|
+
description: errorDescription,
|
|
62
|
+
reason: errorReason
|
|
63
|
+
});
|
|
64
|
+
onFailedPayment({
|
|
65
|
+
errorDescription,
|
|
66
|
+
errorReason
|
|
67
|
+
});
|
|
68
|
+
});
|
|
54
69
|
checkout.open();
|
|
55
70
|
};
|
|
56
71
|
const handlePayment = response => {
|
|
@@ -109,7 +124,8 @@ const RazorpayPaymentButton = ({
|
|
|
109
124
|
numberOfInstallments,
|
|
110
125
|
customerAttributes: {
|
|
111
126
|
email,
|
|
112
|
-
name
|
|
127
|
+
name,
|
|
128
|
+
contact
|
|
113
129
|
},
|
|
114
130
|
isCardPreservingEnabled: isPreserveDetailsChecked
|
|
115
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../app/javascript/src/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { isNotPresent, 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\";\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 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}) => {\n const { t } = useTranslation();\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 if (isNotPresent(response?.razorpay_signature)) {\n onFailedPayment();\n\n return;\n }\n\n onSuccessfulPayment();\n };\n\n const handleSuccess = ({ payment }) => {\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: onFailedPayment },\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 });\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 },\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","customAmount","isDisabled","isLoading","name","tip","theme","isPreserveDetailsChecked","numberOfInstallments","payableType","onBeforePayment","noop","onSuccessfulPayment","onFailedPayment","t","useTranslation","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","
|
|
1
|
+
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../app/javascript/src/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { isNotPresent, 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\";\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}) => {\n const { t } = useTranslation();\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 if (isNotPresent(response?.razorpay_signature)) {\n onFailedPayment();\n\n return;\n }\n\n onSuccessfulPayment();\n };\n\n const handleSuccess = ({ payment }) => {\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: onFailedPayment },\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 });\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","t","useTranslation","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","on","response","errorDescription","description","errorReason","reason","open","handlePayment","isNotPresent","razorpay_signature","handleSuccess","payment","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":";;;;;;;;;;;;;;AAQA,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;GACd;EAEDC,MAAM,CAACI,OAAO,GAAG,MAAM;IACrBL,OAAO,CAAC,KAAK,CAAC;GACf;AACDE,EAAAA,QAAQ,CAACI,IAAI,CAACC,WAAW,CAACN,MAAM,CAAC;AACnC,CAAC,CAAC;AAEEO,MAAAA,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,IAAI;AACtBC,EAAAA,mBAAmB,GAAGD,IAAI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GAC7B;EAED,oBACEI,GAAA,CAACC,MAAM,EAAA;IACLC,QAAQ,EAAEZ,SAAS,IAAIrD,UAAW;AAClCN,IAAAA,KAAK,EAAEA,KAAK,IAAIkB,CAAC,CAAC,0BAA0B,CAAE;IAC9CsD,OAAO,EAAEb,SAAS,IAAIpD,SAAU;AAChCkE,IAAAA,OAAO,EAAET;AAAY,GACtB,CAAC;AAEN;;;;"}
|
|
@@ -30,6 +30,7 @@ const RazorpayPaymentButton = ({
|
|
|
30
30
|
payableId,
|
|
31
31
|
discountCode,
|
|
32
32
|
email,
|
|
33
|
+
contact,
|
|
33
34
|
customAmount,
|
|
34
35
|
isDisabled,
|
|
35
36
|
isLoading,
|
|
@@ -53,6 +54,20 @@ const RazorpayPaymentButton = ({
|
|
|
53
54
|
return;
|
|
54
55
|
}
|
|
55
56
|
const checkout = new window.Razorpay(options);
|
|
57
|
+
|
|
58
|
+
// Listen for payment failure events to capture error details
|
|
59
|
+
checkout.on("payment.failed", response => {
|
|
60
|
+
const errorDescription = response?.error?.description;
|
|
61
|
+
const errorReason = response?.error?.reason;
|
|
62
|
+
logger.error("Razorpay payment failed:", {
|
|
63
|
+
description: errorDescription,
|
|
64
|
+
reason: errorReason
|
|
65
|
+
});
|
|
66
|
+
onFailedPayment({
|
|
67
|
+
errorDescription,
|
|
68
|
+
errorReason
|
|
69
|
+
});
|
|
70
|
+
});
|
|
56
71
|
checkout.open();
|
|
57
72
|
};
|
|
58
73
|
const handlePayment = response => {
|
|
@@ -111,7 +126,8 @@ const RazorpayPaymentButton = ({
|
|
|
111
126
|
numberOfInstallments,
|
|
112
127
|
customerAttributes: {
|
|
113
128
|
email,
|
|
114
|
-
name
|
|
129
|
+
name,
|
|
130
|
+
contact
|
|
115
131
|
},
|
|
116
132
|
isCardPreservingEnabled: isPreserveDetailsChecked
|
|
117
133
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../../app/javascript/src/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { isNotPresent, 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\";\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 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}) => {\n const { t } = useTranslation();\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 if (isNotPresent(response?.razorpay_signature)) {\n onFailedPayment();\n\n return;\n }\n\n onSuccessfulPayment();\n };\n\n const handleSuccess = ({ payment }) => {\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: onFailedPayment },\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 });\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 },\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","customAmount","isDisabled","isLoading","name","tip","theme","isPreserveDetailsChecked","numberOfInstallments","payableType","onBeforePayment","noop","onSuccessfulPayment","onFailedPayment","t","useTranslation","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","
|
|
1
|
+
{"version":3,"file":"RazorpayPaymentButton.js","sources":["../../app/javascript/src/components/RazorpayPaymentButton.jsx"],"sourcesContent":["import { isNotPresent, 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\";\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}) => {\n const { t } = useTranslation();\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 if (isNotPresent(response?.razorpay_signature)) {\n onFailedPayment();\n\n return;\n }\n\n onSuccessfulPayment();\n };\n\n const handleSuccess = ({ payment }) => {\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: onFailedPayment },\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 });\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","t","useTranslation","openRazorpayCheckout","options","logger","error","checkout","window","Razorpay","on","response","errorDescription","description","errorReason","reason","open","handlePayment","isNotPresent","razorpay_signature","handleSuccess","payment","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":";;;;;;;;;;;;;;;;AAQA,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;GACd;EAEDC,MAAM,CAACI,OAAO,GAAG,MAAM;IACrBL,OAAO,CAAC,KAAK,CAAC;GACf;AACDE,EAAAA,QAAQ,CAACI,IAAI,CAACC,WAAW,CAACN,MAAM,CAAC;AACnC,CAAC,CAAC;AAEEO,MAAAA,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,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,MAAAA,kBAAkB,EAAE;QAAEhE,KAAK;QAAEK,IAAI;AAAEJ,QAAAA;OAAS;AAC5CgE,MAAAA,uBAAuB,EAAEzD;KAC1B;IACDkD,mBAAmB,CAACI,OAAO,CAAC;GAC7B;EAED,oBACEI,cAAA,CAACC,cAAM,EAAA;IACLC,QAAQ,EAAEZ,SAAS,IAAIrD,UAAW;AAClCN,IAAAA,KAAK,EAAEA,KAAK,IAAIkB,CAAC,CAAC,0BAA0B,CAAE;IAC9CsD,OAAO,EAAEb,SAAS,IAAIpD,SAAU;AAChCkE,IAAAA,OAAO,EAAET;AAAY,GACtB,CAAC;AAEN;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-payments-frontend",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.18",
|
|
4
4
|
"description": "To manage payments across the neeto products.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"homepage": "https://github.com/bigbinary/neeto-payments-nano",
|
|
@@ -61,9 +61,9 @@
|
|
|
61
61
|
"@babel/preset-typescript": "7.26.0",
|
|
62
62
|
"@babel/runtime": "7.26.10",
|
|
63
63
|
"@bigbinary/babel-preset-neeto": "^1.0.3",
|
|
64
|
-
"@bigbinary/eslint-plugin-neeto": "1.8.
|
|
64
|
+
"@bigbinary/eslint-plugin-neeto": "1.8.1",
|
|
65
65
|
"@bigbinary/neeto-cist": "1.0.17",
|
|
66
|
-
"@bigbinary/neeto-editor": "1.47.
|
|
66
|
+
"@bigbinary/neeto-editor": "1.47.88",
|
|
67
67
|
"@bigbinary/neeto-filters-frontend": "4.3.30",
|
|
68
68
|
"@bigbinary/neeto-icons": "1.20.80",
|
|
69
69
|
"@dnd-kit/core": "6.3.1",
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
"peerDependencies": {
|
|
176
176
|
"@babel/runtime": "7.26.10",
|
|
177
177
|
"@bigbinary/neeto-cist": "1.0.17",
|
|
178
|
-
"@bigbinary/neeto-editor": "1.47.
|
|
178
|
+
"@bigbinary/neeto-editor": "1.47.88",
|
|
179
179
|
"@bigbinary/neeto-filters-frontend": "4.3.30",
|
|
180
180
|
"@bigbinary/neeto-icons": "1.20.80",
|
|
181
181
|
"@dnd-kit/core": "6.3.1",
|