Skip to main content
Skip to main content

AbstractPaymentService

This will be

Deprecated

in the near future use the AbstractPaymentProcessor instead

constructor

Parameters

containerunknownRequired
configRecord<string, unknown>

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
identifierstringRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

atomicPhase_

Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.

Type Parameters

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

PromisePromise<TResult>Required
the result of the transactional work

authorizePayment

Parameters

paymentSessionPaymentSessionRequired
A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.
contextDataRequired

Returns

PromisePromise<object>Required

Deprecated


cancelPayment

This will be

Parameters

paymentPaymentRequired
A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.

Returns

PromisePromise<Data>Required

Deprecated

in the near future


capturePayment

This will be

Parameters

paymentPaymentRequired
A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.

Returns

PromisePromise<Data>Required

Deprecated

in the near future


createPayment

Abstract **createPayment**(context): Promise&#60;[PaymentSessionResponse](/references/medusa/types/medusa.PaymentSessionResponse)&#62;

Parameters

contextCart & PaymentContextRequired
The type of this argument is meant to be temporary and once the previous method signature will be removed, the type will only be PaymentContext instead of Cart & PaymentContext

Returns

PromisePromise<PaymentSessionResponse>Required

Abstract **createPayment**(cart): Promise&#60;[Data](/references/medusa/types/medusa.Data)&#62;

This will be

Parameters

cartCartRequired

Returns

PromisePromise<Data>Required

Deprecated

in the near future use createPayment(context: Cart & PaymentContext): Promise<PaymentSessionResponse> instead


deletePayment

This will be

Parameters

paymentSessionPaymentSessionRequired
A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.

Returns

PromisePromise<void>Required

Deprecated

in the near future


getIdentifier

Returns

stringstring

getPaymentData

Parameters

paymentSessionPaymentSessionRequired
A Payment Session is created when a Customer initilizes the checkout flow, and can be used to hold the state of a payment flow. Each Payment Session is controlled by a Payment Provider, which is responsible for the communication with external payment services. Authorized Payment Sessions will eventually get promoted to Payments to indicate that they are authorized for payment processing such as capture or refund. Payment sessions can also be used as part of payment collections.

Returns

PromisePromise<Data>Required

Deprecated


getStatus

This will be

Parameters

dataDataRequired

Returns

PromisePromise<PaymentSessionStatus>Required

Deprecated

in the near future


refundPayment

This will be

Parameters

paymentPaymentRequired
A payment is originally created from a payment session. Once a payment session is authorized, the payment is created to represent the authorized amount with a given payment method. Payments can be captured, canceled or refunded. Payments can be made towards orders, swaps, order edits, or other resources.
refundAmountnumberRequired

Returns

PromisePromise<Data>Required

Deprecated

in the near future


retrievePayment

Parameters

paymentDataDataRequired

Returns

PromisePromise<Data>Required

Deprecated


retrieveSavedMethods

This will be

Parameters

customerCustomerRequired
A customer can make purchases in your store and manage their profile.

Returns

PromisePromise<Data[]>Required

Deprecated

in the near future


shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

updatePayment

Abstract **updatePayment**(paymentSessionData, context): Promise&#60;Record&#60;string, unknown&#62; \| [PaymentSessionResponse](/references/medusa/types/medusa.PaymentSessionResponse)&#62;

Parameters

paymentSessionDataDataRequired
contextCart & PaymentContextRequired
The type of this argument is meant to be temporary and once the previous method signature will be removed, the type will only be PaymentContext instead of Cart & PaymentContext

Returns

PromisePromise<Record<string, unknown> | PaymentSessionResponse>Required
it return either a PaymentSessionResponse or PaymentSessionResponse["session_data"] to maintain backward compatibility

Abstract **updatePayment**(paymentSessionData, cart): Promise&#60;[Data](/references/medusa/types/medusa.Data)&#62;

This will be

Parameters

paymentSessionDataDataRequired
cartCartRequired

Returns

PromisePromise<Data>Required

Deprecated

in the near future use updatePayment(paymentSessionData: PaymentSessionData, context: Cart & PaymentContext): Promise<PaymentSessionResponse> instead


updatePaymentData

Parameters

paymentSessionDataDataRequired
dataDataRequired

Returns

PromisePromise<Data>Required

Deprecated


withTransaction

Parameters

transactionManagerEntityManager

Returns

constructor(container: unknown, config?: Record<string, unknown>) => AbstractPaymentServiceRequired
__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
identifierstringRequired
activeManager_objectRequired
atomicPhase_<TResult, TError>(work: (transactionManager: EntityManager) => Promise<TResult>, isolationOrErrorHandler?: IsolationLevel | (error: TError) => Promise<void | TResult>, maybeErrorHandlerOrDontFail?: (error: TError) => Promise<void | TResult>) => Promise<TResult>Required
authorizePayment(paymentSession: PaymentSession, context: Data) => Promise<{ data: Data ; status: PaymentSessionStatus }>Required
cancelPayment(payment: Payment) => Promise<Data>Required
capturePayment(payment: Payment) => Promise<Data>Required
createPayment(context: Cart & PaymentContext) => Promise<PaymentSessionResponse>(cart: Cart) => Promise<Data>Required
deletePayment(paymentSession: PaymentSession) => Promise<void>Required
getIdentifier() => stringRequired
getPaymentData(paymentSession: PaymentSession) => Promise<Data>Required
getStatus(data: Data) => Promise<PaymentSessionStatus>Required
refundPayment(payment: Payment, refundAmount: number) => Promise<Data>Required
retrievePayment(paymentData: Data) => Promise<Data>Required
retrieveSavedMethods(customer: Customer) => Promise<Data[]>Required
shouldRetryTransaction_(err: Record<string, unknown> | { code: string }) => booleanRequired
updatePayment(paymentSessionData: Data, context: Cart & PaymentContext) => Promise<Record<string, unknown> | PaymentSessionResponse>(paymentSessionData: Data, cart: Cart) => Promise<Data>Required
updatePaymentData(paymentSessionData: Data, data: Data) => Promise<Data>Required
withTransaction(transactionManager?: EntityManager) => AbstractPaymentServiceRequired
Was this section helpful?