Skip to content

Commit bebcb3f

Browse files
authored
redirect method in button props (#2467)
1 parent 915822c commit bebcb3f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

Diff for: src/zoid/buttons/component.jsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
getSDKAttribute,
4343
getJsSdkLibrary,
4444
wasShopperInsightsUsed,
45+
isPayPalTrustedUrl,
4546
} from "@paypal/sdk-client/src";
4647
import {
4748
rememberFunding,
@@ -292,15 +293,24 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
292293
},
293294

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

302+
redirect: {
303+
type: "function",
304+
sendToChild: true,
305+
value: () => (url) => {
306+
if (isPayPalTrustedUrl(url)) {
307+
location.href = url;
308+
} else {
309+
throw new Error(`Unable to redirect to provided url ${url}`);
310+
}
311+
},
312+
},
313+
304314
hashChangeHandler: {
305315
type: "function",
306316
sendToChild: false,

0 commit comments

Comments
 (0)