Skip to content

Commit 749a65e

Browse files
committed
update return url query params
1 parent 281999f commit 749a65e

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

Diff for: src/lib/appSwitchResume.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function getAppSwitchParamsWebFallback(): AppSwitchResumeParams | null {
2424
new URLSearchParams(window.location.search)
2525
);
2626
const {
27-
buttonSessionID,
27+
button_session_id: buttonSessionID,
2828
fundingSource,
2929
token: orderID,
3030
PayerID: payerID,
@@ -76,14 +76,18 @@ export function getAppSwitchResumeParams(): AppSwitchResumeParams | null {
7676
const {
7777
token,
7878
PayerID,
79-
buttonSessionID,
79+
button_session_id: buttonSessionID,
8080
billingToken,
8181
paymentID,
8282
subscriptionID,
83-
vaultSetupToken,
83+
vaultSetupToken: vaultToken,
84+
approval_token_id: approvalTokenID,
85+
approval_session_id: approvalSessionID,
8486
fundingSource,
8587
} = parseQuery(queryString);
8688

89+
const vaultSetupToken = vaultToken || approvalTokenID || approvalSessionID;
90+
8791
const params: AppSwitchResumeParams = {
8892
orderID: token,
8993
buttonSessionID,

Diff for: src/lib/appSwithResume.test.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe("app switch resume flow", () => {
2626

2727
test("should test fetching resume params when parameters are correctly passed", () => {
2828
vi.spyOn(window, "location", "get").mockReturnValue({
29-
hash: `#onApprove?buttonSessionID=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}`,
29+
hash: `#onApprove?button_session_id=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}`,
3030
});
3131

3232
const params = getAppSwitchResumeParams();
@@ -55,7 +55,7 @@ describe("app switch resume flow", () => {
5555

5656
test("should test null fetching resume params with invalid callback passed", () => {
5757
vi.spyOn(window, "location", "get").mockReturnValue({
58-
hash: `#Unknown?buttonSessionID=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}`,
58+
hash: `#Unknown?button_session_id=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}`,
5959
});
6060

6161
const params = getAppSwitchResumeParams();
@@ -67,7 +67,7 @@ describe("app switch resume flow", () => {
6767

6868
test("should test fetching multiple resume params when parameters are correctly passed", () => {
6969
vi.spyOn(window, "location", "get").mockReturnValue({
70-
hash: `#onApprove?buttonSessionID=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}&billingToken=BA-124&PayerID=PP-payer-122&paymentID=PAY-123&subscriptionID=I-1234&vaultSetupToken=VA-3`,
70+
hash: `#onApprove?button_session_id=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}&billingToken=BA-124&PayerID=PP-payer-122&paymentID=PAY-123&subscriptionID=I-1234&vaultSetupToken=VA-3`,
7171
});
7272

7373
const params = getAppSwitchResumeParams();
@@ -87,9 +87,9 @@ describe("app switch resume flow", () => {
8787
expect(isAppSwitchResumeFlow()).toEqual(true);
8888
});
8989

90-
test("should test onApprove resume params when parameters are passed from web fallback", () => {
90+
test("should test onApprove resume params when parameters are passed from web fallback with vaultSetupToken", () => {
9191
vi.spyOn(window, "location", "get").mockReturnValue({
92-
search: `?buttonSessionID=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}&vaultSetupToken=VA-3&PayerID=PP123456`,
92+
search: `?button_session_id=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}&vaultSetupToken=VA-3&PayerID=PP123456`,
9393
});
9494

9595
const params = getAppSwitchResumeParams();
@@ -106,9 +106,9 @@ describe("app switch resume flow", () => {
106106
expect(isAppSwitchResumeFlow()).toEqual(true);
107107
});
108108

109-
test("should test onCancel resume params when parameters are passed from web fallback", () => {
109+
test("should test onCancel resume params when parameters are passed from web fallback with approval_token_id", () => {
110110
vi.spyOn(window, "location", "get").mockReturnValue({
111-
search: `?buttonSessionID=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}&vaultSetupToken=VA-3`,
111+
search: `?button_session_id=${buttonSessionID}&token=${orderID}&fundingSource=${fundingSource}&approval_token_id=VA-3`,
112112
});
113113

114114
const params = getAppSwitchResumeParams();

0 commit comments

Comments
 (0)