@speedlo/payments
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -54,3 +54,3 @@ 'use strict'; | ||
var reportErrors = function reportErrors(paymentStatus) { | ||
var reportErrors = React.useCallback(function (paymentStatus) { | ||
// returns whether any error was reported | ||
@@ -68,5 +68,4 @@ if (!paymentStatus) { | ||
return false; | ||
}; | ||
var handlePaymentStatus = function handlePaymentStatus(orderId, userToken) { | ||
}, [onError]); | ||
var handlePaymentStatus = React.useCallback(function (orderId, userToken) { | ||
try { | ||
@@ -88,4 +87,3 @@ // get payment status from GQL query (via callback) | ||
} | ||
}; | ||
}, [onFinish, queryPaymentStatus, redirectUrl, reportErrors]); | ||
React.useEffect(function () { | ||
@@ -115,3 +113,3 @@ var _QS$parse = QS.parse(window.location.search.replace(/^\?/, '')), | ||
}); | ||
}, [window.location.search]); | ||
}, [handlePaymentStatus]); | ||
@@ -118,0 +116,0 @@ var executeGoPayPayment = function executeGoPayPayment(gatewayUrl) { |
@@ -1,2 +0,2 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var r=e(require("qs-lite")),t=e(require("react")),n=e(require("scriptjs"));"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var o=function(){return null};exports.useGoPay=function(e,i){var u=void 0===i?{}:i,c=u.onError,a=void 0===c?o:c,s=u.onFinish,l=void 0===s?o:s,f=u.redirectUrl,y=t.useState(!1),d=y[0],m=y[1],h=function(r,t){try{return Promise.resolve(e(r,t)).then(function(e){(function(e){return e?!e.isSuccess&&(a(e.userErrors),!0):(a([]),!0)})(e)||(l(),f&&location.replace(f))})}catch(e){return Promise.reject(e)}};return t.useEffect(function(){var e=r.parse(window.location.search.replace(/^\?/,"")),t=e.orderId,n=e.userToken;if(t){var o,i=setTimeout(function(){return m(!0)},500);try{o=window.atob(n)}catch(e){throw new Error("User token decoding failed in useGoPay: "+e)}h(t,o).finally(function(){clearTimeout(i),m(!1)})}},[window.location.search]),{executeGoPayPayment:function(e){try{m(!0);var r=function(r,t){try{var o=(i=e.includes("gw.sandbox.gopay.com")?"https://gw.sandbox.gopay.com/gp-gw/js/embed.js":"https://gate.gopay.cz/gp-gw/js/embed.js",Promise.resolve(new Promise(function(e){n(i,e)})).then(function(){var r={gatewayUrl:e,inline:!0};return Promise.resolve(new Promise(function(e){_gopay.checkout(r,function(r){e(r.id)})})).then(function(){return Promise.resolve(h()).then(function(){})})}))}catch(e){return t(!0,e)}var i;return o&&o.then?o.then(t.bind(null,!1),t.bind(null,!0)):t(!1,value)}(0,function(e,r){if(m(!1),e)throw r;return r});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},paymentLoading:d}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var r=e(require("qs-lite")),t=e(require("react")),n=e(require("scriptjs"));"undefined"!=typeof Symbol&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator"))),"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var o=function(){return null};exports.useGoPay=function(e,i){var u=void 0===i?{}:i,a=u.onError,c=void 0===a?o:a,s=u.onFinish,l=void 0===s?o:s,f=u.redirectUrl,y=t.useState(!1),d=y[0],m=y[1],b=t.useCallback(function(e){return e?!e.isSuccess&&(c(e.userErrors),!0):(c([]),!0)},[c]),h=t.useCallback(function(r,t){try{return Promise.resolve(e(r,t)).then(function(e){b(e)||(l(),f&&location.replace(f))})}catch(e){return Promise.reject(e)}},[l,e,f,b]);return t.useEffect(function(){var e=r.parse(window.location.search.replace(/^\?/,"")),t=e.orderId,n=e.userToken;if(t){var o,i=setTimeout(function(){return m(!0)},500);try{o=window.atob(n)}catch(e){throw new Error("User token decoding failed in useGoPay: "+e)}h(t,o).finally(function(){clearTimeout(i),m(!1)})}},[h]),{executeGoPayPayment:function(e){try{m(!0);var r=function(r,t){try{var o=(i=e.includes("gw.sandbox.gopay.com")?"https://gw.sandbox.gopay.com/gp-gw/js/embed.js":"https://gate.gopay.cz/gp-gw/js/embed.js",Promise.resolve(new Promise(function(e){n(i,e)})).then(function(){var r={gatewayUrl:e,inline:!0};return Promise.resolve(new Promise(function(e){_gopay.checkout(r,function(r){e(r.id)})})).then(function(){return Promise.resolve(h()).then(function(){})})}))}catch(e){return t(!0,e)}var i;return o&&o.then?o.then(t.bind(null,!1),t.bind(null,!0)):t(!1,value)}(0,function(e,r){if(m(!1),e)throw r;return r});return Promise.resolve(r&&r.then?r.then(function(){}):void 0)}catch(e){return Promise.reject(e)}},paymentLoading:d}}; | ||
//# sourceMappingURL=payments.cjs.production.min.js.map |
@@ -50,3 +50,3 @@ import QS from 'qs-lite'; | ||
var reportErrors = function reportErrors(paymentStatus) { | ||
var reportErrors = React.useCallback(function (paymentStatus) { | ||
// returns whether any error was reported | ||
@@ -64,5 +64,4 @@ if (!paymentStatus) { | ||
return false; | ||
}; | ||
var handlePaymentStatus = function handlePaymentStatus(orderId, userToken) { | ||
}, [onError]); | ||
var handlePaymentStatus = React.useCallback(function (orderId, userToken) { | ||
try { | ||
@@ -84,4 +83,3 @@ // get payment status from GQL query (via callback) | ||
} | ||
}; | ||
}, [onFinish, queryPaymentStatus, redirectUrl, reportErrors]); | ||
React.useEffect(function () { | ||
@@ -111,3 +109,3 @@ var _QS$parse = QS.parse(window.location.search.replace(/^\?/, '')), | ||
}); | ||
}, [window.location.search]); | ||
}, [handlePaymentStatus]); | ||
@@ -114,0 +112,0 @@ var executeGoPayPayment = function executeGoPayPayment(gatewayUrl) { |
{ | ||
"name": "@speedlo/payments", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"scripts": { | ||
@@ -11,2 +11,3 @@ "build": "tsdx build --tsconfig ./tsconfig.build.json", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/payments.esm.js", | ||
"files": [ | ||
@@ -23,6 +24,4 @@ "dist" | ||
"devDependencies": { | ||
"@speedlo/types": "^2.1.1", | ||
"@types/react": "^16.8.13", | ||
"@types/scriptjs": "^0.0.2", | ||
"react": "^16.8.2" | ||
"@speedlo/types": "^2.1.2", | ||
"@types/scriptjs": "^0.0.2" | ||
}, | ||
@@ -33,3 +32,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "fd0955d6e70c338d12ae6e3a7ee7c399985c41b6" | ||
"gitHead": "91a8987fbcd9b21c2570fa45e30657c31ae9423d" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
99581
2