Skip to content

update return url query params #2483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/lib/appSwitchResume.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getAppSwitchParamsWebFallback(): AppSwitchResumeParams | null {
new URLSearchParams(window.location.search)
);
const {
buttonSessionID,
button_session_id: buttonSessionID,
fundingSource,
token: orderID,
PayerID: payerID,
Expand Down Expand Up @@ -76,14 +76,18 @@ export function getAppSwitchResumeParams(): AppSwitchResumeParams | null {
const {
token,
PayerID,
buttonSessionID,
button_session_id: buttonSessionID,
billingToken,
paymentID,
subscriptionID,
vaultSetupToken,
vaultSetupToken: vaultToken,
approval_token_id: approvalTokenID,
approval_session_id: approvalSessionID,
fundingSource,
} = parseQuery(queryString);

const vaultSetupToken = vaultToken || approvalTokenID || approvalSessionID;

const params: AppSwitchResumeParams = {
orderID: token,
buttonSessionID,
Expand Down
14 changes: 7 additions & 7 deletions src/lib/appSwithResume.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe("app switch resume flow", () => {

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

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

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

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

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

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

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

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

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

const params = getAppSwitchResumeParams();
Expand Down