cancel
Showing results for 
Search instead for 
Did you mean: 

Session time after sending post request on Jakarta EE

Hello all,
I am trying to send a post request to retreive the checkout page. But everytime i receive session time out page.
Can someone had this same issue?

public String submit2() throws InvalidKeyException, NoSuchAlgorithmException, KeyManagementException {
DATE = getUTCDateTime();
MERCHANT_ID = "";
PROFIL_ID = "";
ACCESS_KEY = "";
DF_ORG_ID = "";
SECRET_KEY = "";
TRANSACTION_UID = UUID.randomUUID().toString();
SESSION_ID = getSessionId();
REFERENCE_NUMBER = "";
AMOUNT = "";
CURRENCY = "";
MERCHANT_DESC = "";
try {
SIGN_DATA = generateParametter();
} catch (InvalidKeyException ex) {
Logger.getLogger(PaiementClient.class.getName()).log(Level.SEVERE, null, ex);
} catch (NoSuchAlgorithmException ex) {
Logger.getLogger(PaiementClient.class.getName()).log(Level.SEVERE, null, ex);
}
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(null, trustAllCerts, new SecureRandom());
Cookie jsessionidCookie = new Cookie("jsessionid", SESSION_ID, "/", null, 600);
Client client = ClientBuilder.newBuilder()
.sslContext(sc)
.connectTimeout(30, TimeUnit.SECONDS)
.hostnameVerifier((hostname, session) -> true) // Trust all hostnames
.build();
Form form = new Form()
.param("access_key", ACCESS_KEY)
.param("amount", AMOUNT)
.param("auth_trans_ref_no", REFERENCE_NUMBER)
.param("bill_to_address_city", "Mountain View")
.param("bill_to_address_country", "US")
.param("bill_to_address_line1", "1295 Charleston Rd")
.param("bill_to_address_line2", "1295 Charleston Rd")
.param("bill_to_address_postal_code", "94043")
.param("bill_to_address_state", "CA")
.param("bill_to_email", "null@cybersource.com")
.param("bill_to_forename", "Noreal")
.param("bill_to_phone", "+662-2962-000")
.param("bill_to_surname", "Name")
.param("currency", CURRENCY)
.param("customer_ip_address", "0:0:0:0:0:0:0:1")
.param("item_0_code", "KFLTFDIV")
.param("item_0_name", "KFLTFDIV")
.param("item_0_quantity", "100")
.param("item_0_sku", "sku001")
.param("item_0_unit_price", "5.72")
.param("item_1_code", "KFLTFD70")
.param("item_1_name", "KFLTFD70")
.param("item_1_quantity", "100")
.param("item_1_sku", "sku002")
.param("item_1_unit_price", "10.00")
.param("line_item_count", "2")
.param("locale", "en-us")
.param("merchant_defined_data1", "MDD#1")
.param("merchant_defined_data2", "MDD#2")
.param("merchant_defined_data3", "MDD#3")
.param("merchant_defined_data4", "MDD#4")
.param("merchant_descriptor", MERCHANT_DESC)
.param("override_custom_cancel_page", "http://localhost:12457/jsp/sa-wm/response.jsp")
.param("override_custom_receipt_page", "http://localhost:12457/jsp/sa-wm/response.jsp")
.param("payment_method", "card")
.param("profile_id", PROFIL_ID)
.param("reference_number", REFERENCE_NUMBER)
.param("signed_date_time", DATE)
.param("signed_field_names", "profile_id,access_key,transaction_uuid,signed_field_names,unsigned_field_names,signed_date_time,locale,payment_method,transaction_type,reference_number,auth_trans_ref_no,amount,currency,merchant_descriptor,override_custom_cancel_page,override_custom_receipt_page")
.param("transaction_type", "sale")
.param("transaction_uuid", TRANSACTION_UID)
.param("unsigned_field_names", "device_fingerprint_id,bill_to_forename,bill_to_surname,bill_to_email,bill_to_phone,bill_to_address_line1,bill_to_address_line2,bill_to_address_city,bill_to_address_state,bill_to_address_country,bill_to_address_postal_code,customer_ip_address,line_item_count,item_0_code,item_0_sku,item_0_name,item_0_quantity,item_0_unit_price,item_1_code,item_1_sku,item_1_name,item_1_quantity,item_1_unit_price,merchant_defined_data1,merchant_defined_data2,merchant_defined_data3,merchant_defined_data4")
.param("device_fingerprint_id", SESSION_ID)
.param("jsessionid", SESSION_ID)
.param("signature", SIGN_DATA);

Response response = client.target("https://testsecureacceptance.cybersource.com/pay")
.request(MediaType.APPLICATION_FORM_URLENCODED)
.accept(MediaType.TEXT_PLAIN)
.post(Entity.form(form));
try {
FacesContext.getCurrentInstance().getExternalContext().redirect("https://testsecureacceptance.cybersource.com/checkout");
} catch (IOException ex) {
Logger.getLogger(PaiementClient.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}

Not that when submit using a  form with all those data it work perfectly

samsonsouley
Member
0 REPLIES 0