Skip to content

redirect method in button props #2467

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
Jan 29, 2025
Merged
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
20 changes: 15 additions & 5 deletions src/zoid/buttons/component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
getSDKAttribute,
getJsSdkLibrary,
wasShopperInsightsUsed,
isPayPalTrustedUrl,
} from "@paypal/sdk-client/src";
import {
rememberFunding,
Expand Down Expand Up @@ -292,15 +293,24 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
},

props: {
// App Switch Properties
appSwitchWhenAvailable: {
// this value is a string for now while we test the app switch
// feature. Before we give this to a real merchant, we should
// change this to a boolean - Shane 11 Dec 2024
type: "string",
type: "boolean",
queryParam: true,
required: false,
},

redirect: {
type: "function",
sendToChild: true,
value: () => (url) => {
if (isPayPalTrustedUrl(url)) {
location.href = url;
} else {
throw new Error(`Unable to redirect to provided url ${url}`);
}
},
},

hashChangeHandler: {
type: "function",
sendToChild: false,
Expand Down