getPaymentInfo(payment: BasketPayment): HTMLTemplateElement | undefined¶
The getPaymentInfo
method retrieves the payment information template 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 template is to be retrieved.
Returned value¶
A returned value has a type of HTMLTemplateElement | undefined
, which is the HTML template containing payment information or undefined
if no template is associated with the specified payment method.
Example¶
In this example, we use the basketPaymentsApi
to retrieve the payment information template for a selected payment option.
useStorefront(async (storefront) => {
let basketPaymentsApi = storefront.getApiSync('basketPaymentsApi');
if (!basketPaymentsApi) {
const featureSystemApi = this.getApiSync('FeatureSystemApi');
await featureSystemApi.registerDynamic('basket');
basketPaymentsApi = storefront.getApiSync('basketPaymentsApi');
}
const selectedPayment = {
id: 'credit-card',
name: 'Credit Card',
// ... other payment properties
};
const paymentInfo = basketPaymentsApi.getPaymentInfo(selectedPayment);
if (paymentInfo) {
console.log('Payment information template:', paymentInfo);
} else {
console.log('No payment information available for the selected payment option.');
}
});
Basket Payments API methods reference¶
- get
- select$
- getAvailable
- selectAvailable$
- setPayment
- setPaymentData
- getSelectedPayment
- selectSelectedPayment$
- getActivePaymentCost
- selectActivePaymentCost$
- getPaymentChannelStrategy
- addPaymentChannelStrategy
- addPaymentInfo
- getSectionValidation
- selectSectionValidation$