public abstract class BasePaymentFlow extends java.lang.Object implements PaymentFlow
Modifier and Type | Field and Description |
---|---|
protected java.time.Clock |
clock |
protected ExpectedTokenType |
expectedTokenType |
protected MinimalInvoice |
invoice |
protected PreImageOrder |
order |
protected OrderRequest |
orderRequest |
protected PaymentRequired |
paymentRequired |
protected byte[] |
preImageHash |
protected CachableHttpServletRequest |
request |
protected RequestData |
requestData |
protected Settlement |
settlement |
protected org.jose4j.jwt.JwtClaims |
tokenClaims |
Constructor and Description |
---|
BasePaymentFlow(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)
Default constructor initializing the common parts of a PaymentFlow.
|
Modifier and Type | Method and Description |
---|---|
protected CurrencyConverter |
getCurrencyConverter() |
protected LightningHandler |
getLightningHandler() |
protected java.time.Instant |
getNotBeforeDate() |
protected PaymentHandler |
getPaymentHandler() |
byte[] |
getPreImageHash() |
protected RequestPolicyFactory |
getRequestPolicyFactory() |
protected abstract java.lang.String |
getSourceNode() |
protected TokenGenerator |
getTokenGenerator() |
protected java.lang.String |
getTokenIssuer()
Help method to retrieve the issuer claim from a JWT token.
|
boolean |
isPaymentRequired()
Method that should determine if the current state of payment flow.
|
boolean |
isPayPerRequest()
Method that should indicate if related payment flow is for one request only or valid
over a given period.
|
void |
markAsExecuted()
Method that should be called by a filter or equivalent after successful execution of
payed request and the related payment flow is payPerRequest.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkSettledInvoice, getSettlement, isSettled, requestPayment
protected java.time.Clock clock
protected PaymentRequired paymentRequired
protected CachableHttpServletRequest request
protected OrderRequest orderRequest
protected org.jose4j.jwt.JwtClaims tokenClaims
protected ExpectedTokenType expectedTokenType
protected PreImageOrder order
protected MinimalInvoice invoice
protected Settlement settlement
protected byte[] preImageHash
protected RequestData requestData
public BasePaymentFlow(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)
paymentRequired
- the annotation signaling the requested resource requires payment.
Can be null for some nodes in a distributed setuo.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.protected RequestPolicyFactory getRequestPolicyFactory()
protected LightningHandler getLightningHandler()
protected PaymentHandler getPaymentHandler()
protected TokenGenerator getTokenGenerator()
protected CurrencyConverter getCurrencyConverter()
protected java.time.Instant getNotBeforeDate()
protected abstract java.lang.String getSourceNode()
public boolean isPaymentRequired() throws AlreadyExecutedException, java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException
isPaymentRequired
in interface PaymentFlow
AlreadyExecutedException
- if related payment is pay per request and is already executed.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.public boolean isPayPerRequest() throws InternalErrorException
isPayPerRequest
in interface PaymentFlow
InternalErrorException
- if internal errors occurred processing the method.public void markAsExecuted() throws java.lang.IllegalArgumentException, java.io.IOException, InternalErrorException
markAsExecuted
in interface PaymentFlow
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.public byte[] getPreImageHash()
getPreImageHash
in interface PaymentFlow
protected java.lang.String getTokenIssuer() throws TokenException
TokenException
- if problems occurred parsing issuer from JWT claims.