use of com.tranxactive.j2pay.net.HTTPResponse in project J2PAY by tranxactive.
the class BillproGateway method rebill.
@Override
public HTTPResponse rebill(JSONObject apiParameters, JSONObject rebillParameters, float amount) {
JSONObject resp;
int result;
RebillResponse successResponse = null;
ErrorResponse errorResponse = new ErrorResponse();
HTTPResponse httpResponse;
String requestString = this.buildRebillParameters(apiParameters, rebillParameters, amount);
httpResponse = HTTPClient.httpPost(url, requestString, ContentType.APPLICATION_XML);
if (httpResponse.getStatusCode() == -1) {
return httpResponse;
}
resp = XMLHelper.toJson(httpResponse.getContent());
result = resp.getJSONObject("Response").getInt("ResponseCode");
if (result == 100) {
successResponse = new RebillResponse();
successResponse.setMessage(resp.getJSONObject("Response").getString("Description"));
successResponse.setTransactionId(resp.getJSONObject("Response").get("TransactionID").toString());
successResponse.setAmount(amount);
successResponse.setRebillParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()).put(REFERENCE, rebillParameters.getString(REFERENCE)));
successResponse.setRefundParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
successResponse.setVoidParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
} else {
errorResponse.setMessage(resp.getJSONObject("Response").get("Description").toString());
errorResponse.setTransactionId(resp.getJSONObject("Response").optString("TransactionID"));
}
// final response.
processFinalResponse(resp, httpResponse, successResponse, errorResponse);
return httpResponse;
}
use of com.tranxactive.j2pay.net.HTTPResponse in project J2PAY by tranxactive.
the class BillproGateway method voidTransaction.
@Override
public HTTPResponse voidTransaction(JSONObject apiParameters, JSONObject voidParameters) {
JSONObject resp;
int result;
String requestString = this.buildVoidParameters(apiParameters, voidParameters);
VoidResponse successResponse = null;
ErrorResponse errorResponse = new ErrorResponse();
HTTPResponse httpResponse = HTTPClient.httpPost(url, requestString, ContentType.APPLICATION_XML);
if (httpResponse.getStatusCode() == -1) {
return httpResponse;
}
resp = XMLHelper.toJson(httpResponse.getContent());
result = resp.getJSONObject("Response").getInt("ResponseCode");
if (result == 100) {
successResponse = new VoidResponse();
successResponse.setMessage(resp.getJSONObject("Response").getString("Description"));
successResponse.setTransactionId(resp.getJSONObject("Response").get("TransactionID").toString());
} else {
errorResponse.setMessage(resp.getJSONObject("Response").get("Description").toString());
errorResponse.setTransactionId(resp.getJSONObject("Response").optString("TransactionID"));
}
// final response.
processFinalResponse(resp, httpResponse, successResponse, errorResponse);
return httpResponse;
}
use of com.tranxactive.j2pay.net.HTTPResponse in project J2PAY by tranxactive.
the class BillproGateway method authorize.
@Override
public HTTPResponse authorize(JSONObject apiParameters, Customer customer, CustomerCard customerCard, Currency currency, float amount) {
JSONObject resp;
int result;
String reference = getUniqueCustomerId();
String requestString = this.buildAuthParameters(apiParameters, reference, customer, customerCard, currency, amount);
AuthResponse successResponse = null;
ErrorResponse errorResponse = new ErrorResponse();
HTTPResponse httpResponse = HTTPClient.httpPost(url, requestString, ContentType.APPLICATION_XML);
if (httpResponse.getStatusCode() == -1) {
return httpResponse;
}
resp = XMLHelper.toJson(httpResponse.getContent());
result = resp.getJSONObject("Response").getInt("ResponseCode");
if (result == 100) {
successResponse = new AuthResponse();
successResponse.setMessage(resp.getJSONObject("Response").getString("Description"));
successResponse.setTransactionId(resp.getJSONObject("Response").get("TransactionID").toString());
successResponse.setAmount(amount);
successResponse.setCurrencyCode(currency);
successResponse.setCardValuesFrom(customerCard);
successResponse.setRebillParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()).put(REFERENCE, reference));
successResponse.setVoidParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
successResponse.setCaptureParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
} else {
errorResponse.setMessage(resp.getJSONObject("Response").get("Description").toString());
errorResponse.setTransactionId(resp.getJSONObject("Response").optString("TransactionID"));
}
// final response.
processFinalResponse(resp, httpResponse, successResponse, errorResponse);
return httpResponse;
}
use of com.tranxactive.j2pay.net.HTTPResponse in project J2PAY by tranxactive.
the class BillproGateway method refund.
@Override
public HTTPResponse refund(JSONObject apiParameters, JSONObject refundParameters, float amount) {
JSONObject resp;
int result;
String requestString = this.buildRefundParameters(apiParameters, refundParameters, amount);
RefundResponse successResponse = null;
ErrorResponse errorResponse = new ErrorResponse();
HTTPResponse httpResponse = HTTPClient.httpPost(url, requestString, ContentType.APPLICATION_XML);
if (httpResponse.getStatusCode() == -1) {
return httpResponse;
}
resp = XMLHelper.toJson(httpResponse.getContent());
result = resp.getJSONObject("Response").getInt("ResponseCode");
if (result == 100) {
successResponse = new RefundResponse();
successResponse.setMessage(resp.getJSONObject("Response").getString("Description"));
successResponse.setTransactionId(resp.getJSONObject("Response").get("TransactionID").toString());
successResponse.setAmount(amount);
successResponse.setVoidParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
} else {
errorResponse.setMessage(resp.getJSONObject("Response").get("Description").toString());
errorResponse.setTransactionId(resp.getJSONObject("Response").optString("TransactionID"));
}
// final response.
processFinalResponse(resp, httpResponse, successResponse, errorResponse);
return httpResponse;
}
use of com.tranxactive.j2pay.net.HTTPResponse in project J2PAY by tranxactive.
the class BillproGateway method capture.
@Override
public HTTPResponse capture(JSONObject apiParameters, JSONObject captureParameters, float amount) {
JSONObject resp;
int result;
String requestString = this.buildCaptureParameters(apiParameters, captureParameters);
CaptureResponse successResponse = null;
ErrorResponse errorResponse = new ErrorResponse();
HTTPResponse httpResponse = HTTPClient.httpPost(url, requestString, ContentType.APPLICATION_XML);
if (httpResponse.getStatusCode() == -1) {
return httpResponse;
}
resp = XMLHelper.toJson(httpResponse.getContent());
result = resp.getJSONObject("Response").getInt("ResponseCode");
if (result == 100) {
successResponse = new CaptureResponse();
successResponse.setMessage(resp.getJSONObject("Response").getString("Description"));
successResponse.setTransactionId(resp.getJSONObject("Response").get("TransactionID").toString());
successResponse.setAmount(amount);
successResponse.setVoidParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
successResponse.setRefundParams(new JSONObject().put(ParamList.TRANSACTION_ID.getName(), successResponse.getTransactionId()));
} else {
errorResponse.setMessage(resp.getJSONObject("Response").get("Description").toString());
errorResponse.setTransactionId(resp.getJSONObject("Response").optString("TransactionID"));
}
// final response.
processFinalResponse(resp, httpResponse, successResponse, errorResponse);
return httpResponse;
}
Aggregations