Skip to content

getPaymentChannelStrategy(channelKey?: string): IPaymentChannel

The getPaymentChannelStrategy method retrieves the payment channel strategy associated with a specific channel key. This allows for customized payment processing based on different channels.

Input parameters

channelKey

channelKey is an optional parameter of type string that identifies the specific payment channel strategy to retrieve. If omitted, a default strategy may be returned.

Returned value

A returned value has a type of IPaymentChannel, representing the strategy or configuration used by the specified payment channel.

Example

In this example, we use the basketShippingsApi to retrieve the payment channel strategy for a given channel key.

useStorefront(async (storefront) => {
    let basketShippingsApi = storefront.getApiSync('basketShippingsApi');

    if (!basketShippingsApi) {
        const featureSystemApi = this.getApiSync('FeatureSystemApi');
        await featureSystemApi.registerDynamic('basket');

        basketShippingsApi = storefront.getApiSync('basketShippingsApi');
    }

    const channelKey = 'paypal';
    const paymentChannelStrategy = basketShippingsApi.getPaymentChannelStrategy(channelKey);

    console.log(`Payment channel strategy for ${channelKey}:`, paymentChannelStrategy);
});

Basket Shippings API methods reference

Objects reference