Masterpass

pz-masterpass provides a set of modular and customizable components for Masterpass integration during checkout. This includes card management, OTP verification, and modal interactions.

Installation Method

You can use the following command to install the extension with the latest plugins:

npx @akinon/projectzero@latest --plugins

Masterpass Provider

Wraps your checkout context with Masterpass features. Use this at the top level of the checkout.

/src/app/[commerce]/[locale]/[currency]/orders/checkout/page.tsx

Usage Examples

Default Usage

<PluginModule
    component={Component.MasterpassProvider}
    props={{
translations: {
    genericErrorMessage: 'An error occurred. Please try again later.'
}
    }}
>
 ... ...
</PluginModule>

Customized Usage Additional Params

Delete Confirmation Modal

Shows a modal when a user attempts to delete a saved card.

Props

Props
Type
Required
Description

translations

type of defaultTranslations

Optional

Used to customize the default texts.

renderer

RendererProps

Optional

Renderer functions that can be used to customize all subcomponents.

RendererProps

Props
Type
Description

open

boolean

It is information whether the modal is open or not.

setOpen

(open:boolean) => void

Used to manage modal on/off operation.

onConfirm

() => void

This is the function that will perform the deletion operation.

onCancel

() => void

This is the function that will be run if the user cancels the deletion process.

loading

boolean

Indicates the loading status during the deletion process.

error

string / null

Error message to be displayed if an error occurs during deletion.

Usage Examples

Default Usage

Customized Usage with Renderer

OTP Modal

Displays an OTP verification modal after card action (add).

Props

Props
Type
Required
Description

translations

type of defaultTranslations

Optional

Used to customize the default texts.

renderer

RendererProps

Optional

Renderer functions that can be used to customize all subcomponents.

RendererProps

Props
Type
Description

open

boolean

It is information whether the modal is open or not.

setOpen

(open:boolean) => void

Used to manage modal on/off operation.

onSubmit

(data: { otp_code:string }) => void

Sends the OTP code entered by the user.

loading

boolean

Indicates the loading status during validation.

error

string / null

Error message to be displayed if there is an error.

resendSms

() => void

Function triggered when the user requests SMS again.

resendSmsFetching

boolean

Indicates the loading status during the resending process.

targetDate

number

When the countdown will end (as a timestamp).

otpRef

string / null

Transaction reference number, if applicable.

Usage Examples

Default Usage

Customized Usage with Renderer

MasterpassLinkModal Component

Prompts user to link their Masterpass card if one is detected.

Props

Props
Type
Required
Description

translations

type of defaultTranslations

Optional

Used to customize the default texts.

renderer

RendererProps

Optional

Renderer functions that can be used to customize all subcomponents.

RendererProps

Props
Type
Description

open

boolean

It is information whether the modal is open or not.

setOpen

(open:boolean) => void

Used to manage modal on/off operation.

onClick

() => void

It is the function that is called when the user clicks the "Use" button.

loading

boolean

This is the loading status that will be displayed during the API request.

error

string / null

If there is an error in the API response, a message is displayed in this field.

Usage Examples

Default Usage

Customized Usage with Renderer

MasterpassCardList Component

Displays all Masterpass-linked cards and allows selection or deletion.

Props

Props
Type
Required
Description

className

string

Optional

It adds an extra style class to the outer container of the component.

translations

{ [key: string]: string }

Optional

Used to customize the default texts.

renderer

RendererProps

Optional

Renderer functions that can be used to customize all subcomponents.

RendererProps

Props
Type
Description

Header

JSX.Element

Used to customize the title area at the top of the card list.

CardItem

(params: { card, selectedCard, onSelect, DeleteButton }) => JSX.Element

It allows you to fully customize the card element.

Loader

() => JSX.Element

Used to define a custom loader component to be displayed when loading cards.

ErrorFallback

(params: { error: string; onRetry: () => void }) => JSX.Element

Custom widget to be shown if an error occurs while loading cards.

SwitchPaymentButton

(props: { onClick: () => void; label: string }) => JSX.Element

Used to customize the "Pay with a new card" option.

Usage Examples

Default Usage

Customized Usage with Renderer

MasterpassCardRegistration Component

Form to add a new Masterpass card and consent to store it.

Props

Props
Type
Required
Description

getValues

() => Record<string, string>

Required

Returns the values ​​of form fields.

className

string

Optional

Gives an additional CSS class to the outer container.

infoModalContent

React.ReactNode

Optional

Body content for the informational modal.

infoModalIcon

React.ReactNode

Optional

Used to override the notification icon.

translations

typeof defaultTranslations

Optional

Can be used to override default texts.

renderer

RendererProps

Optional

Renderer functions that can be used to customize all subcomponents.

RendererProps

Props
Type
Description

Content

props: { isChecked, toggle, setIsInfoModalOpen, onChange, onSubmit, loading, error, showGoBackLink?, onClickGoBackLink? }) => JSX.Element

Used to render the main content.

InfoModal

(props: { open: boolean; setOpen: (value: boolean) => void }) => JSX.Element

Can be used to override the notification modal.

Usage Examples

Default Usage

Customized Usage with className, infoModalContent, infoModalIcon

Customized Usage with Renderer

Last updated

Was this helpful?