Class Request
- Direct Known Subclasses:
- InAppPurchase, InAppStoreCard, InAppStoredCardUpdate, MandateManagement, Purchase, Refund, RequestMoney, Reversal, TransactionLog, TransactionStatus
public abstract class Request
extends java.lang.Object
Field Summary
Modifier and Type | Field and Description |
---|---|
protected Config |
config
Configuration object for the API communication
|
protected CommunicationFormat |
outputFormat
Output format from the API (for some requests may be XML or JSON)
|
Constructor Summary
Constructor and Description |
---|
Request() |
Method Summary
Modifier and Type | Method and Description |
---|---|
void |
addRequestParam(java.lang.String name, java.math.BigDecimal value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name, double value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name, int value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name, java.lang.String value)
Adds a parameter to the API request.
|
void |
addRequestParam(java.lang.String name, java.lang.String[] value)
Adds a parameter to the API request.
|
void |
addStandardParams()
Add the parameters that should be present in every API call.
|
void |
clearRequestParams()
Clears the request parameters.
|
java.lang.String |
createApiCallFormHtml()
Creates a minimal HTML document, containing a form with all the request parameters.
|
java.lang.String |
createApiCallFormHtml(java.lang.String title)
Creates a minimal HTML document, containing a form with all the request parameters.
|
java.lang.String |
createApiCallFormHtml(java.lang.String title, java.lang.String content)
Creates a minimal HTML document, containing a form with all the request parameters.
|
java.lang.String |
createSignature()
Create a signature for the API request parameters using the store private key.
|
Config |
getConfig() |
CommunicationFormat |
getOutputFormat() |
java.util.Map<java.lang.String,java.lang.String[]> |
getSignedRequestParams()
Returns all the API request parameters and generates a signature for them, if one is not present.
|
protected BasicResponse |
processApiCall()
Makes a request to the API using and returns the decoded API response.
|
void |
removeRequestParam(java.lang.String name)
Removes a parameter, if it exists, from the API request.
|
void |
setConfig(Config config) |
void |
setOutputFormat(CommunicationFormat outputFormat) |
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Field Detail
config
protected Config config
outputFormat
protected CommunicationFormat outputFormat
Constructor Detail
Request
public Request()
Method Detail
getConfig
public Config getConfig()
setConfig
public void setConfig(Config config)
getOutputFormat
public CommunicationFormat getOutputFormat()
setOutputFormat
public void setOutputFormat(CommunicationFormat outputFormat)
addRequestParam
public void addRequestParam(java.lang.String name, java.math.BigDecimal value)
- Parameters:
name
- the parameter namevalue
- the parameter value
addRequestParam
public void addRequestParam(java.lang.String name, double value)
- Parameters:
name
- the parameter namevalue
- the parameter value
addRequestParam
public void addRequestParam(java.lang.String name, int value)
- Parameters:
name
- the parameter namevalue
- the parameter value
addRequestParam
public void addRequestParam(java.lang.String name, java.lang.String value)
- Parameters:
name
- the parameter namevalue
- the parameter value
addRequestParam
public void addRequestParam(java.lang.String name, java.lang.String[] value)
- Parameters:
name
- the parameter namevalue
- the parameter value
removeRequestParam
public void removeRequestParam(java.lang.String name)
- Parameters:
name
- the parameter name
clearRequestParams
public void clearRequestParams()
addStandardParams
public void addStandardParams()
createSignature
public java.lang.String createSignature() throws IPCException
- Returns:
- a base64 encoded signature
- Throws:
IPCException
- If for some reason (invalid private key, invalid signature generation algorithm, etc.) the signature could not be created.
getSignedRequestParams
public java.util.Map<java.lang.String,java.lang.String[]> getSignedRequestParams() throws IPCException
- Returns:
- all the API request parameters with a generated signature for them
- Throws:
IPCException
- if the signature could not be generated
createApiCallFormHtml
public java.lang.String createApiCallFormHtml(java.lang.String title, java.lang.String content) throws IPCException
- Parameters:
title
- the page titlecontent
- the page content- Returns:
- a HTML string containing the form
- Throws:
IPCException
- If the signature for the request parameters could not be generated.
createApiCallFormHtml
public java.lang.String createApiCallFormHtml(java.lang.String title) throws IPCException
- Parameters:
title
- the page title- Returns:
- a HTML string containing the form
- Throws:
IPCException
- If the signature for the request parameters could not be generated.
createApiCallFormHtml
public java.lang.String createApiCallFormHtml() throws IPCException
- Returns:
- a HTML string containing the form
- Throws:
IPCException
- If the signature for the request parameters could not be generated.
processApiCall
protected BasicResponse processApiCall() throws IPCException
- Returns:
- a Response object, containing the API response data
- Throws:
IPCException
- If the signature for the request parameters could not be generated. If the API endpoint URL is invalid. If a connection with the API could not be established. If the API endpoint responds with an status code different than java.net.HttpURLConnection.HTTP_OK. If the data returned by the API contains an invalid signature.