Skip to main content

Options and Methods

Information

The customization of the widget is a topic of constant improvement within our Front Team.
We provide additional variables and features on a weekly basis.

Methods and Options​

The Purse widget offers a wide set of configuration options to personalize its behavior and visuals.
These allow merchants to adapt the checkout to their specific branding and UX requirements.

Example Setup​

const widget = await widgetManager.createWidget({
name: "my-widget",
interface: "PAYMENT",
preSelectMethod: "ACI",
methods: (protocol) => protocol.partner === "illicado",
sortProtocols: myFancyCustomSortFunction,
autoSelectTokenStrategy: "none",
forceTokenRegistration: false,
tokenRegistrationDefaultValue: false,
payload: {...},
ui: {...}
})
About Tokens

In this page, "token" refers to saved payment methods, such as a credit card stored in the Purse vault system.
Learn more about how tokenization works here.

Options Table​

OptionTypeDescriptionExample
namestringIdentifier of the widget. If not provided, an autogenerated name will be used."payment-widget"
interfacestringDefines the widget interface. See available types here."PAYMENT"
preSelectMethodstringSets a default selected payment method."aci"
methods(protocol) => booleanFilters payment methods.protocol.method === "wallet"
sortProtocols(a, b) => numberCustom sorting function for payment methods.—
autoSelectTokenStrategy"none", "fav_only", "fav_or_first"Auto-select token logic."none"
forceTokenRegistrationbooleanForces token registration even if the checkbox is unchecked.true
tokenRegistrationDefaultValuebooleanDefines whether the token checkbox is pre-checked.false
payloadanyLoads a configuration object, such as for a simulator.—
uiWidgetUiOptionsControls visuals and layout. See options here.—
formatCurrency(amount, currency) => stringCustom format for displaying currency values."${amount} ${currency}"

Widget Interfaces & Layout​

export type WidgetUiOptions = {
layout?: LayoutOptions,
themeID?: string,
translations?: TranslationsOptions,
stylesheet?: StylesheetOptions,
assets?: AssetsOptions,
payButtons?: PayButtonsOptions
};

You can split the checkout into modular blocks on your page.
Start with the PAYMENT interface, then explore more via Widget Interface and Widget Layout.

Listening to Events​

This section has moved, you can find it here.

Update Session Data​

To update billing/shipping information dynamically, use:

API V1

async function updateSession(newSessionData) {
const updated = await fetch("https://api.purse-sandbox.com/payment/v1", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_TOKEN"
},
body: JSON.stringify(newSessionData)
}).then(res => res.json());

await widgetManager.setPaymentSession(updated);
}

API V2

async function updateSession(newSessionData) {
try {
await widgetManager.setWidgetData(newSessionData.widget.data);
} catch (e) {
console.log('Error : ', e);
}
}

Manager Methods​

MethodReturn / ActionDescription
getIsPaymentFulfilled()booleanTells whether the session is fully paid.
getRemainingAmountToPay()numberReturns remaining amount in the session.
setPaymentSession(session) (API V1)
setWidgetData(session.widget.data) (API V2)
voidUpdates session information.
resetNavigation()voidResets widget selection to neutral state.