selectAvailable$(): Observable<BasketPayment[]>¶
The selectAvailable$
method provides an observable stream of the available payment options, allowing you to subscribe to real-time updates based on changes in the basket's state or user eligibility.
Returned value¶
A returned value has a type of Observable<BasketPayment[]>
where BasketPayment
represents the BasketPayment model, which emits the current list of available payment methods and updates whenever there are changes.
Example¶
In this example, we subscribe to the selectAvailable$
observable to monitor available payment options.
useStorefront(async ({ eventBus, getApi }) => {
eventBus.on('basket.initialized', async () => {
const basketPaymentsApi = await getApi('basketPaymentsApi');
const availablePaymentOptions$ = basketPaymentsApi.selectAvailable$();
availablePaymentOptions$.subscribe((availablePaymentOptions) => {
console.log('Updated available payment options:', availablePaymentOptions);
});
});
});
Basket Payments API methods reference¶
- get
- select$
- getAvailable
- setPayment
- setPaymentData
- getSelectedPayment
- selectSelectedPayment$
- getActivePaymentCost
- selectActivePaymentCost$
- getPaymentChannelStrategy
- addPaymentChannelStrategy
- addPaymentInfo
- getPaymentInfo
- getSectionValidation
- selectSectionValidation$