Skip to main content
Skip to main content

PaymentCollectionService

Constructors

constructor

**new PaymentCollectionService**(«destructured»)

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
customerService_CustomerServiceRequired
eventBusService_EventBusServiceRequired
manager_EntityManagerRequired
paymentCollectionRepository_Repository<PaymentCollection> & &#123; getPaymentCollectionIdByPaymentId: Method getPaymentCollectionIdByPaymentId ; getPaymentCollectionIdBySessionId: Method getPaymentCollectionIdBySessionId &#125;Required
paymentProviderService_PaymentProviderServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "payment-collection.created"

Events.DELETEDstringRequired

Default: "payment-collection.deleted"

Events.PAYMENT_AUTHORIZEDstringRequired

Default: "payment-collection.payment_authorized"

Events.UPDATEDstringRequired

Default: "payment-collection.updated"

Accessors

activeManager_

Protected get**activeManager_**(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

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.

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

authorizePaymentSessions

**authorizePaymentSessions**(paymentCollectionId, sessionIds, context?): Promise&#60;[PaymentCollection](/references/services/classes/PaymentCollection)&#62;

Authorizes the payment sessions of a payment collection.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection
sessionIdsstring[]Required
array of payment session ids to be authorized
contextRecord<string, unknown>Required
additional data required by payment providers

Default: {}

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment collection and its payment session.

create

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

Creates a new payment collection.

Parameters

info to create the payment collection

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment collection created.

delete

**delete**(paymentCollectionId): Promise&#60;undefined \| [PaymentCollection](/references/services/classes/PaymentCollection)&#62;

Deletes a payment collection.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection to be removed

Returns

Promise<undefined | PaymentCollection>

PromisePromise<undefined | PaymentCollection>Required
the payment collection removed.

isValidTotalAmount

Private **isValidTotalAmount**(total, sessionsInput): boolean

Parameters

totalnumberRequired

Returns

boolean

booleanboolean

markAsAuthorized

**markAsAuthorized**(paymentCollectionId): Promise&#60;[PaymentCollection](/references/services/classes/PaymentCollection)&#62;

Marks a payment collection as authorized bypassing the payment flow.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment session authorized.

refreshPaymentSession

**refreshPaymentSession**(paymentCollectionId, sessionId, customerId): Promise&#60;[PaymentSession](/references/services/classes/PaymentSession)&#62;

Removes and recreate a payment session of a payment collection.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection
sessionIdstringRequired
the id of the payment session to be replaced
customerIdstringRequired
the id of the customer

Returns

Promise<PaymentSession>

PromisePromise<PaymentSession>Required
the new payment session created.

retrieve

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

Retrieves a payment collection by id.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection
the config to retrieve the payment collection

Default: {}

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment collection.

setPaymentSession

**setPaymentSession**(paymentCollectionId, sessionInput, customerId): Promise&#60;[PaymentCollection](/references/services/classes/PaymentCollection)&#62;

Manages a single payment sessions of a payment collection.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection
object containing payment session info
customerIdstringRequired
the id of the customer

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment collection and its payment session.

setPaymentSessionsBatch

**setPaymentSessionsBatch**(paymentCollectionOrId, sessionsInput, customerId): Promise&#60;[PaymentCollection](/references/services/classes/PaymentCollection)&#62;

Manages multiple payment sessions of a payment collection.

Parameters

paymentCollectionOrIdstring | PaymentCollectionRequired
the id of the payment collection
array containing payment session info
customerIdstringRequired
the id of the customer

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment collection and its payment sessions.

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

boolean

booleanboolean

update

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

Updates a payment collection.

Parameters

paymentCollectionIdstringRequired
the id of the payment collection to update
dataDeepPartial<PaymentCollection>Required
info to be updated

Returns

Promise<PaymentCollection>

PromisePromise<PaymentCollection>Required
the payment collection updated.

withTransaction

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

Parameters

transactionManagerEntityManager

Returns

PaymentCollectionService

Was this section helpful?