getActivePaymentCost(): FullPrice | undefined¶
The getActivePaymentCost
method retrieves the cost associated with the currently active payment option in the basket's shipping configuration.
Returned value¶
A returned value has a type of FullPrice | undefined
where FullPrice
represents the FullPrice model indicating the cost details of the active payment method or undefined
if no payment method is active.
Example¶
In this example, we use the basketPaymentsApi
to get the cost of the active 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 activePaymentCost = basketPaymentsApi.getActivePaymentCost();
if (activePaymentCost) {
console.log('Active payment cost:', activePaymentCost);
} else {
console.log('No active payment cost available.');
}
});
Basket Payments API methods reference¶
- get
- select$
- getAvailable
- selectAvailable$
- setPayment
- setPaymentData
- getSelectedPayment
- selectSelectedPayment$
- selectActivePaymentCost$
- getPaymentChannelStrategy
- addPaymentChannelStrategy
- addPaymentInfo
- getPaymentInfo
- getSectionValidation
- selectSectionValidation$