@ComponentScan(value="org.lightningj.paywall.spring") @Component(value="paymentHandler") public class DemoPaymentHandler extends SpringPaymentHandler
paymentDataConverter, paymentEventBus
Constructor and Description |
---|
DemoPaymentHandler() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Method called after initialization of bean.
|
protected PaymentData |
findPaymentData(byte[] preImageHash)
Method to lookup a payment data in the payment handler.
|
protected PaymentData |
newPaymentData(byte[] preImageHash,
OrderRequest orderRequest)
Method that should generate a new PaymentData for a given order request.
|
protected void |
updatePaymentData(PaymentEventType type,
PaymentData paymentData,
LightningHandlerContext context)
Method called on update events about a given payment data.
|
getDefaultInvoiceValidity, getDefaultSettlementValidity, getLightningHandler, isLightningHandlerAutoconnect
checkSettlement, createOrder, getLightningHandlerContext, init, lookupInvoice, markAsExecuted, onLightningEvent, registerListener, registerSettledInvoice, unregisterListener
public void afterPropertiesSet() throws java.lang.Exception
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
afterPropertiesSet
in class SpringPaymentHandler
java.lang.Exception
- in the event of misconfiguration (such as failure to set an
essential property) or if initialization fails for any other reasonprotected 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.