All files / app/embeddedCheckout EmbeddedCheckoutSupport.ts

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29        6x   6x   3x 3x     7x 2x 3x     2x 1x     1x           6x  
import { LanguageService } from '@bigcommerce/checkout-sdk';
 
import { CheckoutSupport } from '../checkout';
 
import { EmbeddedCheckoutUnsupportedError } from './errors';
 
export default class EmbeddedCheckoutSupport implements CheckoutSupport {
    constructor(
        private unsupportedMethods: string[],
        private langService: LanguageService
    ) {}
 
    isSupported(...ids: string[]): boolean {
        const unsupportedMethods = ids.filter(id =>
            this.unsupportedMethods.indexOf(id) >= 0
        );
 
        if (unsupportedMethods.length === 0) {
            return true;
        }
 
        throw new EmbeddedCheckoutUnsupportedError(
            this.langService.translate('embedded_checkout.unsupported_error', {
                methods: unsupportedMethods.join(', '),
            })
        );
    }
}