Methods
(async, static) approvePayment(paymentKey, actionBy) → {Promise.<Payment>}
Given a paymentKey it does the following:
- Gets the last payment for the key and checks tha its pending
- Add a new row with
approvedstate with the same info - Request payment to external payment system/s
- Add a new roww with
requestedstate
If any of the steps fails it throws an error.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
string | Payment key |
actionBy |
string | Action executor |
Returns:
The approved payment
- Type
- Promise.<Payment>
(async, static) batchApprovePayments(paymentKeys, actionBy) → {Promise.<PaymentBatchApprove>}
Given a list of payment keys it tries to approve them in a sync way. If one fails it logs the
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKeys |
Array.<string> | Payment keys |
actionBy |
string | Action executor |
Returns:
Batch approval response
- Type
- Promise.<PaymentBatchApprove>
(async, static) countPayments(args, actionBy) → {Promise.<number>}
Returns the total number of payments based on the args filtering.
This is used for pagination purposes.
Parameters:
| Name | Type | Description |
|---|---|---|
args |
PaymentFilters | Fitlering parameters |
actionBy |
string | Action executor |
Returns:
- Type
- Promise.<number>
(async, static) createPayment(params, actionBy) → {Promise.<Payment>}
Creates a new payment with status NEEDS_APPROVAL.
Parameters:
| Name | Type | Description |
|---|---|---|
params |
PaymentParams | Payment params |
actionBy |
string | Action executor |
Returns:
The created payment
- Type
- Promise.<Payment>
(async, static) denyPayment(paymentKey, reason, actionBy) → {Promise.<Payment>}
- Source:
Denies a payment.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
string | Payment key |
reason |
string | Reason fo denial |
actionBy |
string | Action executor |
Throws:
-
-
If no payment for the given key are found
- Type
- Error
-
-
-
If reason is empty
- Type
- Error
-
Returns:
The last payment for the given key
- Type
- Promise.<Payment>
(async, static) getLastPayment(paymentKey, actionBy) → {Promise.<Payment>}
Given a paymentKey it returns the last unprocessed payment associated with
that given key.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
string | Payment key |
actionBy |
string | Action executor |
Throws:
-
If no payment for the given key are found
- Type
- Error
Returns:
The last payment for the given key
- Type
- Promise.<Payment>
(async, static) getPaymentHistory(paymentKey, actionBy) → {Promise.<Array.<Payment>>}
Given a paymentKey it returns the history of all payment associated with
that given key, ordered by in decreasing order by its additions.
Note that only the unprocessed payments will be returned so that a clean history is kept.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
string | Payment key |
actionBy |
string | Action executor |
Returns:
History of the payment as a list of payments
- Type
- Promise.<Array.<Payment>>
(async, static) getPaymentProcessingHistory(paymentKey, processingKey, actionBy) → {Promise.<Array.<Payment>>}
Given a paymentKey and a processingKey it returns the processing history.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
string | Payment key |
processingKey |
string | Payment processing key |
actionBy |
string | Action executor |
Throws:
-
If no payment for the given key are found
- Type
- Error
Returns:
- Type
- Promise.<Array.<Payment>>
(async, static) handleEvent(paymentKey, actionBy) → {Promise.<Payment>}
Handles an external event and process it.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
ExternalPaymentEvent | Payment key |
actionBy |
string | Action executor |
Returns:
The handled payment
- Type
- Promise.<Payment>
(async, static) listPayments(args, actionBy) → {Promise.<Array.<Payment>>}
Returns a list of all the payments with possible
filtering based on the args.
Parameters:
| Name | Type | Description |
|---|---|---|
args |
PaymentFilters | null | Fitlering parameters |
actionBy |
string | Action executor |
Returns:
- Type
- Promise.<Array.<Payment>>
(async, static) processPayment(paymentKey, processingKey, actionBy) → {Promise.<Payment>}
Marks a payment for a given (paymentKey, processingKey) pair as processed.
Parameters:
| Name | Type | Description |
|---|---|---|
paymentKey |
string | Payment key |
processingKey |
string | Processing key |
actionBy |
string | Action executor |
Throws:
-
If no unprocessed payment with the requested params is not found.
- Type
- Error
Returns:
The processed payment
- Type
- Promise.<Payment>
(async, static) publishPaymentAdded(payment, actionBy) → {Promise.<void>}
Publishes that a non processed payment has been added.
Parameters:
| Name | Type | Description |
|---|---|---|
payment |
Payment | Payment ot be published |
actionBy |
string | Action executor |
Returns:
- Type
- Promise.<void>
(async, static) requestPayment(payment, actionBy) → {Promise.<PaymentRequestResponse>}
Requests the given payment to the messaging system via a req-reply flow.
Currently this is done via NATS to Orchestrator.
Parameters:
| Name | Type | Description |
|---|---|---|
payment |
Payment | The payment to be requested |
actionBy |
string | The action executor |
Returns:
The request response by the external service
- Type
- Promise.<PaymentRequestResponse>