PaymentMethodConfigOptions

PaymentMethodConfigOptions

PaymentMethodConfigOptions

Defines the object which is used to construct the PaymentMethodHandler.

Signature

interface PaymentMethodConfigOptions<T extends PaymentMethodArgs = PaymentMethodArgs> extends ConfigurableOperationDefOptions<T> {
  createPayment: CreatePaymentFn<T>;
  settlePayment: SettlePaymentFn<T>;
  createRefund?: CreateRefundFn<T>;
  onStateTransitionStart?: OnTransitionStartFn<PaymentState, PaymentTransitionData>;
}

Extends

Members

createPayment

property
type:
CreatePaymentFn<T>
This function provides the logic for creating a payment. For example, it may call out to a third-party service with the data and should return a CreatePaymentResult object contains the details of the payment.

settlePayment

property
type:
SettlePaymentFn<T>
This function provides the logic for settling a payment, also known as “capturing”. For payment integrations that settle/capture the payment on creation (i.e. the createPayment() method returns with a state of 'Settled') this method need only return { success: true }.

createRefund

property
type:
CreateRefundFn<T>
This function provides the logic for refunding a payment created with this payment method. Some payment providers may not provide the facility to programmatically create a refund. In such a case, this method should be omitted and any Refunds will have to be settled manually by an administrator.

onStateTransitionStart

This function, when specified, will be invoked before any transition from one PaymentState to another. The return value (a sync / async boolean) is used to determine whether the transition is permitted.