@Component(value="paymentHandler") public class DemoPaymentHandler extends SpringPaymentHandler
paymentDataConverter, paymentEventBus
Constructor and Description |
---|
DemoPaymentHandler() |
Modifier and Type | Method and Description |
---|---|
protected PaymentData |
findPaymentData(byte[] preImageHash)
Method to lookup a payment data in the payment handler.
|
protected java.time.Duration |
getDefaultSettlementValidity() |
protected PaymentData |
newPaymentData(byte[] preImageHash,
OrderRequest orderRequest)
Method that should generate a new PaymentData for a given order request.
|
void |
setSettlementDuration(java.time.Duration settlementDuration)
Method only used to override default duration set for settlement, only used
to test settlement token expiration in functional test and does not need to be part
of implementation regular use cases.
|
protected void |
updatePaymentData(PaymentEventType type,
PaymentData paymentData,
LightningHandlerContext context)
Method called on update events about a given payment data.
|
afterPropertiesSet, getDefaultInvoiceValidity, getLightningHandler, isLightningHandlerAutoconnect
checkSettlement, createOrder, getLightningHandlerContext, init, lookupInvoice, markAsExecuted, onLightningEvent, registerListener, registerSettledInvoice, unregisterListener
protected PaymentData newPaymentData(byte[] preImageHash, OrderRequest orderRequest) throws java.io.IOException, InternalErrorException
The generated PaymentData should be at least MinimalPaymentData with preImageHash and orderedAmount set.
It is recommended that the PaymentData is persisted in this call but could be skipped for performance in certain payment flows.
newPaymentData
in class BasePaymentHandler
preImageHash
- the unique preImageHash used to identify a payment flow
withing a lightning payment.orderRequest
- the specification of the payment data that should be created calculated
from data in the PaymentRequired annotation.java.io.IOException
- if communication exception occurred in underlying components.InternalErrorException
- if internal exception occurred generating new payment data.protected PaymentData findPaymentData(byte[] preImageHash) throws InternalErrorException
findPaymentData
in class BasePaymentHandler
preImageHash
- the unique preImageHash used to identify a payment flow
withing a lightning payment.InternalErrorException
- if internal exception occurred fetching related payment data.protected void updatePaymentData(PaymentEventType type, PaymentData paymentData, LightningHandlerContext context) throws InternalErrorException
The related payment data (using preImageHash as unique identifier) is automatically looked up and the implementing method should at least persist the updated data.
updatePaymentData
in class BasePaymentHandler
type
- the type of event such as INVOICE_CREATED or INVOICE_SETTLED.paymentData
- the payment data to update and persist.context
- the latest known state of the lightning handler. Null if no known state exists.InternalErrorException
- if internal exception occurred updating related payment data.public void setSettlementDuration(java.time.Duration settlementDuration)
settlementDuration
- the duration of generated settlement for this payment.protected java.time.Duration getDefaultSettlementValidity()
getDefaultSettlementValidity
in class SpringPaymentHandler