I am trying to do merchant validation in Java. Before that, I completed these steps:-
String file=classLoader.getResource("/merchant.p12").getFile();
FileInputStream fileN=new FileInputStream(file);
clientStore.load(fileN,keyStorePassword.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientStore, keyStorePassword.toCharArray());
KeyManager[] kms = kmf.getKeyManagers();
SSLContext sslContext = null;
sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(kms, null, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
URL url= new URL(validationUrl);
HttpsURLConnection urlConn = (HttpsURLConnection) url.openConnection();
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
urlConn.setRequestProperty( "Content-Type", "application/json" );
urlConn.setRequestProperty("Accept", "application/json");
urlConn.setRequestMethod("POST");
urlConn.connect();
JSONObject cred = new JSONObject();
cred.put("merchantIdentifier","com.merchant.mymerchantname");
cred.put("displayName", "test");
cred.put("initiative", "web");
cred.put("initiativeContext", mydomain);
OutputStream conn= urlConn.getOutputStream();
OutputStreamWriter wr = new OutputStreamWriter
(conn);
wr.write(cred.toString());
wr.flush();
StringBuilder sb = new StringBuilder();
int HttpResult = urlConn.getResponseCode();
Please help me with this as I am badly stuck.
Registered Merchant Id, generated CSR, created merchant id and payment processing certificates.
Registered and verified domain & allowed Https connection to sandbox IPs on port 443 and whitelisted IPs for domain verification.
generated validation Url , using it to create ApplePay Payment Session.
String file=classLoader.getResource("/merchant.p12").getFile();
FileInputStream fileN=new FileInputStream(file);
clientStore.load(fileN,keyStorePassword.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientStore, keyStorePassword.toCharArray());
KeyManager[] kms = kmf.getKeyManagers();
SSLContext sslContext = null;
sslContext = SSLContext.getInstance("TLSv1.2");
sslContext.init(kms, null, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
URL url= new URL(validationUrl);
HttpsURLConnection urlConn = (HttpsURLConnection) url.openConnection();
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
urlConn.setRequestProperty( "Content-Type", "application/json" );
urlConn.setRequestProperty("Accept", "application/json");
urlConn.setRequestMethod("POST");
urlConn.connect();
JSONObject cred = new JSONObject();
cred.put("merchantIdentifier","com.merchant.mymerchantname");
cred.put("displayName", "test");
cred.put("initiative", "web");
cred.put("initiativeContext", mydomain);
OutputStream conn= urlConn.getOutputStream();
OutputStreamWriter wr = new OutputStreamWriter
(conn);
wr.write(cred.toString());
wr.flush();
StringBuilder sb = new StringBuilder();
int HttpResult = urlConn.getResponseCode();
Please help me with this as I am badly stuck.