Payment Method Types

Payment Method Types

OnTransitionStartFn

The signature of the function defined by onStateTransitionStart in PaymentMethodConfigOptions.

This function is called before the state of a Payment is transitioned. Its return value used to determine whether the transition can occur.

Signature

type OnTransitionStartFn<T extends PaymentMethodArgs> = (
    fromState: PaymentState,
    toState: PaymentState,
    args: ConfigArgValues<T>,
    data: PaymentTransitionData,
) => OnTransitionStartReturnType

CreatePaymentResult

This object is the return value of the CreatePaymentFn.

Signature

interface CreatePaymentResult {
  amount: number;
  state: Exclude<PaymentState, 'Refunded' | 'Error'>;
  transactionId?: string;
  errorMessage?: string;
  metadata?: PaymentMetadata;
}

Members

amount

property
type:
number

state

property
type:
Exclude<PaymentState, 'Refunded' | 'Error'>

transactionId

property
type:
string

errorMessage

property
type:
string

metadata

property
type:
PaymentMetadata

CreatePaymentErrorResult

This object is the return value of the CreatePaymentFn when there has been an error.

Signature

interface CreatePaymentErrorResult {
  amount: number;
  state: 'Error';
  transactionId?: string;
  errorMessage: string;
  metadata?: PaymentMetadata;
}

Members

amount

property
type:
number

state

property
type:
'Error'

transactionId

property
type:
string

errorMessage

property
type:
string

metadata

property
type:
PaymentMetadata

CreateRefundResult

This object is the return value of the CreateRefundFn.

Signature

interface CreateRefundResult {
  state: RefundState;
  transactionId?: string;
  metadata?: PaymentMetadata;
}

Members

state

property
type:
RefundState

transactionId

property
type:
string

metadata

property
type:
PaymentMetadata

SettlePaymentResult

This object is the return value of the SettlePaymentFn

Signature

interface SettlePaymentResult {
  success: boolean;
  errorMessage?: string;
  metadata?: PaymentMetadata;
}

Members

success

property
type:
boolean

errorMessage

property
type:
string

metadata

property
type:
PaymentMetadata

CreatePaymentFn

This function contains the logic for creating a payment. See PaymentMethodHandler for an example.

Signature

type CreatePaymentFn<T extends PaymentMethodArgs> = (
    order: Order,
    args: ConfigArgValues<T>,
    metadata: PaymentMetadata,
) => CreatePaymentResult | CreatePaymentErrorResult | Promise<CreatePaymentResult | CreatePaymentErrorResult>

SettlePaymentFn

This function contains the logic for settling a payment. See PaymentMethodHandler for an example.

Signature

type SettlePaymentFn<T extends PaymentMethodArgs> = (
    order: Order,
    payment: Payment,
    args: ConfigArgValues<T>,
) => SettlePaymentResult | Promise<SettlePaymentResult>

CreateRefundFn

This function contains the logic for creating a refund. See PaymentMethodHandler for an example.

Signature

type CreateRefundFn<T extends PaymentMethodArgs> = (
    input: RefundOrderInput,
    total: number,
    order: Order,
    payment: Payment,
    args: ConfigArgValues<T>,
) => CreateRefundResult | Promise<CreateRefundResult>