diff --git a/src/app/checkout/CheckoutSupport.ts b/src/app/checkout/CheckoutSupport.ts new file mode 100644 index 0000000000..b8aae81c77 --- /dev/null +++ b/src/app/checkout/CheckoutSupport.ts @@ -0,0 +1,10 @@ +export default interface CheckoutSupport { + /** + * Check if a feature is supported. + * + * If a feature is not supported, the call will throw an error. + * Otherwise, it will return true. It will always return true if the + * application is not running as Embedded Checkout. + */ + isSupported(...ids: string[]): boolean; +} diff --git a/src/app/checkout/NoopCheckoutSupport.ts b/src/app/checkout/NoopCheckoutSupport.ts new file mode 100644 index 0000000000..5ef2aea3cb --- /dev/null +++ b/src/app/checkout/NoopCheckoutSupport.ts @@ -0,0 +1,7 @@ +import CheckoutSupport from './CheckoutSupport'; + +export default class NoopCheckoutSupport implements CheckoutSupport { + isSupported(): boolean { + return true; + } +} diff --git a/src/app/checkout/index.ts b/src/app/checkout/index.ts index 35c2f78a07..2a97d16db8 100644 --- a/src/app/checkout/index.ts +++ b/src/app/checkout/index.ts @@ -1,10 +1,13 @@ import { CheckoutContextProps } from './CheckoutContext'; import { CheckoutProviderProps, CheckoutProviderState } from './CheckoutProvider'; +import CheckoutSupport from './CheckoutSupport'; export type CheckoutContextProps = CheckoutContextProps; export type CheckoutProviderProps = CheckoutProviderProps; export type CheckoutProviderState = CheckoutProviderState; +export type CheckoutSupport = CheckoutSupport; export { default as CheckoutContext } from './CheckoutContext'; export { default as CheckoutProvider } from './CheckoutProvider'; export { default as withCheckout } from './withCheckout'; +export { default as NoopCheckoutSupport } from './NoopCheckoutSupport';