@speedlo/payments
Advanced tools
Comparing version 1.1.2 to 1.2.0
@@ -7,2 +7,3 @@ 'use strict'; | ||
var QS = _interopDefault(require('qs-lite')); | ||
var React = _interopDefault(require('react')); | ||
@@ -99,7 +100,7 @@ var scriptjs = _interopDefault(require('scriptjs')); | ||
}; | ||
var handlePaymentStatus = function (orderId) { return __awaiter(_this, void 0, void 0, function () { | ||
var handlePaymentStatus = function (orderId, userToken) { return __awaiter(_this, void 0, void 0, function () { | ||
var paymentStatus, hasError; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, queryPaymentStatus(orderId)]; | ||
case 0: return [4 /*yield*/, queryPaymentStatus(orderId, userToken)]; | ||
case 1: | ||
@@ -119,14 +120,12 @@ paymentStatus = _a.sent(); | ||
React.useEffect(function () { | ||
// retrieve orderId from the url | ||
var match = window.location.href.match(/orderId=(\d+)/i); | ||
if (!match) { | ||
var _a = QS.parse(window.location.search.replace(/^\?/, '')), orderId = _a.orderId, userToken = _a.userToken; | ||
if (!orderId) { | ||
return; | ||
} | ||
var _a = __read(match, 2), orderId = _a[1]; | ||
var indicatorDelay = setTimeout(function () { return setPaymentLoading(true); }, 500); | ||
handlePaymentStatus(orderId).finally(function () { | ||
handlePaymentStatus(orderId, userToken).finally(function () { | ||
clearTimeout(indicatorDelay); | ||
setPaymentLoading(false); | ||
}); | ||
}, [window.location.href]); | ||
}, [window.location.search]); | ||
var executeGoPayPayment = function (gatewayUrl) { return __awaiter(_this, void 0, void 0, function () { | ||
@@ -133,0 +132,0 @@ var scriptUrl_1, checkoutOptions_1; |
@@ -10,3 +10,3 @@ interface PaymentStatus { | ||
} | ||
export declare const useGoPay: (queryPaymentStatus: (orderId?: string | undefined) => Promise<PaymentStatus | null>, { onError, onFinish, redirectUrl }?: Partial<IOptions>) => { | ||
export declare const useGoPay: (queryPaymentStatus: (orderId?: string | undefined, userToken?: string | undefined) => Promise<PaymentStatus | null>, { onError, onFinish, redirectUrl }?: Partial<IOptions>) => { | ||
executeGoPayPayment: (gatewayUrl: string) => Promise<void>; | ||
@@ -13,0 +13,0 @@ paymentLoading: boolean; |
{ | ||
"name": "@speedlo/payments", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"scripts": { | ||
@@ -22,2 +22,3 @@ "prepublish": "node ../../util/builder.js" | ||
"dependencies": { | ||
"qs-lite": "^0.0.1", | ||
"scriptjs": "^2.5.9" | ||
@@ -35,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "e0d4dc60ab6ddfc86b0297f68085cf735784d407" | ||
"gitHead": "266140a3645bcf0314b6b05328ac6eda27c0fd75" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15143
4
179
+ Addedqs-lite@^0.0.1
+ Addedqs-lite@0.0.1(transitive)