beforeRedirect Callback

The beforeRedirect callback is invoked before browser redirects occur during the payment flow. The return value of the callback will be stored until the browser is returned to the merchant page. The value can be recovered with the afterRedirect callback.

Payment method such as PayPal requires the browser to be redirected away from a merchant page.


The beforeRedirect callback must be defined using the data-beforeRedirect attribute on the Checkout script tag. The attribute value must be the name of a global function.


        <script src=""
        <script type="text/javascript">
            function getPageState() {
                return {
                    foo: "string",
                    bar: 123.45



Return Value

data Object
A JSON serializable object.

Copyright © 2023 Mastercard