Skip to main content
Skip to main content

PaymentProviderService

Helps retrieve payment providers

constructor

Parameters

containerInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
container_InjectedDependenciesRequired
customerService_CustomerServiceRequired
featureFlagRouter_FlagRouterRequired
logger_LoggerRequired
manager_EntityManagerRequired
paymentProviderRepository_Repository<PaymentProvider>Required
paymentRepository_Repository<Payment>Required
paymentSessionRepository_Repository<PaymentSession>Required
refundRepository_Repository<Refund>Required
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

paymentService_

Returns

PaymentServiceobjectRequired

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
contextRecord<string, unknown>Required

Returns

PromisePromise<undefined | PaymentSession>Required

buildPaymentProcessorContext

Build the create session context for both legacy and new API

Parameters

cartOrDataCart | PaymentSessionInputRequired

Returns

Cart & PaymentContextCart & PaymentContext

cancelPayment

Parameters

paymentObjPartial<Payment> & objectRequired

Returns

PromisePromise<Payment>Required

capturePayment

Parameters

paymentObjPartial<Payment> & objectRequired

Returns

PromisePromise<Payment>Required

createPayment

Parameters

dataCreatePaymentInputRequired

Returns

PromisePromise<Payment>Required

createSession

**createSession**(providerId, cart): Promise&#60;[PaymentSession](/references/entities/classes/PaymentSession)&#62;

Parameters

providerIdstringRequired
cartCartRequired

Returns

PromisePromise<PaymentSession>Required

Deprecated

**createSession**(sessionInput): Promise&#60;[PaymentSession](/references/entities/classes/PaymentSession)&#62;

Creates a payment session with the given provider.

Parameters

sessionInputPaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required

deleteSession

Parameters

paymentSessionPaymentSessionRequired

Returns

PromisePromise<undefined | PaymentSession>Required

getStatus

Parameters

paymentPaymentRequired

Returns

PromisePromise<PaymentSessionStatus>Required

list

Returns

PromisePromise<PaymentProvider[]>Required

listPayments

List all the payments according to the given selector and config.

Parameters

selectorSelector<Payment>Required
configFindConfig<Payment>Required

Returns

PromisePromise<Payment[]>Required

processUpdateRequestsData

Process the collected data. Can be used every time we need to process some collected data returned by the provider

Parameters

dataobjectRequired

Default: {}

data.customerobject
data.customer.idstring
paymentResponseRecord<string, unknown> | PaymentSessionResponseRequired

Returns

PromisePromise<void>Required

refreshSession

Refreshes a payment session with the given provider. This means, that we delete the current one and create a new.

Parameters

paymentSessionobjectRequired
the payment session object to update
paymentSession.dataRecord<string, unknown>Required
paymentSession.idstringRequired
paymentSession.provider_idstringRequired
sessionInputPaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required
the payment session

refundFromPayment

Parameters

paymentPaymentRequired
amountnumberRequired
reasonstringRequired
notestring

Returns

PromisePromise<Refund>Required

refundPayment

Parameters

payObjsPayment[]Required
amountnumberRequired
reasonstringRequired
notestring

Returns

PromisePromise<Refund>Required

registerInstalledProviders

Parameters

providerIdsstring[]Required

Returns

PromisePromise<void>Required

retrievePayment

Retrieve a payment entity with the given id.

Parameters

paymentIdstringRequired
relationsstring[]Required

Default: []

Returns

PromisePromise<Payment>Required

retrieveProvider

Finds a provider given an id

Type Parameters

TProviderunknownRequired

Parameters

providerIdstringRequired
the id of the provider to get

Returns

TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : anyTProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any
the payment provider

retrieveRefund

Parameters

idstringRequired
configFindConfig<Refund>Required

Default: {}

Returns

PromisePromise<Refund>Required

retrieveSession

Return the payment session for the given id.

Parameters

paymentSessionIdstringRequired
relationsstring[]Required

Default: []

Returns

PromisePromise<PaymentSession>Required

saveSession

Create or update a Payment session data.

Parameters

providerIdstringRequired
dataobjectRequired
data.amountnumber
data.cartIdstring
data.isInitiatedboolean
data.isSelectedboolean
data.payment_session_idstring
data.sessionDataRecord<string, unknown>Required

Returns

PromisePromise<PaymentSession>Required

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

throwFromPaymentProcessorError

Parameters

errObjPaymentProcessorErrorRequired

Returns

voidvoid

updatePayment

Parameters

paymentIdstringRequired
dataobjectRequired
data.order_idstring
data.swap_idstring

Returns

PromisePromise<Payment>Required

updateSession

Update a payment session with the given provider.

Parameters

paymentSessionobjectRequired
The paymentSession to update
paymentSession.dataRecord<string, unknown>Required
paymentSession.idstringRequired
paymentSession.provider_idstringRequired
sessionInputCart | PaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required
the payment session

updateSessionData

Parameters

paymentSessionPaymentSessionRequired
dataRecord<string, unknown>Required

Returns

PromisePromise<PaymentSession>Required

withTransaction

Parameters

transactionManagerEntityManager

Returns

PaymentProviderServiceobjectRequired
Helps retrieve payment providers
Was this section helpful?