PaymentProviderService
Helps retrieve payment providers
Constructors
constructor
**new PaymentProviderService**(container)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredpaymentService_
Protected get**paymentService_**(): [PaymentService](/references/services/classes/PaymentService)
Returns
Methods
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter 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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>RequiredauthorizePayment
**authorizePayment**(paymentSession, context): Promise<undefined \| [PaymentSession](/references/services/classes/PaymentSession)>
Parameters
context
Record<string, unknown>RequiredReturns
Promise<undefined | PaymentSession>
buildPaymentProcessorContext
Protected **buildPaymentProcessorContext**(cartOrData): [Cart](/references/services/classes/Cart) & [PaymentContext](/references/services/types/PaymentContext)
Build the create session context for both legacy and new API
Parameters
Returns
Cart & PaymentContext
Cart & PaymentContextcancelPayment
**cancelPayment**(paymentObj): Promise<[Payment](/references/services/classes/Payment)>
Parameters
Returns
Promise<Payment>
capturePayment
**capturePayment**(paymentObj): Promise<[Payment](/references/services/classes/Payment)>
Parameters
Returns
Promise<Payment>
createPayment
**createPayment**(data): Promise<[Payment](/references/services/classes/Payment)>
Parameters
Returns
Promise<Payment>
createSession
**createSession**(providerId, cart): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Parameters
providerId
stringRequiredReturns
Promise<PaymentSession>
Deprecated
**createSession**(sessionInput): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Creates a payment session with the given provider.
Parameters
Returns
Promise<PaymentSession>
deleteSession
**deleteSession**(paymentSession): Promise<undefined \| [PaymentSession](/references/services/classes/PaymentSession)>
Parameters
Returns
Promise<undefined | PaymentSession>
getStatus
**getStatus**(payment): Promise<[PaymentSessionStatus](/references/services/enums/PaymentSessionStatus)>
Parameters
Returns
Promise<PaymentSessionStatus>
list
**list**(): Promise<[PaymentProvider](/references/services/classes/PaymentProvider)[]>
Returns
Promise<PaymentProvider[]>
listPayments
**listPayments**(selector, config?): Promise<[Payment](/references/services/classes/Payment)[]>
List all the payments according to the given selector and config.
Parameters
Returns
Promise<Payment[]>
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
data
objectRequiredDefault: {}
data.customer
objectdata.customer.id
stringReturns
Promise<void>
Promise
Promise<void>RequiredrefreshSession
**refreshSession**(paymentSession, sessionInput): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Refreshes a payment session with the given provider. This means, that we delete the current one and create a new.
Parameters
paymentSession
objectRequiredpaymentSession.data
Record<string, unknown>RequiredpaymentSession.id
stringRequiredpaymentSession.provider_id
stringRequiredReturns
Promise<PaymentSession>
refundFromPayment
**refundFromPayment**(payment, amount, reason, note?): Promise<[Refund](/references/services/classes/Refund)>
Parameters
amount
numberRequiredreason
stringRequirednote
stringReturns
Promise<Refund>
refundPayment
**refundPayment**(payObjs, amount, reason, note?): Promise<[Refund](/references/services/classes/Refund)>
Parameters
Returns
Promise<Refund>
registerInstalledProviders
**registerInstalledProviders**(providerIds): Promise<void>
Parameters
providerIds
string[]RequiredReturns
Promise<void>
Promise
Promise<void>RequiredretrievePayment
**retrievePayment**(paymentId, relations?): Promise<[Payment](/references/services/classes/Payment)>
Retrieve a payment entity with the given id.
Parameters
paymentId
stringRequiredrelations
string[]RequiredDefault: []
Returns
Promise<Payment>
retrieveProvider
**retrieveProvider**<TypeParameter TProvider>(providerId): TProvider extends [AbstractPaymentService](/references/services/classes/AbstractPaymentService) ? [AbstractPaymentService](/references/services/classes/AbstractPaymentService) : TProvider extends [AbstractPaymentProcessor](/references/services/classes/AbstractPaymentProcessor) ? [AbstractPaymentProcessor](/references/services/classes/AbstractPaymentProcessor) : any
Finds a provider given an id
TProvider
unknownRequiredParameters
providerId
stringRequiredReturns
TProvider
extends AbstractPaymentService ? AbstractPaymentService : TProvider
extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any
TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : any
TProvider extends AbstractPaymentService ? AbstractPaymentService : TProvider extends AbstractPaymentProcessor ? AbstractPaymentProcessor : anyretrieveRefund
**retrieveRefund**(id, config?): Promise<[Refund](/references/services/classes/Refund)>
Parameters
id
stringRequiredDefault: {}
Returns
Promise<Refund>
retrieveSession
**retrieveSession**(paymentSessionId, relations?): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Return the payment session for the given id.
Parameters
paymentSessionId
stringRequiredrelations
string[]RequiredDefault: []
Returns
Promise<PaymentSession>
saveSession
Protected **saveSession**(providerId, data): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Create or update a Payment session data.
Parameters
providerId
stringRequireddata
objectRequireddata.amount
numberdata.cartId
stringdata.isInitiated
booleandata.isSelected
booleandata.payment_session_id
stringdata.sessionData
Record<string, unknown>Requireddata.status
PaymentSessionStatusReturns
Promise<PaymentSession>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanthrowFromPaymentProcessorError
Private **throwFromPaymentProcessorError**(errObj): void
Parameters
Returns
void
void
voidupdatePayment
**updatePayment**(paymentId, data): Promise<[Payment](/references/services/classes/Payment)>
Parameters
paymentId
stringRequireddata
objectRequireddata.order_id
stringdata.swap_id
stringReturns
Promise<Payment>
updateSession
**updateSession**(paymentSession, sessionInput): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Update a payment session with the given provider.
Parameters
paymentSession
objectRequiredpaymentSession.data
Record<string, unknown>RequiredpaymentSession.id
stringRequiredpaymentSession.provider_id
stringRequiredReturns
Promise<PaymentSession>
updateSessionData
**updateSessionData**(paymentSession, data): Promise<[PaymentSession](/references/services/classes/PaymentSession)>
Parameters
data
Record<string, unknown>RequiredReturns
Promise<PaymentSession>
withTransaction
**withTransaction**(transactionManager?): [PaymentProviderService](/references/services/classes/PaymentProviderService)
Parameters
transactionManager
EntityManager