0

I am getting Run time exception while making refund request to PayPal using NVP API: I tried setting up TLS configuration using #JAVA_OPTS="$JAVA_OPTS -Dhttps.protocols=TLSv1.1,TLSv1.2" and migrated to java 8, still facing issue.
//---------Code to make request PayLoad-----------

NVPEncoder encoder = new NVPEncoder();
encoder.add("METHOD", "RefundTransaction");
encoder.add("TRANSACTIONID", captureTrans.getString("referenceNum"));
encoder.add("REFUNDTYPE", "Partial");
encoder.add("CURRENCYCODE", captureTrans.getString("currencyUomId"));
encoder.add("AMT",refundAmount );

//----------Code for creating signatureAPIProfile()-------

APIProfile profile = ProfileFactory.createSignatureAPIProfile();
            profile.setAPIUsername(payPalConfig.getString("apiUserName"));
            profile.setAPIPassword(payPalConfig.getString("apiPassword"));
            profile.setSignature(payPalConfig.getString("apiSignature"));
            profile.setEnvironment(payPalConfig.getString("apiEnvironment"));
            caller.setAPIProfile(profile);

// Code to fire refund request

   String requestMessage = encoder.encode();
    String responseMessage = caller.call(requestMessage); //Getting exception in this line
    NVPDecoder decoder = new NVPDecoder();
    decoder.decode(responseMessage);

// Exception trace

[java] Mar 29, 2018 3:41:13 PM com.paypal.sdk.exceptions.FatalException <init>
     [java] SEVERE: Unable to complete HTTPS transaction
     [java] javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
     [java]     at sun.security.ssl.Alerts.getSSLException(Unknown Source)
     [java]     at sun.security.ssl.Alerts.getSSLException(Unknown Source)
     [java]     at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
     [java]     at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
     [java]     at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
     [java]     at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
     [java]     at sun.security.ssl.AppOutputStream.write(Unknown Source)
     [java]     at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
     [java]     at java.io.BufferedOutputStream.flush(Unknown Source)
     [java]     at org.apache.commons.httpclient.methods.StringRequestEntity.writeRequest(StringRequestEntity.java:146)
     [java]     at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:499)
     [java]     at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114)
     [java]     at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
     [java]     at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
     [java]     at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
     [java]     at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
     [java]     at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
     [java]     at com.paypal.sdk.core.nvp.NVPAPICaller.call(NVPAPICaller.java:353)
     [java]     at com.paypal.sdk.services.NVPCallerServices.call(NVPCallerServices.java:56)
     [java]     at org.ofbiz.accounting.thirdparty.paypal.PayPalServices.sendNVPRequest(PayPalServices.java:1048)
fab
  • 1,189
  • 12
  • 21
msingh
  • 31
  • 1
  • 3
  • Assume you've been through https://stackoverflow.com/questions/6353849/received-fatal-alert-handshake-failure-through-sslhandshakeexception?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa ? – Evan Knowles Mar 29 '18 at 12:54
  • Yes, I upgraded ssLProtocol to TLSV1.2 , upgraded my java version to java 8.But did not work. As I am using signature method to fire request , So I think there would be no issue due to Certificates. – msingh Apr 02 '18 at 05:43
  • Resolved the issue, Project was not pointing to java 8. By configuring it to java 8, the issue had been resolved – msingh May 04 '18 at 09:57

0 Answers0