Skip to main content

PaymentMethodEligibilityChecker

PaymentMethodEligibilityChecker

The PaymentMethodEligibilityChecker class is used to check whether an order qualifies for a given PaymentMethod.

Example

const ccPaymentEligibilityChecker = new PaymentMethodEligibilityChecker({
code: 'order-total-payment-eligibility-checker',
description: [{ languageCode: LanguageCode.en, value: 'Checks that the order total is above some minimum value' }],
args: {
orderMinimum: { type: 'int', ui: { component: 'currency-form-input' } },
},
check: (ctx, order, args) => {
return order.totalWithTax >= args.orderMinimum;
},
});
Signature
class PaymentMethodEligibilityChecker<T extends ConfigArgs = ConfigArgs> extends ConfigurableOperationDef<T> {
constructor(config: PaymentMethodEligibilityCheckerConfig<T>)
}

constructor

method
(config: PaymentMethodEligibilityCheckerConfig<T>) => PaymentMethodEligibilityChecker

PaymentMethodEligibilityCheckerConfig

Configuration passed into the constructor of a PaymentMethodEligibilityChecker to configure its behavior.

Signature
interface PaymentMethodEligibilityCheckerConfig<T extends ConfigArgs> extends ConfigurableOperationDefOptions<T> {
check: CheckPaymentMethodEligibilityCheckerFn<T>;
}

CheckPaymentMethodEligibilityCheckerFn

A function which implements logic to determine whether a given Order is eligible for a particular payment method. If the function resolves to false or a string, the check is considered to have failed. A string result can be used to provide information about the reason for ineligibility, if desired.

Signature
type CheckPaymentMethodEligibilityCheckerFn<T extends ConfigArgs> = (
ctx: RequestContext,
order: Order,
args: ConfigArgValues<T>,
method: PaymentMethod,
) => boolean | string | Promise<boolean | string>