import { CustomFieldsDraft, Money, Payment, PaymentDraft, PaymentMethodInfoDraft, TransactionState, TransactionType } from '@commercetools/platform-sdk'; import { CommercetoolsAPI } from './api.type'; import { Logger } from '../../logger'; export type PaymentAmount = { centAmount: number; currencyCode: string; fractionDigits: number; }; export type PaymentServiceOptions = { ctAPI: CommercetoolsAPI; logger: Logger; }; export type GetPayment = { id: string; version?: number; }; export type FindPaymentsByInterfaceId = { interfaceId: string; }; export type PSPInteraction = { request?: string; response?: string; }; export type TransactionData = { type: TransactionType; amount: Money; interactionId?: string; interfaceId?: string; state: TransactionState; }; export type UpdatePayment = { id: string; pspReference?: string; pspInteractions?: CustomFieldsDraft[]; transaction?: TransactionData; paymentMethod?: string; paymentMethodInfo?: PaymentMethodInfoDraft; customFields?: CustomFieldsDraft; token?: string; }; export type FindTransaction = { payment: Payment; transactionType: TransactionType; states: TransactionState[]; }; /** * Payment service interface exposes methods to interact with the commercetools platform API. */ export interface PaymentService { getPayment(opts: GetPayment): Promise; findPaymentsByInterfaceId(opts: FindPaymentsByInterfaceId): Promise; hasTransactionInState(opts: FindTransaction): boolean; createPayment(draft: PaymentDraft): Promise; updatePayment(opts: UpdatePayment): Promise; }