Skip to content

getPaymentInfo(payment: BasketPayment): Map<string, HTMLTemplateElement>

The getPaymentInfo method retrieves a map of payment information templates associated with a specific payment option within the basket's shipping configuration.

Input parameters

payment

payment is a mandatory parameter which represents the BasketPayment model specifying the payment method whose information templates are to be retrieved.

Returned value

A returned value has a type of Map<string, HTMLTemplateElement>, which is a map where keys are string identifiers and values are HTML templates containing payment information for the specified payment method.

Example

In this example, we use the basketPaymentsApi to retrieve the payment information templates for a selected payment option.

useStorefront(async ({ eventBus, getApi }) => {
    eventBus.on('basket.initialized', async () => {
        const basketPaymentsApi = await getApi('basketPaymentsApi');

        const selectedPayment = basketPaymentsApi.getSelectedPayment();

        if (selectedPayment) {
            const paymentInfoMap = basketPaymentsApi.getPaymentInfo(selectedPayment);

            console.log('Payment information templates:', paymentInfoMap);

            // Iterate through the map
            paymentInfoMap.forEach((template, key) => {
                console.log(`Template key: ${key}`, template);
            });
        }
    });
});

Basket Payments API methods reference

Models reference