Skip to main content
Skip to main content

PaymentService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
eventBusService_EventBusServiceRequired
manager_EntityManagerRequired
paymentProviderService_PaymentProviderServiceRequired
paymentRepository_Repository<Payment>Required
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "payment.created"

Events.PAYMENT_CAPTUREDstringRequired

Default: "payment.payment_captured"

Events.PAYMENT_CAPTURE_FAILEDstringRequired

Default: "payment.payment_capture_failed"

Events.REFUND_CREATEDstringRequired

Default: "payment.payment_refund_created"

Events.REFUND_FAILEDstringRequired

Default: "payment.payment_refund_failed"

Events.UPDATEDstringRequired

Default: "payment.updated"


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

capture

Captures a payment.

Parameters

paymentOrIdstring | PaymentRequired
the id or the class instance of the payment

Returns

PromisePromise<Payment>Required
the payment captured.

create

Created a new payment.

Parameters

paymentInputPaymentDataInputRequired
info to create the payment

Returns

PromisePromise<Payment>Required
the payment created.

refund

refunds a payment.

Parameters

paymentOrIdstring | PaymentRequired
the id or the class instance of the payment
amountnumberRequired
the amount to be refunded from the payment
reasonstringRequired
the refund reason
notestring
additional note of the refund

Returns

PromisePromise<Refund>Required
the refund created.

retrieve

Retrieves a payment by id.

Parameters

paymentIdstringRequired
the id of the payment
configFindConfig<Payment>Required
the config to retrieve the payment

Default: {}

Returns

PromisePromise<Payment>Required
the payment.

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

update

Updates a payment in order to link it to an order or a swap.

Parameters

paymentIdstringRequired
the id of the payment
dataobjectRequired
order_id or swap_id to link the payment
data.order_idstring
data.swap_idstring

Returns

PromisePromise<Payment>Required
the payment updated.

withTransaction

Parameters

transactionManagerEntityManager

Returns

PaymentServiceobjectRequired
Was this section helpful?