Skip to main content
Skip to main content

PaymentProviderService

Helps retrieve payment providers

constructor

Parameters

containerInjectedDependenciesRequired

Properties

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

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

paymentService_

Returns

PaymentServiceobjectRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

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

registerInstalledProviders

Parameters

providerIdsstring[]Required

Returns

PromisePromise<void>Required

list

Returns

PromisePromise<PaymentProvider[]>Required

retrievePayment

Retrieve a payment entity with the given id.

Parameters

paymentIdstringRequired
relationsstring[]Required

Default: []

Returns

PromisePromise<Payment>Required
Retrieve a payment entity with the given id.

listPayments

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

Parameters

selectorSelector<Payment>Required
configFindConfig<Payment>Required

Returns

PromisePromise<Payment[]>Required
List all the payments according to the given selector and config.

retrieveSession

Return the payment session for the given id.

Parameters

paymentSessionIdstringRequired
relationsstring[]Required

Default: []

Returns

PromisePromise<PaymentSession>Required
Return the payment session for the given id.

createSession

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

Parameters

providerIdstringRequired
cartCartRequired

Returns

PromisePromise<PaymentSession>Required

Deprecated

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

Creates a payment session with the given provider.

Parameters

sessionInputPaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required
Creates a payment session with the given provider.

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.idstringRequired
paymentSession.dataRecord<string, unknown>Required
paymentSession.provider_idstringRequired
sessionInputPaymentSessionInputRequired

Returns

PromisePromise<PaymentSession>Required
the payment session

updateSession

Update a payment session with the given provider.

Parameters

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

Returns

PromisePromise<PaymentSession>Required
the payment session

deleteSession

Parameters

paymentSessionPaymentSessionRequired

Returns

PromisePromise<undefined | PaymentSession>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 : anyRequired
the payment provider

createPayment

Parameters

dataCreatePaymentInputRequired

Returns

PromisePromise<Payment>Required

updatePayment

Parameters

paymentIdstringRequired
dataobjectRequired
data.order_idstring
data.swap_idstring

Returns

PromisePromise<Payment>Required

authorizePayment

Parameters

paymentSessionPaymentSessionRequired
contextRecord<string, unknown>Required

Returns

PromisePromise<undefined | PaymentSession>Required

updateSessionData

Parameters

paymentSessionPaymentSessionRequired
dataRecord<string, unknown>Required

Returns

PromisePromise<PaymentSession>Required

cancelPayment

Parameters

paymentObjPartial<Payment> & objectRequired

Returns

PromisePromise<Payment>Required

getStatus

Parameters

paymentPaymentRequired

Returns

PromisePromise<PaymentSessionStatus>Required

capturePayment

Parameters

paymentObjPartial<Payment> & objectRequired

Returns

PromisePromise<Payment>Required

refundPayment

Parameters

payObjsPayment[]Required
amountnumberRequired
reasonstringRequired
notestring

Returns

PromisePromise<Refund>Required

refundFromPayment

Parameters

paymentPaymentRequired
amountnumberRequired
reasonstringRequired
notestring

Returns

PromisePromise<Refund>Required

retrieveRefund

Parameters

idstringRequired
configFindConfig<Refund>Required

Default: {}

Returns

PromisePromise<Refund>Required

buildPaymentProcessorContext

Build the create session context for both legacy and new API

Parameters

cartOrDataCart | PaymentSessionInputRequired

Returns

CartobjectRequired
A cart represents a virtual shopping bag. It can be used to complete an order, a swap, or a claim.
PaymentContextobjectRequired

saveSession

Create or update a Payment session data.

Parameters

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

Returns

PromisePromise<PaymentSession>Required
Create or update a Payment session data.

processUpdateRequestsData

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

Parameters

dataobjectRequired

Default: {}

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

Returns

PromisePromise<void>Required
Process the collected data. Can be used every time we need to process some collected data returned by the provider

throwFromPaymentProcessorError

Parameters

errObjPaymentProcessorErrorRequired

Returns

voidvoidRequired
Was this section helpful?