Skip to main content
Skip to main content

PaymentProviderService

internal.internal.PaymentProviderService

Helps retrieve payment providers

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
throwFromPaymentProcessorErroranyRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_


paymentService_

Protected get paymentService_(): PaymentService

Returns

PaymentService

defaultPaymentServiceRequired

Methods

atomicPhase_

Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>

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

Inherited from

TransactionBaseService.atomicPhase_


authorizePayment

authorizePayment(paymentSession, context): Promise<undefined | PaymentSession>

Parameters

paymentSessionPaymentSessionRequired
contextRecord<string, unknown>Required

Returns

Promise<undefined | PaymentSession>

PromisePromise<undefined | PaymentSession>Required

buildPaymentProcessorContext

Protected buildPaymentProcessorContext(cartOrData): Cart & PaymentContext

Build the create session context for both legacy and new API

Parameters

cartOrDataCart | PaymentSessionInputRequired

Returns

Cart & PaymentContext

[`Cart`](/references/js-client/internal/classes/admin_collections.internal.Cart) & [`PaymentContext`](/references/js-client/internal/modules/admin_discounts.internal.internal#paymentcontext)Cart & PaymentContext

cancelPayment

cancelPayment(paymentObj): Promise<Payment>

Parameters

paymentObjPartial<Payment> & { id: string }Required

Returns

Promise<Payment>

PromisePromise<Payment>Required

capturePayment

capturePayment(paymentObj): Promise<Payment>

Parameters

paymentObjPartial<Payment> & { id: string }Required

Returns

Promise<Payment>

PromisePromise<Payment>Required

createPayment

createPayment(data): Promise<Payment>

Parameters

dataCreatePaymentInputRequired

Returns

Promise<Payment>

PromisePromise<Payment>Required

createSession

createSession(providerId, cart): Promise<PaymentSession>

Parameters

providerIdstringRequired
cartCartRequired

Returns

Promise<PaymentSession>

PromisePromise<PaymentSession>Required

Deprecated

createSession(sessionInput): Promise<PaymentSession>

Creates a payment session with the given provider.

Parameters

sessionInputPaymentSessionInputRequired

Returns

Promise<PaymentSession>

PromisePromise<PaymentSession>Required

deleteSession

deleteSession(paymentSession): Promise<undefined | PaymentSession>

Parameters

paymentSessionPaymentSessionRequired

Returns

Promise<undefined | PaymentSession>

PromisePromise<undefined | PaymentSession>Required

getStatus

getStatus(payment): Promise<PaymentSessionStatus>

Parameters

paymentPaymentRequired

Returns

Promise<PaymentSessionStatus>

PromisePromise<PaymentSessionStatus>Required

list

list(): Promise<PaymentProvider[]>

Returns

Promise<PaymentProvider[]>

PromisePromise<PaymentProvider[]>Required

listPayments

listPayments(selector, config?): Promise<Payment[]>

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

Parameters

selectorSelector<Payment>Required

Returns

Promise<Payment[]>

PromisePromise<Payment[]>Required

processUpdateRequestsData

Protected processUpdateRequestsData(data, paymentResponse): Promise<void>

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

Parameters

dataundefined | { customer?: { id?: string } }Required
paymentResponseRecord<string, unknown> | PaymentSessionResponseRequired

Returns

Promise<void>

PromisePromise<void>Required

refreshSession

refreshSession(paymentSession, sessionInput): Promise<PaymentSession>

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

Promise<PaymentSession>

PromisePromise<PaymentSession>Required
the payment session

refundFromPayment

refundFromPayment(payment, amount, reason, note?): Promise<Refund>

Parameters

paymentPaymentRequired
amountnumberRequired
reasonstringRequired
notestring

Returns

Promise<Refund>

PromisePromise<Refund>Required

refundPayment

refundPayment(payObjs, amount, reason, note?): Promise<Refund>

Parameters

payObjsPayment[]Required
amountnumberRequired
reasonstringRequired
notestring

Returns

Promise<Refund>

PromisePromise<Refund>Required

registerInstalledProviders

registerInstalledProviders(providerIds): Promise<void>

Parameters

providerIdsstring[]Required

Returns

Promise<void>

PromisePromise<void>Required

retrievePayment

retrievePayment(paymentId, relations?): Promise<Payment>

Retrieve a payment entity with the given id.

Parameters

paymentIdstringRequired
relationsstring[]

Returns

Promise<Payment>

PromisePromise<Payment>Required

retrieveProvider

retrieveProvider<TProvider>(providerId): TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any

Finds a provider given an id

TProviderunknownRequired

Parameters

providerIdstringRequired
the id of the provider to get

Returns

TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any

`TProvider` extends [`AbstractPaymentService`](/references/js-client/internal/classes/admin_discounts.internal.internal.AbstractPaymentService) ? [`AbstractPaymentService`](/references/js-client/internal/classes/admin_discounts.internal.internal.AbstractPaymentService) : `TProvider` extends [`AbstractPaymentProcessor`](/references/js-client/internal/classes/admin_discounts.internal.internal.AbstractPaymentProcessor) ? [`AbstractPaymentProcessor`](/references/js-client/internal/classes/admin_discounts.internal.internal.AbstractPaymentProcessor) : `any`TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any
the payment provider

retrieveRefund

retrieveRefund(id, config?): Promise<Refund>

Parameters

idstringRequired

Returns

Promise<Refund>

PromisePromise<Refund>Required

retrieveSession

retrieveSession(paymentSessionId, relations?): Promise<PaymentSession>

Return the payment session for the given id.

Parameters

paymentSessionIdstringRequired
relationsstring[]

Returns

Promise<PaymentSession>

PromisePromise<PaymentSession>Required

saveSession

Protected saveSession(providerId, data): Promise<PaymentSession>

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

Promise<PaymentSession>

PromisePromise<PaymentSession>Required

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


updatePayment

updatePayment(paymentId, data): Promise<Payment>

Parameters

paymentIdstringRequired
dataobjectRequired
data.order_idstring
data.swap_idstring

Returns

Promise<Payment>

PromisePromise<Payment>Required

updateSession

updateSession(paymentSession, sessionInput): Promise<PaymentSession>

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

Promise<PaymentSession>

PromisePromise<PaymentSession>Required
the payment session

updateSessionData

updateSessionData(paymentSession, data): Promise<PaymentSession>

Parameters

paymentSessionPaymentSessionRequired
dataRecord<string, unknown>Required

Returns

Promise<PaymentSession>

PromisePromise<PaymentSession>Required

withTransaction

withTransaction(transactionManager?): PaymentProviderService

Parameters

transactionManagerEntityManager

Returns

PaymentProviderService

defaultPaymentProviderServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?