saveFormFields()

saveFormFields() is a default implementation of a beforeRedirect callback. When used in conjunction with restoreFormFields(), the contents of any input elements on your page can be restored across browser redirects during the payment process.

Usage

saveFormFields() can be configured as the beforeRedirect callback using the data-beforeRedirect attribute on the Checkout script tag.

Example

<html>
    <head>
        <script src="https://ap-gateway.mastercard.com/checkout/version/78/checkout.js"
            data-beforeRedirect="Checkout.saveFormFields"
            data-afterRedirect="Checkout.restoreFormFields">
        </script>
    </head>
    ...
</html>

Arguments

None

Return Value

fieldData

An object which represents the input elements on the current page and their values. The input values can be re-written to the page page by passing this object to restoreFormFields().

Copyright © 2023 MasterCard