@bigbinary/neeto-payments-frontend 1.4.6 → 1.4.7
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/index.cjs.js +92 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +92 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -7050,6 +7050,97 @@ var useSquareCard = function useSquareCard() {
|
|
|
7050
7050
|
};
|
|
7051
7051
|
};
|
|
7052
7052
|
|
|
7053
|
+
var loadScript$1 = function loadScript(src) {
|
|
7054
|
+
return new Promise(function (resolve) {
|
|
7055
|
+
var script = document.createElement("script");
|
|
7056
|
+
script.src = src;
|
|
7057
|
+
script.onload = function () {
|
|
7058
|
+
resolve(true);
|
|
7059
|
+
};
|
|
7060
|
+
script.onerror = function () {
|
|
7061
|
+
resolve(false);
|
|
7062
|
+
};
|
|
7063
|
+
document.body.appendChild(script);
|
|
7064
|
+
});
|
|
7065
|
+
};
|
|
7066
|
+
var useRazorpayPayment = function useRazorpayPayment(_ref) {
|
|
7067
|
+
var payableId = _ref.payableId,
|
|
7068
|
+
_ref$onBeforePayment = _ref.onBeforePayment,
|
|
7069
|
+
onBeforePayment = _ref$onBeforePayment === void 0 ? neetoCist.noop : _ref$onBeforePayment,
|
|
7070
|
+
_ref$onSuccessfulPaym = _ref.onSuccessfulPayment,
|
|
7071
|
+
onSuccessfulPayment = _ref$onSuccessfulPaym === void 0 ? neetoCist.noop : _ref$onSuccessfulPaym,
|
|
7072
|
+
_ref$onFailedPayment = _ref.onFailedPayment,
|
|
7073
|
+
onFailedPayment = _ref$onFailedPayment === void 0 ? neetoCist.noop : _ref$onFailedPayment;
|
|
7074
|
+
var _useTranslation = reactI18next.useTranslation(),
|
|
7075
|
+
t = _useTranslation.t;
|
|
7076
|
+
var openRazorpayCheckout = /*#__PURE__*/function () {
|
|
7077
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(options) {
|
|
7078
|
+
var script, checkout;
|
|
7079
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
7080
|
+
while (1) switch (_context.prev = _context.next) {
|
|
7081
|
+
case 0:
|
|
7082
|
+
_context.next = 2;
|
|
7083
|
+
return loadScript$1("https://checkout.razorpay.com/v1/checkout.js");
|
|
7084
|
+
case 2:
|
|
7085
|
+
script = _context.sent;
|
|
7086
|
+
if (script) {
|
|
7087
|
+
_context.next = 6;
|
|
7088
|
+
break;
|
|
7089
|
+
}
|
|
7090
|
+
logger.error(t("neetoPayments.razorpay.loadError"));
|
|
7091
|
+
return _context.abrupt("return");
|
|
7092
|
+
case 6:
|
|
7093
|
+
checkout = new window.Razorpay(options);
|
|
7094
|
+
checkout.open();
|
|
7095
|
+
case 8:
|
|
7096
|
+
case "end":
|
|
7097
|
+
return _context.stop();
|
|
7098
|
+
}
|
|
7099
|
+
}, _callee);
|
|
7100
|
+
}));
|
|
7101
|
+
return function openRazorpayCheckout(_x) {
|
|
7102
|
+
return _ref2.apply(this, arguments);
|
|
7103
|
+
};
|
|
7104
|
+
}();
|
|
7105
|
+
var handlePayment = function handlePayment(response) {
|
|
7106
|
+
if (neetoCist.isNotPresent(response === null || response === void 0 ? void 0 : response.razorpay_signature)) {
|
|
7107
|
+
onFailedPayment();
|
|
7108
|
+
return;
|
|
7109
|
+
}
|
|
7110
|
+
onSuccessfulPayment();
|
|
7111
|
+
};
|
|
7112
|
+
var handleSuccess = function handleSuccess(_ref3) {
|
|
7113
|
+
var payment = _ref3.payment;
|
|
7114
|
+
if ((payment === null || payment === void 0 ? void 0 : payment.status) === "successful") {
|
|
7115
|
+
return onSuccessfulPayment();
|
|
7116
|
+
}
|
|
7117
|
+
var options = {
|
|
7118
|
+
key: payment.publicKey,
|
|
7119
|
+
order_id: payment.orderIdentifier,
|
|
7120
|
+
customer_id: payment.customerIdentifier,
|
|
7121
|
+
modal: {
|
|
7122
|
+
confirm_close: true,
|
|
7123
|
+
ondismiss: onFailedPayment
|
|
7124
|
+
},
|
|
7125
|
+
handler: handlePayment
|
|
7126
|
+
};
|
|
7127
|
+
return openRazorpayCheckout(ramda.mergeDeepLeft(RAZORPAY_PAYMENT_BUTTON_OPTIONS, options));
|
|
7128
|
+
};
|
|
7129
|
+
var _useCreateRazorpayPay = useCreateRazorpayPayment({
|
|
7130
|
+
onSuccess: handleSuccess
|
|
7131
|
+
}),
|
|
7132
|
+
createRazorpayOrder = _useCreateRazorpayPay.mutate;
|
|
7133
|
+
var makePayment = function makePayment() {
|
|
7134
|
+
onBeforePayment();
|
|
7135
|
+
createRazorpayOrder({
|
|
7136
|
+
payableId: payableId
|
|
7137
|
+
});
|
|
7138
|
+
};
|
|
7139
|
+
return {
|
|
7140
|
+
makePayment: makePayment
|
|
7141
|
+
};
|
|
7142
|
+
};
|
|
7143
|
+
|
|
7053
7144
|
var useStripePromise = function useStripePromise(stripeAccountIdentifier) {
|
|
7054
7145
|
var stripePromise = React.useMemo( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
7055
7146
|
var stripeJs, _yield$stripeJs, loadStripe;
|
|
@@ -9267,6 +9358,7 @@ exports.SquareCard = SquareCard;
|
|
|
9267
9358
|
exports.SquareDashboard = index$1;
|
|
9268
9359
|
exports.StripeConnect = StripeConnect;
|
|
9269
9360
|
exports.buildStripeTransactionLink = buildStripeTransactionLink;
|
|
9361
|
+
exports.useRazorpayPayment = useRazorpayPayment;
|
|
9270
9362
|
exports.useSquareCard = useSquareCard;
|
|
9271
9363
|
exports.useStripePromise = useStripePromise;
|
|
9272
9364
|
//# sourceMappingURL=index.cjs.js.map
|