public class BlockChypClient extends Object
| Modifier and Type | Field and Description |
|---|---|
static long |
MS_PER_HOUR |
static String |
OFFLINE_CACHE |
static String |
OFFLINE_FIXED_KEY |
| Constructor and Description |
|---|
BlockChypClient()
Default constructor.
|
BlockChypClient(APICredentials defaultCredentials)
Provided as a convenience to support constructor based dependency injection.
|
BlockChypClient(String gatewayHost)
Provided as a convenience to support constructor based dependency injection.
|
BlockChypClient(String gatewayHost,
APICredentials defaultCredentials)
Provided as a convenience to support constructor based dependency injection.
|
BlockChypClient(String gatewayHost,
String testGatewayHost,
APICredentials defaultCredentials)
Provided as a convenience to support constructor based dependency injection.
|
| Modifier and Type | Method and Description |
|---|---|
BooleanPromptResponse |
booleanPrompt(BooleanPromptRequest request)
Asks the user a yes or no question.
|
CaptureResponse |
capture(CaptureRequest request)
Captures a preauth.
|
AuthorizationResponse |
charge(AuthorizationRequest request)
Performs a standard auth and capture.
|
Acknowledgement |
clear(ClearTerminalRequest request)
Clears the terminal of any in progress transactions or line item information.
|
CloseBatchResponse |
closeBatch(CloseBatchRequest request)
Executes a manual batch close.
|
protected APICredentials |
decrypt(APICredentials creds)
Decrypts API credentials using the offline cache key.
|
protected byte[] |
deriveOfflineKey()
Generates the encryption key used for offline cache records.
|
protected void |
dumpSignatureFile(PaymentRequest request,
AuthorizationResponse response)
Writes the signature to a file if a signature is present and the caller has
requested it.
|
protected APICredentials |
encrypt(APICredentials creds)
Encrypts API credentials using the offline cache key.
|
AuthorizationResponse |
enroll(AuthorizationRequest request)
Enrolls the payment method in the recurring payment token vault.
|
protected Object |
finishGatewayRequest(org.apache.commons.httpclient.HttpMethod method,
Class responseType)
Executes a previously assembled HttpMethod against the gateway.
|
protected Object |
finishTerminalRequest(TerminalRouteResponse route,
Object request,
org.apache.commons.httpclient.methods.EntityEnclosingMethod method,
Class responseType)
This handles all the common logic associated with processing terminal http requests.
|
protected Object |
getGateway(String path,
boolean test,
Class responseType)
Executes an http get request against the gateway with a timeout override.
|
protected Object |
getGateway(String path,
boolean test,
Class responseType,
int requestTimeout)
Executes an http get request against the gateway with a timeout override.
|
protected org.apache.commons.httpclient.HttpClient |
getGatewayClient()
Returns the gateway client singleton.
|
TerminalRouteResponse |
getOfflineCache(String terminalName)
Returns the route stored in the offline cache for the given terminal.
|
String |
getOfflineRouteCacheLocation()
Returns the offline route cache location.
|
protected org.apache.commons.httpclient.HttpClient |
getTerminalClient()
Returns the terminal client singleton.
|
HeartbeatResponse |
heartbeat(boolean test)
Tests communication with the Gateway.
|
protected void |
initObjectMapper()
Initializes the JSON encoder and parser.
|
boolean |
isTerminalHttps()
Gets the terminal https flag.
|
protected boolean |
isTerminalRouted(ITerminalReference terminalName)
Returns true if transaction for the given terminal reference should be routed over the local subnet.
|
Acknowledgement |
message(MessageRequest request)
Displays a text message on the terminal screen.
|
protected TerminalRequest |
newTerminalRequestForRoute(TerminalRouteResponse route)
Assembles a new terminal request and populates the credentials, using transient
credentials if available.
|
Acknowledgement |
newTransactionDisplay(TransactionDisplayRequest request)
Resets the line item display.
|
Acknowledgement |
ping(PingRequest request)
Tests local communication with a terminal.
|
protected void |
populateSignatureOptions(PaymentRequest request)
This method is used to setup sensible defaults for local signature file
dumps.
|
protected Object |
postGateway(String path,
CoreRequest request,
Class responseClass)
Executes a post HTTP request against the gateway.
|
protected Object |
postTerminal(String path,
Object request,
Class responseType)
Posts an http request to the terminal API.
|
AuthorizationResponse |
preauth(AuthorizationRequest request)
Preauthorizes a transaction.
|
protected Object |
putGateway(String path,
CoreRequest request,
Class responseClass)
Executes a put HTTP request against the gateway.
|
protected Object |
putTerminal(String path,
Object request,
Class responseType)
Executes a put http request against the terminal API.
|
AuthorizationResponse |
refund(RefundRequest request)
Refunds a transaction.
|
protected String |
resolveOfflineRouteCacheLocation(String terminalName)
Returns the offline cache location.
|
protected String |
resolveTerminalHost(TerminalRouteResponse route)
Assembles the scheme, ip address, and port number bits of a terminal URL.
|
protected TerminalRouteResponse |
resolveTerminalRoute(String terminalName)
Finds the terminal route record for the given terminal name.
|
AuthorizationResponse |
reverse(AuthorizationRequest request)
Executes a time out reversal.
|
protected TerminalRouteResponse |
routeCacheGet(String terminalName)
Looks up a terminal route from the cache.
|
protected void |
routeCachePut(TerminalRouteResponse route)
Puts a terminal route in the cache (both caches).
|
void |
setDefaultCredentials(APICredentials defaultCredentials)
Sets the default root API credentials for the client.
|
void |
setGatewayHost(String gatewayHost)
Used to override the live gateway host.
|
void |
setOfflineRouteCacheEnabled(boolean offlineRouteCacheEnabled)
Enables or disables offline terminal route caching.
|
void |
setOfflineRouteCacheLocation(String offlineRouteCacheLocation)
Sets the offline route cache location if you want to override the default.
|
void |
setPaymentLogger(PaymentLogger paymentLogger)
Sets the payment logger.
|
void |
setTerminalHttps(boolean terminalHttps)
Sets the terminal https flag.
|
void |
setTestGatewayHost(String testGatewayHost)
Used to override the test gateway host.
|
TextPromptResponse |
textPrompt(TextPromptRequest request)
Captures text input from the user.
|
protected String |
toFullyQualifiedGatewayPath(String path,
boolean test)
Converts path to the fully qualified URL for a gateway API call.
|
protected String |
toFullyQualifiedTerminalPath(TerminalRouteResponse route,
String path)
Assembles a full path to the terminal for an API call.
|
protected String |
toTerminalRouteKey(String terminalName)
Creates a cache key for terminal routes.
|
Acknowledgement |
updateTransactionDisplay(TransactionDisplayRequest request)
Updates the line item display.
|
VoidResponse |
voidTx(VoidRequest request)
Voids a transaction.
|
public static final String OFFLINE_CACHE
public static final String OFFLINE_FIXED_KEY
public static final long MS_PER_HOUR
public BlockChypClient()
public BlockChypClient(String gatewayHost)
gatewayHost - alternate gateway endpoint.public BlockChypClient(APICredentials defaultCredentials)
defaultCredentials - APICredentialspublic BlockChypClient(String gatewayHost, APICredentials defaultCredentials)
gatewayHost - - alternate gateway endpoint.defaultCredentials - APICredentialspublic BlockChypClient(String gatewayHost, String testGatewayHost, APICredentials defaultCredentials)
gatewayHost - alternate gateway endpoint.testGatewayHost - alternate gateway endpoint.defaultCredentials - APICredentialspublic void setGatewayHost(String gatewayHost)
gatewayHost - alternate gateway endpoint.public void setTestGatewayHost(String testGatewayHost)
testGatewayHost - alternate gateway endpoint.public void setDefaultCredentials(APICredentials defaultCredentials)
defaultCredentials - APICredentialspublic void setOfflineRouteCacheEnabled(boolean offlineRouteCacheEnabled)
offlineRouteCacheEnabled - true if offline route caching is enabled.public void setPaymentLogger(PaymentLogger paymentLogger)
paymentLogger - an implementation of PaymentLoggerprotected void initObjectMapper()
public HeartbeatResponse heartbeat(boolean test) throws Exception
test - whether or not to route the the transaction to the test gateway.AcknowledgementException - exception if any errors occurred processing the request.public Acknowledgement ping(PingRequest request) throws Exception
request - PingRequestAcknowledgementException - exception if any errors occurred processing the request.public AuthorizationResponse enroll(AuthorizationRequest request) throws Exception
request - AuthorizationRequestAuthorizationResponseException - exception if any errors occurred processing the request.public AuthorizationResponse charge(AuthorizationRequest request) throws Exception
request - AuthorizationRequestAuthorizationResponseException - exception if any errors occurred processing the request.public AuthorizationResponse reverse(AuthorizationRequest request) throws Exception
request - AuthorizationRequestAuthorizationResponseException - exception if any errors occurred processing the request.public CloseBatchResponse closeBatch(CloseBatchRequest request) throws Exception
request - CloseBatchRequestCloseBatchResponseException - exception if any errors occurred processing the request.public AuthorizationResponse refund(RefundRequest request) throws Exception
request - RefundRequestAuthorizationResponseException - exception if any errors occurred processing the request.public AuthorizationResponse preauth(AuthorizationRequest request) throws Exception
request - AuthorizationRequestAuthorizationResponseException - exception if any errors occurred processing the request.public Acknowledgement message(MessageRequest request) throws Exception
request - MessageRequestAcknowledgementException - exception if any errors occurred processing the request.public TextPromptResponse textPrompt(TextPromptRequest request) throws Exception
request - TextPromptRequestTextPromptResponseException - exception if any errors occurred processing the request.public BooleanPromptResponse booleanPrompt(BooleanPromptRequest request) throws Exception
request - BooleanPromptRequestBooleanPromptResponseException - exception if any errors occurred processing the request.public Acknowledgement newTransactionDisplay(TransactionDisplayRequest request) throws Exception
request - TransactionDisplayRequestAcknowledgementException - exception if any errors occurred processing the request.public Acknowledgement clear(ClearTerminalRequest request) throws Exception
request - ClearTerminalRequestAcknowledgementException - exception if any errors occurred processing the request.public Acknowledgement updateTransactionDisplay(TransactionDisplayRequest request) throws Exception
request - TransactionDisplayRequestAcknowledgementException - exception if any errors occurred processing the request.public CaptureResponse capture(CaptureRequest request) throws Exception
request - CaptureRequestCaptureResponseException - exception if any errors occurred processing the request.public VoidResponse voidTx(VoidRequest request) throws Exception
request - VoidRequestVoidResponseException - exception if any errors occurred processing the request.protected APICredentials decrypt(APICredentials creds)
creds - blockchyp API credentials.protected APICredentials encrypt(APICredentials creds)
creds - blockchyp API credentials.protected byte[] deriveOfflineKey()
protected TerminalRouteResponse routeCacheGet(String terminalName)
terminalName - terminal name assigned at activation.protected void routeCachePut(TerminalRouteResponse route)
route - the terminal route record.protected String toTerminalRouteKey(String terminalName)
terminalName - terminal name.protected void populateSignatureOptions(PaymentRequest request)
request - PaymentRequestprotected void dumpSignatureFile(PaymentRequest request, AuthorizationResponse response)
request - PaymentRequestresponse - AuthorizationResponseprotected TerminalRouteResponse resolveTerminalRoute(String terminalName)
terminalName - name of the terminal assigned at activation.protected org.apache.commons.httpclient.HttpClient getGatewayClient()
protected org.apache.commons.httpclient.HttpClient getTerminalClient()
protected String resolveTerminalHost(TerminalRouteResponse route)
route - the terminal route record.protected String toFullyQualifiedTerminalPath(TerminalRouteResponse route, String path)
route - the terminal route record.path - API path relative to the root (e.g. "/api/charge")protected boolean isTerminalRouted(ITerminalReference terminalName)
terminalName - reference to the terminal.protected Object finishTerminalRequest(TerminalRouteResponse route, Object request, org.apache.commons.httpclient.methods.EntityEnclosingMethod method, Class responseType) throws Exception
route - the terminal route recordrequest - the request payload, if put or postmethod - the HttpMethod prepopulatedresponseType - expected response type.Exception - exception if any errors occurred processing the request.protected Object putTerminal(String path, Object request, Class responseType) throws Exception
path - api path relative to the root (e.g. "/api/charge")request - the request payload object.responseType - expected response type.Exception - exception if any errors occurred processing the request.protected TerminalRequest newTerminalRequestForRoute(TerminalRouteResponse route)
route - the terminal route record.TerminalRequestprotected Object postTerminal(String path, Object request, Class responseType) throws Exception
path - api path relative to the root (e.g. "/api/charge")request - the request payload object.responseType - expected response type.Exception - exception if any errors occurred processing the request.protected Object getGateway(String path, boolean test, Class responseType) throws Exception
path - api path relative to the root (e.g. "/api/heartbeat")test - whether or not this request should go to the test gatewayresponseType - expected response type.Exception - exception if any errors occurred processing the request.protected Object getGateway(String path, boolean test, Class responseType, int requestTimeout) throws Exception
path - API path relative to the root (e.g. "/api/heartbeat")test - whether or not this request should go to the test gatewayresponseType - expected response type.requestTimeout - timeout for the request in millisecondsException - exception if any errors occurred processing the request.protected Object finishGatewayRequest(org.apache.commons.httpclient.HttpMethod method, Class responseType) throws Exception
method - the HttpMethod to execute.responseType - expected response type.Exception - exception if any errors occurred processing the request.protected Object postGateway(String path, CoreRequest request, Class responseClass) throws Exception
path - API path from root (e.g. "/api/charge")request - the request object.responseClass - expected response type.Exception - exception if any errors occurred processing the request.protected Object putGateway(String path, CoreRequest request, Class responseClass) throws Exception
path - API path from root (e.g. "/api/charge")request - the request object.responseClass - expected response type.Exception - exception if any errors occurred processing the request.protected String resolveOfflineRouteCacheLocation(String terminalName)
terminalName - the target terminal name.public TerminalRouteResponse getOfflineCache(String terminalName)
terminalName - the target terminal name.public String getOfflineRouteCacheLocation()
public void setOfflineRouteCacheLocation(String offlineRouteCacheLocation)
offlineRouteCacheLocation - offline route cache location.protected String toFullyQualifiedGatewayPath(String path, boolean test)
path - path relative to the root (e.g. "/api/charge")test - whether or not this should route to the test transaction.public boolean isTerminalHttps()
public void setTerminalHttps(boolean terminalHttps)
terminalHttps - https flag.Copyright © 2019 BlockChyp, Inc.. All rights reserved.