@see PaymentResponse
*/
public PaymentResponse chargeAmount(String endUserId, String referenceCode, String description, String currency, double amount, int referenceSequence, String code, String callbackURL,
String clientCorrelator, String onBehalfOf, String purchaseCategoryCode, String channel, double taxAmount, String serviceId, String productId) {
PaymentResponse response=new PaymentResponse();
FormParameters formParameters=new FormParameters();
formParameters.put("endUserId", endUserId);
formParameters.put("transactionOperationStatus", "charged");
formParameters.put("referenceSequence", Integer.toString(referenceSequence));
formParameters.put("amount", Double.toString(amount));
formParameters.put("currency", currency);
formParameters.put("description", description);
formParameters.put("referenceCode", referenceCode);
formParameters.put("code", code);
formParameters.put("callbackURL", callbackURL);
formParameters.put("clientCorrelator", clientCorrelator);
formParameters.put("onBehalfOf", onBehalfOf);
formParameters.put("purchaseCategoryCode", purchaseCategoryCode);
formParameters.put("channel", channel);
formParameters.put("taxAmount", Double.toString(taxAmount));
formParameters.put("serviceId", serviceId);
formParameters.put("productId", productId);
int responseCode=0;
String contentType = null;
try {
String endpoint=endPoints.getAmountReservationChargeEndpoint().replace("{endUserId}", URLEncoder.encode(endUserId, "utf-8")).replace("{transactionId}", URLEncoder.encode(referenceCode, "utf-8"));
if (dumpRequestAndResponse) JSONRequest.dumpRequestVariables(endpoint, authorisationHeader, formParameters);
HttpURLConnection con = JSONRequest.setupConnection(endpoint, authorisationHeader);
con.setDoOutput(true);
OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream());
String requestBody=JSONRequest.formEncodeParams(formParameters);
out.write(requestBody);
out.close();
responseCode=con.getResponseCode();
contentType = con.getContentType();
if (callbackURL==null) {
response=paymentResponseProcessor.getResponse(con, OneAPIServlet.OK);
} else {
response=paymentResponseProcessor.getResponse(con, OneAPIServlet.ACCEPTED);
}
} catch (Exception e) {
System.out.println("Exception "+e.getMessage()+" "+e.getLocalizedMessage());
e.printStackTrace();
response.setHTTPResponseCode(responseCode);
response.setContentType(contentType);
response.setRequestError(new RequestError(RequestError.SERVICEEXCEPTION, "SVCJAVA", e.getMessage(), e.getClass().getName()));
}
return response;
}