Skip to content

Commit d592bd0

Browse files
committed
fix type
1 parent 5ff3bd9 commit d592bd0

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

Diff for: src/lib/appSwitchResume.js

+21-20
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,35 @@ export type AppSwitchResumeParams = {|
1919
// The Web fallback flow uses different set of query params then appswitch flow.
2020
function getAppSwitchParamsWebFallback(): AppSwitchResumeParams | null {
2121
try {
22-
// eslint-disable-next-line compat/compat
23-
const params = new URLSearchParams(window.location.search);
24-
const buttonSessionID = params.get("buttonSessionID");
25-
const fundingSource = params.get("fundingSource");
26-
const orderID = params.get("token");
27-
const payerID = params.get("PayerID");
28-
const vaultToken = params.get("vaultSetupToken");
29-
const approvalTokenID = params.get("approval_token_id");
30-
const approvalSessionID = params.get("approval_session_id");
22+
const params = Object.fromEntries(
23+
// eslint-disable-next-line compat/compat
24+
new URLSearchParams(window.location.search)
25+
);
26+
const {
27+
buttonSessionID,
28+
fundingSource,
29+
token: orderID,
30+
PayerID: payerID,
31+
vaultSetupToken: vaultToken,
32+
approval_token_id: approvalTokenID,
33+
approval_session_id: approvalSessionID,
34+
} = params;
3135

3236
const vaultSetupToken = vaultToken || approvalTokenID || approvalSessionID;
33-
if (payerID && (orderID || vaultSetupToken)) {
34-
return {
35-
checkoutState: "onApprove",
36-
orderID,
37-
vaultSetupToken,
37+
38+
if (vaultSetupToken || orderID) {
39+
const resumeParams: AppSwitchResumeParams = {
40+
checkoutState: payerID ? "onApprove" : "onCancel",
3841
payerID,
39-
buttonSessionID,
40-
fundingSource,
41-
};
42-
} else if (vaultSetupToken || orderID) {
43-
return {
44-
checkoutState: "onCancel",
4542
orderID,
4643
vaultSetupToken,
4744
buttonSessionID,
45+
// URLSearchParams get returns as string,
46+
// but below code excepts a value from list of string.
47+
// $FlowIgnore[incompatible-type]
4848
fundingSource,
4949
};
50+
return resumeParams;
5051
}
5152
return null;
5253
} catch (err) {

0 commit comments

Comments
 (0)