Package com.blockchyp.client
Class BlockChypClient
java.lang.Object
com.blockchyp.client.BlockChypClient
This is the main class Java developers will interact with. You can
instantiate this class directly or use it with a dependency injection
framework like Spring or Guice. Most developers will only need to inject
credentials, but you may also want to override default endpoints if you're
targeting non production BlockChyp systems (which is unlikely).
You can inject settings via the constructors or via setters depending on your
preferences.
You'll also notice that we're not using generics or any features from Java
1.7 or later. This is just to maintain as much backward compatibility as
possible with older systems (1.6 or later). The underlying REST API's are
invoked using commons-httpclient 3.1 and we use Jackson for JSON
serialization.
Most internal methods are scoped as protected in order to give developers the
ability to override things if they need special behavior or have weird
classpath issues.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefault 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.BlockChypClient(String dashboardHost, String gatewayHost, String testGatewayHost, APICredentials defaultCredentials) Provided as a convenience to support constructor based dependency injection. -
Method Summary
Modifier and TypeMethodDescriptionActivates a terminal.addTestMerchant(AddTestMerchantRequest request) Adds a test merchant account.balance(BalanceRequest request) Checks the remaining balance on a payment method.batchDetails(BatchDetailsRequest request) Returns the batch details for a single batch.batchHistory(BatchHistoryRequest request) Returns the batch history for a merchant.booleanPrompt(BooleanPromptRequest request) Asks the consumer a yes/no question.Cancels a payment link.capture(CaptureRequest request) Captures a preauthorization.captureSignature(CaptureSignatureRequest request) Captures and returns a signature.cashDiscount(CashDiscountRequest request) Calculates the discount for actual cash transactions.charge(AuthorizationRequest request) Executes a standard direct preauth and capture.clear(ClearTerminalRequest request) Clears the line item display and any in progress transaction.closeBatch(CloseBatchRequest request) Closes the current credit card batch.customer(CustomerRequest request) Retrieves a customer by id.customerSearch(CustomerSearchRequest request) Searches the customer database.Deactivates a terminal.protected APICredentialsdecrypt(APICredentials creds) Decrypts API credentials using the offline cache key.deleteBrandingAsset(BrandingAssetRequest request) Deletes a branding asset.deleteCustomer(DeleteCustomerRequest request) Deletes a customer record.protected ObjectdeleteDashboard(String path, ITimeoutRequest request, Class responseClass) Executes a delete HTTP request against the gateway.protected ObjectdeleteGateway(String path, ITimeoutRequest request, Class responseClass) Executes a delete HTTP request against the gateway.deleteMediaAsset(MediaRequest request) Deletes a media asset.Deletes a boarding platform configuration.Deletes a queued transaction from the terminal.deleteSlideShow(SlideShowRequest request) Deletes a single slide show.Deletes a survey question.deleteTestMerchant(MerchantProfileRequest request) Deletes a test merchant account.deleteToken(DeleteTokenRequest request) Deletes a payment token.protected byte[]Generates the encryption key used for offline cache records.protected voiddumpSignatureFile(Object request, Object response) Writes the signature to a file if a signature is present and the caller has requested it.protected APICredentialsencrypt(APICredentials creds) Encrypts API credentials using the offline cache key.enroll(EnrollRequest request) Adds a new payment method to the token vault.protected ObjectfinishGatewayRequest(org.apache.commons.httpclient.HttpMethod method, Class responseType) Executes a previously assembled HttpMethod against the gateway.protected ObjectfinishTerminalRequest(TerminalRouteResponse route, Object request, org.apache.commons.httpclient.HttpMethod method, Class responseType) This handles all the common logic associated with processing terminal http requests.protected ObjectgetDashboard(String path, ITimeoutRequest request, Class responseType) Executes an http get request against the gateway with a timeout override.protected ObjectgetGateway(String path, boolean test, Class responseType) Executes an http get request against the gateway with a timeout override.protected ObjectgetGateway(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.HttpClientReturns the gateway client singleton.getMerchants(GetMerchantsRequest request) Adds a test merchant account.getOfflineCache(String terminalName) Returns the route stored in the offline cache for the given terminal.Returns the offline route cache location.protected org.apache.commons.httpclient.HttpClientReturns the terminal client singleton.giftActivate(GiftActivateRequest request) Activates or recharges a gift card.heartbeat(boolean test) Tests communication with the Gateway.protected voidInitializes the JSON encoder and parser.Invites a user to join a merchant account.booleanGets the terminal https flag.protected booleanisTerminalRouted(ITerminalReference terminalName) Returns true if transaction for the given terminal reference should be routed over the local subnet.linkToken(LinkTokenRequest request) Links a token to a customer record.Returns a list of queued transactions on a terminal.locate(LocateRequest request) Returns routing and location data for a payment terminal.media(MediaRequest request) Returns the media library for a given partner, merchant, or organization.mediaAsset(MediaRequest request) Returns the media details for a single media asset.Returns detail for a single merchant-invoice statement.Returns a list of merchant invoices.merchantPlatforms(MerchantProfileRequest request) List all merchant platforms configured for a gateway merchant.merchantProfile(MerchantProfileRequest request) Returns profile information for a merchant.merchantUsers(MerchantProfileRequest request) List all active users and pending invites for a merchant account.message(MessageRequest request) Displays a short message on the terminal.protected TerminalRequestAssembles a new terminal request and populates the credentials, using transient credentials if available.Displays a new transaction on the terminal.Returns low level details for how partner commissions were calculated for a specific merchant statement.Returns detail for a single partner statement.Returns a list of partner statements.Retrieves the status of a payment link.ping(PingRequest request) Tests connectivity with a payment terminal.protected ObjectpostDashboard(String path, ITimeoutRequest request, Class responseClass) Executes a post HTTP request against the dashboard.protected ObjectpostGateway(String path, ITimeoutRequest request, Class responseClass) Executes a post HTTP request against the gateway.protected ObjectpostTerminal(String path, Object request, Class responseType) Posts an http request to the terminal API.protected ObjectpostUpload(String path, UploadMetadata request, InputStream inStream, Class responseClass) Executes a post HTTP request against the dashboard.preauth(AuthorizationRequest request) Executes a preauthorization intended to be captured later.pricingPolicy(PricingPolicyRequest request) Returns pricing policy for a merchant.protected ObjectputGateway(String path, ITimeoutRequest request, Class responseClass) Executes a put HTTP request against the gateway.protected ObjectputTerminal(String path, Object request, Class responseType) Executes a put http request against the terminal API.reboot(PingRequest request) Reboot a payment terminal.refund(RefundRequest request) Executes a refund.Resends payment link.protected StringresolveOfflineRouteCacheLocation(String terminalName) Returns the offline cache location.protected StringAssembles the scheme, ip address, and port number bits of a terminal URL.protected TerminalRouteResponseresolveTerminalRoute(String terminalName) Finds the terminal route record for the given terminal name.reverse(AuthorizationRequest request) Executes a manual time out reversal.protected TerminalRouteResponserouteCacheGet(String terminalName) Looks up a terminal route from the cache.protected voidPuts a terminal route in the cache (both caches).sendPaymentLink(PaymentLinkRequest request) Creates and send a payment link to a customer.voidsetDashboardHost(String dashboardHost) Used to override the dashboard host.voidsetDefaultCredentials(APICredentials defaultCredentials) Sets the default root API credentials for the client.voidsetGatewayHost(String gatewayHost) Used to override the live gateway host.voidsetOfflineRouteCacheEnabled(boolean offlineRouteCacheEnabled) Enables or disables offline terminal route caching.voidsetOfflineRouteCacheLocation(String offlineRouteCacheLocation) Sets the offline route cache location if you want to override the default.voidsetPaymentLogger(PaymentLogger paymentLogger) Sets the payment logger.voidsetTerminalHttps(boolean terminalHttps) Sets the terminal https flag.voidsetTestGatewayHost(String testGatewayHost) Used to override the test gateway host.slideShow(SlideShowRequest request) Returns a single slide show with slides.slideShows(SlideShowRequest request) Returns a collection of slide shows.surveyQuestion(SurveyQuestionRequest request) Returns a single survey question with response data.surveyQuestions(SurveyQuestionRequest request) Returns all survey questions for a given merchant.surveyResults(SurveyResultsRequest request) Returns results for a single survey question.Deletes a single terms and conditions template.tcEntry(TermsAndConditionsLogRequest request) Returns a single detailed Terms and Conditions entry.tcLog(TermsAndConditionsLogRequest request) Returns up to 250 entries from the Terms and Conditions log.Returns a single terms and conditions template.Returns a list of terms and conditions templates associated with a merchant account.Updates or creates a terms and conditions template.terminalBranding(BrandingAssetRequest request) Returns the terminal branding stack for a given set of API credentials.terminals(TerminalProfileRequest request) Returns all terminals associated with the merchant account.terminalStatus(TerminalStatusRequest request) Returns the current status of a terminal.Prompts the user to accept terms and conditions.textPrompt(TextPromptRequest request) Asks the consumer a text based question.protected StringConverts path to the fully qualified URL for a dashboard API call.protected StringtoFullyQualifiedGatewayPath(String path, boolean test) Converts path to the fully qualified URL for a gateway API call.protected StringtoFullyQualifiedTerminalPath(TerminalRouteResponse route, String path) Assembles a full path to the terminal for an API call.tokenMetadata(TokenMetadataRequest request) Retrieves payment token metadata.protected StringtoTerminalRouteKey(String terminalName) Creates a cache key for terminal routes.Returns the transaction history for a merchant.Retrieves the current status of a transaction.unlinkToken(UnlinkTokenRequest request) Removes a link between a customer and a token.updateBrandingAsset(BrandingAsset request) Updates a branding asset.updateCustomer(UpdateCustomerRequest request) Updates or creates a customer record.updateMerchant(MerchantProfile request) Adds or updates a merchant account.updateMerchantPlatforms(MerchantPlatform request) List all merchant platforms configured for a gateway merchant.updateSlideShow(SlideShow request) Updates or creates a slide show.updateSurveyQuestion(SurveyQuestion request) Updates or creates a survey question.Appends items to an existing transaction display.uploadMedia(UploadMetadata request, InputStream inStream) Uploads a media asset to the media library.uploadStatus(UploadStatusRequest request) Retrieves the current status of a file upload.voidTx(VoidRequest request) Discards a previous transaction.
-
Field Details
-
OFFLINE_CACHE
- See Also:
-
OFFLINE_FIXED_KEY
- See Also:
-
MS_PER_HOUR
public static final long MS_PER_HOUR- See Also:
-
-
Constructor Details
-
BlockChypClient
public BlockChypClient()Default constructor. -
BlockChypClient
Provided as a convenience to support constructor based dependency injection.- Parameters:
gatewayHost- alternate gateway endpoint.
-
BlockChypClient
Provided as a convenience to support constructor based dependency injection.- Parameters:
defaultCredentials-APICredentials
-
BlockChypClient
Provided as a convenience to support constructor based dependency injection.- Parameters:
gatewayHost- alternate gateway endpoint.defaultCredentials-APICredentials
-
BlockChypClient
public BlockChypClient(String gatewayHost, String testGatewayHost, APICredentials defaultCredentials) Provided as a convenience to support constructor based dependency injection.- Parameters:
gatewayHost- alternate gateway endpoint.testGatewayHost- alternate gateway endpoint.defaultCredentials-APICredentials
-
BlockChypClient
public BlockChypClient(String dashboardHost, String gatewayHost, String testGatewayHost, APICredentials defaultCredentials) Provided as a convenience to support constructor based dependency injection.- Parameters:
dashboardHost- alternate dashboard endpoint.gatewayHost- alternate gateway endpoint.testGatewayHost- alternate gateway endpoint.defaultCredentials-APICredentials
-
-
Method Details
-
setGatewayHost
Used to override the live gateway host. Unless you work at BlockChyp, you probably won't ever need to do this.- Parameters:
gatewayHost- alternate gateway endpoint.
-
setDashboardHost
Used to override the dashboard host. Unless you work at BlockChyp, you probably won't ever need to do this.- Parameters:
dashboardHost- alternate dashboard endpoint.
-
setTestGatewayHost
Used to override the test gateway host. Unless you work at BlockChyp, you probably won't ever need to do this.- Parameters:
testGatewayHost- alternate gateway endpoint.
-
setDefaultCredentials
Sets the default root API credentials for the client.- Parameters:
defaultCredentials-APICredentials
-
setOfflineRouteCacheEnabled
public void setOfflineRouteCacheEnabled(boolean offlineRouteCacheEnabled) Enables or disables offline terminal route caching. Offline route caching is really meant as a defense for situations where developers are creating new BlockChypClient instances over and over for each request and therefore making the in memory cache useless. The BlockChypClient is thread safe so we encourage you to only create one instance and share it for all requests. If you're doing this, you can safely disable offline route caching and we recommend it. Defaults to enabled.- Parameters:
offlineRouteCacheEnabled- true if offline route caching is enabled.
-
setPaymentLogger
Sets the payment logger. Can be used to override that default System.out based logging.- Parameters:
paymentLogger- an implementation ofPaymentLogger
-
initObjectMapper
protected void initObjectMapper()Initializes the JSON encoder and parser. -
heartbeat
Tests communication with the Gateway. If authentication is successful, a merchantPk value is returned.- Parameters:
test- whether or not to route the the transaction to the test gateway.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
locate
Returns routing and location data for a payment terminal.- Parameters:
request- the request parameters.- Returns:
LocateResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
capture
Captures a preauthorization.- Parameters:
request- the request parameters.- Returns:
CaptureResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
voidTx
Discards a previous transaction.- Parameters:
request- the request parameters.- Returns:
VoidResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
reverse
Executes a manual time out reversal. We love time out reversals. Don't be afraid to use them whenever a request to a BlockChyp terminal times out. You have up to two minutes to reverse any transaction. The only caveat is that you must assign transactionRef values when you build the original request. Otherwise, we have no real way of knowing which transaction you're trying to reverse because we may not have assigned it an id yet. And if we did assign it an id, you wouldn't know what it is because your request to the terminal timed out before you got a response.- Parameters:
request- the request parameters.- Returns:
AuthorizationResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
closeBatch
Closes the current credit card batch.- Parameters:
request- the request parameters.- Returns:
CloseBatchResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
sendPaymentLink
Creates and send a payment link to a customer.- Parameters:
request- the request parameters.- Returns:
PaymentLinkResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
resendPaymentLink
public ResendPaymentLinkResponse resendPaymentLink(ResendPaymentLinkRequest request) throws Exception Resends payment link.- Parameters:
request- the request parameters.- Returns:
ResendPaymentLinkResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
cancelPaymentLink
public CancelPaymentLinkResponse cancelPaymentLink(CancelPaymentLinkRequest request) throws Exception Cancels a payment link.- Parameters:
request- the request parameters.- Returns:
CancelPaymentLinkResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
paymentLinkStatus
public PaymentLinkStatusResponse paymentLinkStatus(PaymentLinkStatusRequest request) throws Exception Retrieves the status of a payment link.- Parameters:
request- the request parameters.- Returns:
PaymentLinkStatusResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
transactionStatus
Retrieves the current status of a transaction.- Parameters:
request- the request parameters.- Returns:
AuthorizationResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
updateCustomer
Updates or creates a customer record.- Parameters:
request- the request parameters.- Returns:
CustomerResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
customer
Retrieves a customer by id.- Parameters:
request- the request parameters.- Returns:
CustomerResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
customerSearch
Searches the customer database.- Parameters:
request- the request parameters.- Returns:
CustomerSearchResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
cashDiscount
Calculates the discount for actual cash transactions.- Parameters:
request- the request parameters.- Returns:
CashDiscountResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
batchHistory
Returns the batch history for a merchant.- Parameters:
request- the request parameters.- Returns:
BatchHistoryResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
batchDetails
Returns the batch details for a single batch.- Parameters:
request- the request parameters.- Returns:
BatchDetailsResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
transactionHistory
public TransactionHistoryResponse transactionHistory(TransactionHistoryRequest request) throws Exception Returns the transaction history for a merchant.- Parameters:
request- the request parameters.- Returns:
TransactionHistoryResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
pricingPolicy
Returns pricing policy for a merchant.- Parameters:
request- the request parameters.- Returns:
PricingPolicyResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
partnerStatements
public PartnerStatementListResponse partnerStatements(PartnerStatementListRequest request) throws Exception Returns a list of partner statements.- Parameters:
request- the request parameters.- Returns:
PartnerStatementListResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
partnerStatementDetail
public PartnerStatementDetailResponse partnerStatementDetail(PartnerStatementDetailRequest request) throws Exception Returns detail for a single partner statement.- Parameters:
request- the request parameters.- Returns:
PartnerStatementDetailResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
merchantInvoices
public MerchantInvoiceListResponse merchantInvoices(MerchantInvoiceListRequest request) throws Exception Returns a list of merchant invoices.- Parameters:
request- the request parameters.- Returns:
MerchantInvoiceListResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
merchantInvoiceDetail
public MerchantInvoiceDetailResponse merchantInvoiceDetail(MerchantInvoiceDetailRequest request) throws Exception Returns detail for a single merchant-invoice statement.- Parameters:
request- the request parameters.- Returns:
MerchantInvoiceDetailResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
partnerCommissionBreakdown
public PartnerCommissionBreakdownResponse partnerCommissionBreakdown(PartnerCommissionBreakdownRequest request) throws Exception Returns low level details for how partner commissions were calculated for a specific merchant statement.- Parameters:
request- the request parameters.- Returns:
PartnerCommissionBreakdownResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
merchantProfile
Returns profile information for a merchant.- Parameters:
request- the request parameters.- Returns:
MerchantProfileResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteCustomer
Deletes a customer record.- Parameters:
request- the request parameters.- Returns:
DeleteCustomerResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
tokenMetadata
Retrieves payment token metadata.- Parameters:
request- the request parameters.- Returns:
TokenMetadataResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
linkToken
Links a token to a customer record.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
unlinkToken
Removes a link between a customer and a token.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteToken
Deletes a payment token.- Parameters:
request- the request parameters.- Returns:
DeleteTokenResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
getMerchants
Adds a test merchant account.- Parameters:
request- the request parameters.- Returns:
GetMerchantsResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
updateMerchant
Adds or updates a merchant account. Can be used to create or update test merchants. Only gateway partners may create new live merchants.- Parameters:
request- the request parameters.- Returns:
MerchantProfileResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
merchantUsers
List all active users and pending invites for a merchant account.- Parameters:
request- the request parameters.- Returns:
MerchantUsersResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
inviteMerchantUser
Invites a user to join a merchant account.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
addTestMerchant
Adds a test merchant account.- Parameters:
request- the request parameters.- Returns:
MerchantProfileResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteTestMerchant
Deletes a test merchant account. Supports partner scoped API credentials only. Live merchant accounts cannot be deleted.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
merchantPlatforms
List all merchant platforms configured for a gateway merchant.- Parameters:
request- the request parameters.- Returns:
MerchantPlatformsResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
updateMerchantPlatforms
List all merchant platforms configured for a gateway merchant.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteMerchantPlatforms
Deletes a boarding platform configuration.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
terminals
Returns all terminals associated with the merchant account.- Parameters:
request- the request parameters.- Returns:
TerminalProfileResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
deactivateTerminal
Deactivates a terminal.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
activateTerminal
Activates a terminal.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
tcTemplates
public TermsAndConditionsTemplateResponse tcTemplates(TermsAndConditionsTemplateRequest request) throws Exception Returns a list of terms and conditions templates associated with a merchant account.- Parameters:
request- the request parameters.- Returns:
TermsAndConditionsTemplateResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
tcTemplate
public TermsAndConditionsTemplate tcTemplate(TermsAndConditionsTemplateRequest request) throws Exception Returns a single terms and conditions template.- Parameters:
request- the request parameters.- Returns:
TermsAndConditionsTemplate- Throws:
Exception- exception if any errors occurred processing the request.
-
tcUpdateTemplate
public TermsAndConditionsTemplate tcUpdateTemplate(TermsAndConditionsTemplate request) throws Exception Updates or creates a terms and conditions template.- Parameters:
request- the request parameters.- Returns:
TermsAndConditionsTemplate- Throws:
Exception- exception if any errors occurred processing the request.
-
tcDeleteTemplate
Deletes a single terms and conditions template.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
tcLog
Returns up to 250 entries from the Terms and Conditions log.- Parameters:
request- the request parameters.- Returns:
TermsAndConditionsLogResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
tcEntry
Returns a single detailed Terms and Conditions entry.- Parameters:
request- the request parameters.- Returns:
TermsAndConditionsLogEntry- Throws:
Exception- exception if any errors occurred processing the request.
-
surveyQuestions
Returns all survey questions for a given merchant.- Parameters:
request- the request parameters.- Returns:
SurveyQuestionResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
surveyQuestion
Returns a single survey question with response data.- Parameters:
request- the request parameters.- Returns:
SurveyQuestion- Throws:
Exception- exception if any errors occurred processing the request.
-
updateSurveyQuestion
Updates or creates a survey question.- Parameters:
request- the request parameters.- Returns:
SurveyQuestion- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteSurveyQuestion
Deletes a survey question.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
surveyResults
Returns results for a single survey question.- Parameters:
request- the request parameters.- Returns:
SurveyQuestion- Throws:
Exception- exception if any errors occurred processing the request.
-
media
Returns the media library for a given partner, merchant, or organization.- Parameters:
request- the request parameters.- Returns:
MediaLibraryResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
uploadMedia
Uploads a media asset to the media library.- Parameters:
request- the request parameters.- Returns:
MediaMetadata- Throws:
Exception- exception if any errors occurred processing the request.
-
uploadStatus
Retrieves the current status of a file upload.- Parameters:
request- the request parameters.- Returns:
UploadStatus- Throws:
Exception- exception if any errors occurred processing the request.
-
mediaAsset
Returns the media details for a single media asset.- Parameters:
request- the request parameters.- Returns:
MediaMetadata- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteMediaAsset
Deletes a media asset.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
slideShows
Returns a collection of slide shows.- Parameters:
request- the request parameters.- Returns:
SlideShowResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
slideShow
Returns a single slide show with slides. -
updateSlideShow
Updates or creates a slide show. -
deleteSlideShow
Deletes a single slide show.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
terminalBranding
Returns the terminal branding stack for a given set of API credentials.- Parameters:
request- the request parameters.- Returns:
BrandingAssetResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
updateBrandingAsset
Updates a branding asset.- Parameters:
request- the request parameters.- Returns:
BrandingAsset- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteBrandingAsset
Deletes a branding asset.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
ping
Tests connectivity with a payment terminal.- Parameters:
request- the request parameters.- Returns:
PingResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
charge
Executes a standard direct preauth and capture.- Parameters:
request- the request parameters.- Returns:
AuthorizationResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
preauth
Executes a preauthorization intended to be captured later.- Parameters:
request- the request parameters.- Returns:
AuthorizationResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
refund
Executes a refund.- Parameters:
request- the request parameters.- Returns:
AuthorizationResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
enroll
Adds a new payment method to the token vault.- Parameters:
request- the request parameters.- Returns:
EnrollResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
giftActivate
Activates or recharges a gift card.- Parameters:
request- the request parameters.- Returns:
GiftActivateResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
balance
Checks the remaining balance on a payment method.- Parameters:
request- the request parameters.- Returns:
BalanceResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
clear
Clears the line item display and any in progress transaction.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
terminalStatus
Returns the current status of a terminal.- Parameters:
request- the request parameters.- Returns:
TerminalStatusResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
termsAndConditions
public TermsAndConditionsResponse termsAndConditions(TermsAndConditionsRequest request) throws Exception Prompts the user to accept terms and conditions.- Parameters:
request- the request parameters.- Returns:
TermsAndConditionsResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
captureSignature
Captures and returns a signature.- Parameters:
request- the request parameters.- Returns:
CaptureSignatureResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
newTransactionDisplay
Displays a new transaction on the terminal.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
updateTransactionDisplay
Appends items to an existing transaction display. Subtotal, Tax, and Total are overwritten by the request. Items with the same description are combined into groups.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
message
Displays a short message on the terminal.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
booleanPrompt
Asks the consumer a yes/no question.- Parameters:
request- the request parameters.- Returns:
BooleanPromptResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
textPrompt
Asks the consumer a text based question.- Parameters:
request- the request parameters.- Returns:
TextPromptResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
listQueuedTransactions
public ListQueuedTransactionsResponse listQueuedTransactions(ListQueuedTransactionsRequest request) throws Exception Returns a list of queued transactions on a terminal.- Parameters:
request- the request parameters.- Returns:
ListQueuedTransactionsResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteQueuedTransaction
public DeleteQueuedTransactionResponse deleteQueuedTransaction(DeleteQueuedTransactionRequest request) throws Exception Deletes a queued transaction from the terminal.- Parameters:
request- the request parameters.- Returns:
DeleteQueuedTransactionResponse- Throws:
Exception- exception if any errors occurred processing the request.
-
reboot
Reboot a payment terminal.- Parameters:
request- the request parameters.- Returns:
Acknowledgement- Throws:
Exception- exception if any errors occurred processing the request.
-
decrypt
Decrypts API credentials using the offline cache key.- Parameters:
creds- blockchyp API credentials.- Returns:
- a decrypted copy of the original credentials.
-
encrypt
Encrypts API credentials using the offline cache key.- Parameters:
creds- blockchyp API credentials.- Returns:
- an encrypted copy of the original credentials.
-
deriveOfflineKey
protected byte[] deriveOfflineKey()Generates the encryption key used for offline cache records.- Returns:
- the key in bytes.
-
routeCacheGet
Looks up a terminal route from the cache.- Parameters:
terminalName- terminal name assigned at activation.- Returns:
- the terminal route record.
-
routeCachePut
Puts a terminal route in the cache (both caches).- Parameters:
route- the terminal route record.
-
toTerminalRouteKey
Creates a cache key for terminal routes.- Parameters:
terminalName- terminal name.- Returns:
- terminal cache key.
-
dumpSignatureFile
Writes the signature to a file if a signature is present and the caller has requested it. Notice this does not throw exceptions in order to prevent the calling application from losing track of the authorization.- Parameters:
request-ISignatureRequestresponse-ISignatureResponse
-
resolveTerminalRoute
Finds the terminal route record for the given terminal name. First the local in memory cache is checked, then the offline cache (if enabled). If the first two cache lookups come up empty or the cache is over an hour old, the gateway route API is invoked. If we have a stale cache entry and the gateway route lookup fails or times out, we fall back to the stale cache entry.- Parameters:
terminalName- name of the terminal assigned at activation.- Returns:
- the terminal route record.
-
getGatewayClient
protected org.apache.commons.httpclient.HttpClient getGatewayClient()Returns the gateway client singleton.- Returns:
- HttpClient configured for gateway requests.
-
getTerminalClient
protected org.apache.commons.httpclient.HttpClient getTerminalClient()Returns the terminal client singleton.- Returns:
- HttpClient configured for terminal requests.
-
resolveTerminalHost
Assembles the scheme, ip address, and port number bits of a terminal URL.- Parameters:
route- the terminal route record.- Returns:
- scheme, ip addres, and port number.
-
toFullyQualifiedTerminalPath
Assembles a full path to the terminal for an API call.- Parameters:
route- the terminal route record.path- API path relative to the root (e.g. "/api/charge")- Returns:
- the fully qualified URI.
-
isTerminalRouted
Returns true if transaction for the given terminal reference should be routed over the local subnet.- Parameters:
terminalName- reference to the terminal.- Returns:
- true, if terminal (local subnet) routed.
-
finishTerminalRequest
protected Object finishTerminalRequest(TerminalRouteResponse route, Object request, org.apache.commons.httpclient.HttpMethod method, Class responseType) throws Exception This handles all the common logic associated with processing terminal http requests.- Parameters:
route- the terminal route recordrequest- the request payload, if put or postmethod- the HttpMethod prepopulatedresponseType- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
putTerminal
Executes a put http request against the terminal API.- Parameters:
path- api path relative to the root (e.g. "/api/charge")request- the request payload object.responseType- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
newTerminalRequestForRoute
Assembles a new terminal request and populates the credentials, using transient credentials if available.- Parameters:
route- the terminal route record.- Returns:
TerminalRequest
-
postTerminal
Posts an http request to the terminal API.- Parameters:
path- api path relative to the root (e.g. "/api/charge")request- the request payload object.responseType- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
getGateway
Executes an http get request against the gateway with a timeout override.- Parameters:
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.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
getGateway
protected Object getGateway(String path, boolean test, Class responseType, int requestTimeout) throws Exception Executes an http get request against the gateway with a timeout override.- Parameters:
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 milliseconds- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
getDashboard
protected Object getDashboard(String path, ITimeoutRequest request, Class responseType) throws Exception Executes an http get request against the gateway with a timeout override.- Parameters:
path- API path relative to the root (e.g. "/api/heartbeat")request- the request object.responseType- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
finishGatewayRequest
protected Object finishGatewayRequest(org.apache.commons.httpclient.HttpMethod method, Class responseType) throws Exception Executes a previously assembled HttpMethod against the gateway. Aggregates common logic associated with hitting the gateway.- Parameters:
method- the HttpMethod to execute.responseType- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
postUpload
protected Object postUpload(String path, UploadMetadata request, InputStream inStream, Class responseClass) throws Exception Executes a post HTTP request against the dashboard.- Parameters:
path- API path from root (e.g. "/api/charge")request- the request object.inStream- is the upload input streamresponseClass- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
postDashboard
protected Object postDashboard(String path, ITimeoutRequest request, Class responseClass) throws Exception Executes a post HTTP request against the dashboard.- Parameters:
path- API path from root (e.g. "/api/charge")request- the request object.responseClass- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
postGateway
protected Object postGateway(String path, ITimeoutRequest request, Class responseClass) throws Exception Executes a post HTTP request against the gateway.- Parameters:
path- API path from root (e.g. "/api/charge")request- the request object.responseClass- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
putGateway
protected Object putGateway(String path, ITimeoutRequest request, Class responseClass) throws Exception Executes a put HTTP request against the gateway.- Parameters:
path- API path from root (e.g. "/api/charge")request- the request object.responseClass- expected response type.- Returns:
- a reponse of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteGateway
protected Object deleteGateway(String path, ITimeoutRequest request, Class responseClass) throws Exception Executes a delete HTTP request against the gateway.- Parameters:
path- API path from root (e.g. "/api/charge")request- the request object.responseClass- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
deleteDashboard
protected Object deleteDashboard(String path, ITimeoutRequest request, Class responseClass) throws Exception Executes a delete HTTP request against the gateway.- Parameters:
path- API path from root (e.g. "/api/charge")request- the request object.responseClass- expected response type.- Returns:
- a response of type specified by responseClass
- Throws:
Exception- exception if any errors occurred processing the request.
-
resolveOfflineRouteCacheLocation
Returns the offline cache location. This will be the value of offlineRouteCacheLocation if specified and the operation system default tmp folder otherwise.- Parameters:
terminalName- the target terminal name.- Returns:
- local path.
-
getOfflineCache
Returns the route stored in the offline cache for the given terminal.- Parameters:
terminalName- the target terminal name.- Returns:
- terminal route, null if not found.
-
getOfflineRouteCacheLocation
Returns the offline route cache location.- Returns:
- offline route cache location.
-
setOfflineRouteCacheLocation
Sets the offline route cache location if you want to override the default. Defaults to your operation system's tmp file location.- Parameters:
offlineRouteCacheLocation- offline route cache location.
-
toFullyQualifiedGatewayPath
Converts path to the fully qualified URL for a gateway API call.- Parameters:
path- path relative to the root (e.g. "/api/charge")test- whether or not this should route to the test transaction.- Returns:
- fully qualified URI.
-
toFullyQualifiedDashboardPath
Converts path to the fully qualified URL for a dashboard API call.- Parameters:
path- path relative to the root (e.g. "/api/charge")- Returns:
- fully qualified URI.
-
isTerminalHttps
public boolean isTerminalHttps()Gets the terminal https flag. The Java SDK defaults to using http for terminal communication because installing custom root certificate authorities in Java is quite tricky and cannot be done programmatically. We strongly recommend that all developers install our root CA in your local keystores and then turn https on in production. Our terminal root CA can be found here: https://docs.blockchyp.com/rest-api/terminal/index.html#ssl-tls- Returns:
- https flag.
-
setTerminalHttps
public void setTerminalHttps(boolean terminalHttps) Sets the terminal https flag. The Java SDK defaults to using http for terminal communication because installing custom root certificate authorities in Java is quite tricky and cannot be done programmatically. We strongly recommend that all developers install our root CA in your local keystores and then turn https on in production. Our terminal root CA can be found here: https://docs.blockchyp.com/rest-api/terminal/index.html#ssl-tls- Parameters:
terminalHttps- https flag.
-