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 |
|---|---|
BalanceResponse |
balance(BalanceRequest request)
Checks the remaining balance on a payment method.
|
BooleanPromptResponse |
booleanPrompt(BooleanPromptRequest request)
Asks the consumer a yes/no question.
|
CaptureResponse |
capture(CaptureRequest request)
Captures a preauthorization.
|
CaptureSignatureResponse |
captureSignature(CaptureSignatureRequest request)
Captures and returns a signature.
|
CashDiscountResponse |
cashDiscount(CashDiscountRequest request)
Calculates the discount for actual cash transactions.
|
AuthorizationResponse |
charge(AuthorizationRequest request)
Executes a standard direct preauth and capture.
|
Acknowledgement |
clear(ClearTerminalRequest request)
Clears the line item display and any in progress transaction.
|
CloseBatchResponse |
closeBatch(CloseBatchRequest request)
Closes the current credit card batch.
|
CustomerResponse |
customer(CustomerRequest request)
Retrieves a customer by id.
|
CustomerSearchResponse |
customerSearch(CustomerSearchRequest request)
Searches the customer database.
|
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(Object request,
Object 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.
|
EnrollResponse |
enroll(EnrollRequest request)
Adds a new payment method to the 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.
|
GiftActivateResponse |
giftActivate(GiftActivateRequest request)
Activates or recharges a gift card.
|
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 short message on the terminal.
|
protected TerminalRequest |
newTerminalRequestForRoute(TerminalRouteResponse route)
Assembles a new terminal request and populates the credentials, using transient
credentials if available.
|
Acknowledgement |
newTransactionDisplay(TransactionDisplayRequest request)
Displays a new transaction on the terminal.
|
PingResponse |
ping(PingRequest request)
Tests connectivity with a payment terminal.
|
protected Object |
postGateway(String path,
ICoreRequest 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)
Executes a preauthorization intended to be captured later.
|
protected Object |
putGateway(String path,
ICoreRequest 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)
Executes a refund.
|
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 manual 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).
|
PaymentLinkResponse |
sendPaymentLink(PaymentLinkRequest request)
Creates and send a payment link to a customer.
|
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.
|
TerminalStatusResponse |
terminalStatus(TerminalStatusRequest request)
Returns the current status of a terminal.
|
TermsAndConditionsResponse |
termsAndConditions(TermsAndConditionsRequest request)
Prompts the user to accept terms and conditions.
|
TextPromptResponse |
textPrompt(TextPromptRequest request)
Asks the consumer a text based question.
|
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.
|
AuthorizationResponse |
transactionStatus(TransactionStatusRequest request)
Retrieves the current status of a transaction.
|
CustomerResponse |
updateCustomer(UpdateCustomerRequest request)
Updates or creates a customer record.
|
Acknowledgement |
updateTransactionDisplay(TransactionDisplayRequest request)
Appends items to an existing transaction display.
|
VoidResponse |
voidTx(VoidRequest request)
Discards a previous preauth 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 AuthorizationResponse reverse(AuthorizationRequest request) throws Exception
request - the request parameters.AuthorizationResponseException - exception if any errors occurred processing the request.public CaptureResponse capture(CaptureRequest request) throws Exception
request - the request parameters.CaptureResponseException - exception if any errors occurred processing the request.public CloseBatchResponse closeBatch(CloseBatchRequest request) throws Exception
request - the request parameters.CloseBatchResponseException - exception if any errors occurred processing the request.public VoidResponse voidTx(VoidRequest request) throws Exception
request - the request parameters.VoidResponseException - exception if any errors occurred processing the request.public CustomerResponse updateCustomer(UpdateCustomerRequest request) throws Exception
request - the request parameters.CustomerResponseException - exception if any errors occurred processing the request.public CustomerResponse customer(CustomerRequest request) throws Exception
request - the request parameters.CustomerResponseException - exception if any errors occurred processing the request.public CustomerSearchResponse customerSearch(CustomerSearchRequest request) throws Exception
request - the request parameters.CustomerSearchResponseException - exception if any errors occurred processing the request.public CashDiscountResponse cashDiscount(CashDiscountRequest request) throws Exception
request - the request parameters.CashDiscountResponseException - exception if any errors occurred processing the request.public AuthorizationResponse transactionStatus(TransactionStatusRequest request) throws Exception
request - the request parameters.AuthorizationResponseException - exception if any errors occurred processing the request.public PaymentLinkResponse sendPaymentLink(PaymentLinkRequest request) throws Exception
request - the request parameters.PaymentLinkResponseException - exception if any errors occurred processing the request.public AuthorizationResponse charge(AuthorizationRequest request) throws Exception
request - the request parameters.AuthorizationResponseException - exception if any errors occurred processing the request.public AuthorizationResponse preauth(AuthorizationRequest request) throws Exception
request - the request parameters.AuthorizationResponseException - exception if any errors occurred processing the request.public PingResponse ping(PingRequest request) throws Exception
request - the request parameters.PingResponseException - exception if any errors occurred processing the request.public BalanceResponse balance(BalanceRequest request) throws Exception
request - the request parameters.BalanceResponseException - exception if any errors occurred processing the request.public Acknowledgement clear(ClearTerminalRequest request) throws Exception
request - the request parameters.AcknowledgementException - exception if any errors occurred processing the request.public TermsAndConditionsResponse termsAndConditions(TermsAndConditionsRequest request) throws Exception
request - the request parameters.TermsAndConditionsResponseException - exception if any errors occurred processing the request.public Acknowledgement updateTransactionDisplay(TransactionDisplayRequest request) throws Exception
request - the request parameters.AcknowledgementException - exception if any errors occurred processing the request.public Acknowledgement newTransactionDisplay(TransactionDisplayRequest request) throws Exception
request - the request parameters.AcknowledgementException - exception if any errors occurred processing the request.public TextPromptResponse textPrompt(TextPromptRequest request) throws Exception
request - the request parameters.TextPromptResponseException - exception if any errors occurred processing the request.public BooleanPromptResponse booleanPrompt(BooleanPromptRequest request) throws Exception
request - the request parameters.BooleanPromptResponseException - exception if any errors occurred processing the request.public Acknowledgement message(MessageRequest request) throws Exception
request - the request parameters.AcknowledgementException - exception if any errors occurred processing the request.public AuthorizationResponse refund(RefundRequest request) throws Exception
request - the request parameters.AuthorizationResponseException - exception if any errors occurred processing the request.public EnrollResponse enroll(EnrollRequest request) throws Exception
request - the request parameters.EnrollResponseException - exception if any errors occurred processing the request.public GiftActivateResponse giftActivate(GiftActivateRequest request) throws Exception
request - the request parameters.GiftActivateResponseException - exception if any errors occurred processing the request.public TerminalStatusResponse terminalStatus(TerminalStatusRequest request) throws Exception
request - the request parameters.TerminalStatusResponseException - exception if any errors occurred processing the request.public CaptureSignatureResponse captureSignature(CaptureSignatureRequest request) throws Exception
request - the request parameters.CaptureSignatureResponseException - 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 dumpSignatureFile(Object request, Object response)
request - ISignatureRequestresponse - ISignatureResponseprotected 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, ICoreRequest 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, ICoreRequest 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 © 2020 BlockChyp, Inc.. All rights reserved.