Skip to main content
Skip to main content

PaymentService

Constructors

constructor

**new PaymentService**(«destructured»)

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_

Protected activeManager_: [object Object]

Methods

atomicPhase_

Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

capture

**capture**(paymentOrId): Promise&#60;[Payment](/references/services/classes/Payment)&#62;

Captures a payment.

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

Promise<Payment>

PromisePromise<Payment>Required
the payment captured.

create

**create**(paymentInput): Promise&#60;[Payment](/references/services/classes/Payment)&#62;

Created a new payment.

Parameters
paymentInputPaymentDataInputRequired
info to create the payment
Returns

Promise<Payment>

PromisePromise<Payment>Required
the payment created.

refund

**refund**(paymentOrId, amount, reason, note?): Promise&#60;[Refund](/references/services/classes/Refund)&#62;

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

Promise<Refund>

PromisePromise<Refund>Required
the refund created.

retrieve

**retrieve**(paymentId, config?): Promise&#60;[Payment](/references/services/classes/Payment)&#62;

Retrieves a payment by id.

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

Default: {}

Returns

Promise<Payment>

PromisePromise<Payment>Required
the payment.

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters
errRecord<string, unknown> | { code: string }Required
Returns

boolean

booleanboolean

update

**update**(paymentId, data): Promise&#60;[Payment](/references/services/classes/Payment)&#62;

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

Promise<Payment>

PromisePromise<Payment>Required
the payment updated.

withTransaction

**withTransaction**(transactionManager?): [PaymentService](/references/services/classes/PaymentService)

Parameters
transactionManagerEntityManager
Returns

PaymentService

defaultPaymentServiceRequired
Was this section helpful?