public class CentralLightningHandlerPaymentFlow extends BasePaymentFlow
Should only be created by a BasePaymentFlowManager implementation. Created by Philip Vendil on 2019-01-01.
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
centralSystemRecipientId |
protected boolean |
registerNew |
clock, expectedTokenType, invoice, order, orderRequest, paymentRequired, preImageHash, request, requestData, settlement, tokenClaims
Constructor and Description |
---|
CentralLightningHandlerPaymentFlow(PaymentRequired paymentRequired,
CachableHttpServletRequest request,
OrderRequest orderRequest,
RequestPolicyFactory requestPolicyFactory,
LightningHandler lightningHandler,
PaymentHandler paymentHandler,
TokenGenerator tokenGenerator,
CurrencyConverter currencyConverter,
org.jose4j.jwt.JwtClaims tokenClaims,
ExpectedTokenType expectedTokenType,
java.time.Duration notBeforeDuration,
java.lang.String centralSystemRecipientId,
boolean registerNew)
Default constructor for CentralLightningHandlerPaymentFlow, might be initialized
differenlty given if flow state is in a pay walled node or central lightning handler node.
|
Modifier and Type | Method and Description |
---|---|
InvoiceResult |
checkSettledInvoice()
Method to check if a invoice is settled and returns an InvoiceResult if it is settled, otherwise null.
|
protected InvoiceResult |
generateInvoice()
Help method to generate invoice on a lightning handler node given order in payment JWT token.
|
protected InvoiceResult |
generateOrder()
Help method called by requestPayment on a pay walled node to generate a payment token
containing all relevant order data in order for the lightning node to create an invoice.
|
SettlementResult |
getSettlement()
Method to retrieve a settlement and generate a settlement token.
|
protected java.lang.String |
getSourceNode() |
boolean |
isSettled()
Method to check if related invoice is settled by the end user.
|
InvoiceResult |
requestPayment()
Method to create and order and an invoice.
|
getCurrencyConverter, getLightningHandler, getNotBeforeDate, getPaymentHandler, getPreImageHash, getRequestPolicyFactory, getTokenGenerator, getTokenIssuer, isPaymentRequired, isPayPerRequest, markAsExecuted
protected java.lang.String centralSystemRecipientId
protected boolean registerNew
public CentralLightningHandlerPaymentFlow(PaymentRequired paymentRequired, CachableHttpServletRequest request, OrderRequest orderRequest, RequestPolicyFactory requestPolicyFactory, LightningHandler lightningHandler, PaymentHandler paymentHandler, TokenGenerator tokenGenerator, CurrencyConverter currencyConverter, org.jose4j.jwt.JwtClaims tokenClaims, ExpectedTokenType expectedTokenType, java.time.Duration notBeforeDuration, java.lang.String centralSystemRecipientId, boolean registerNew)
paymentRequired
- the annotation signaling the requested resource requires payment.
Can be null for some nodes in a distributed setup.request
- the related HTTP Request in this phase of the payment flow.orderRequest
- the orderRequest calculated either from paymentRequired annotation
of extracted from JWT token depending on state in the payment flow.requestPolicyFactory
- the used RequestPolicyFactory. Might be null for nodes in a distributed setup.lightningHandler
- the used LightningHandler. Might be null for nodes in a distributed setup.paymentHandler
- the used PaymentHandler. Might be null for nodes in a distributed setup.tokenGenerator
- the user TokenGenerator, should never be null.currencyConverter
- the used CurrencyConverter. Might be null for nodes in a distributed setup.tokenClaims
- all claims parsed from the related JWT token. Null in no related token exists in current state.expectedTokenType
- the expected type of JWT token expected in this state of the payment flow.notBeforeDuration
- the duration for the not before field in generated
JWT tokens. This can be positive if it should be valid in the future, or negative
to support skewed clocked between systems. Use null if no not before date should
be set in generated JWT tokens.centralSystemRecipientId
- the recipient id of the central lightning handler node used to encrypt JWT tokens to.registerNew
- in settled invoices that doesn't have prior order created should automatically be registerd.public InvoiceResult requestPayment() throws java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException, InvalidCurrencyException, TokenException
java.lang.IllegalArgumentException
- if user specified parameters (used by the constructor) was invalid.java.io.IOException
- if communication problems occurred with underlying components.InternalErrorException
- if internal errors occurred processing the method.InvalidCurrencyException
- if problems occurred converting the currency in the order to the one
used in the invoice.TokenException
- if problems occurred generating or validating related JWT Token.protected InvoiceResult generateOrder() throws java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException, InvalidCurrencyException, TokenException
java.lang.IllegalArgumentException
- if user specified parameters (used by the constructor) was invalid.java.io.IOException
- if communication problems occurred with underlying components.InternalErrorException
- if internal errors occurred processing the method.InvalidCurrencyException
- if problems occurred converting the currency in the order to the one
used in the invoice.TokenException
- if problems occurred generating or validating related JWT Token.protected InvoiceResult generateInvoice() throws java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException, InvalidCurrencyException, TokenException
java.lang.IllegalArgumentException
- if user specified parameters (used by the constructor) was invalid.java.io.IOException
- if communication problems occurred with underlying components.InternalErrorException
- if internal errors occurred processing the method.InvalidCurrencyException
- if problems occurred converting the currency in the order to the one
used in the invoice.TokenException
- if problems occurred generating or validating related JWT Token.public InvoiceResult checkSettledInvoice() throws java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException, TokenException
java.lang.IllegalArgumentException
- if user specified parameters (used by the constructor) was invalid.java.io.IOException
- if communication problems occurred with underlying components.InternalErrorException
- if internal errors occurred processing the method.TokenException
- if problem occurred generating the settlement token.public boolean isSettled() throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if user specified parameters (used by the constructor) was invalid.public SettlementResult getSettlement() throws java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException, TokenException
java.lang.IllegalArgumentException
- if user specified parameters (used by the constructor) was invalid.java.io.IOException
- if communication problems occurred with underlying components.InternalErrorException
- if internal errors occurred processing the method.TokenException
- if problem occurred generating the settlement token.protected java.lang.String getSourceNode()
getSourceNode
in class BasePaymentFlow