Hi,
I am using PayPal Java SDK to execute payment.
My code is look like this:
public Map<String, Object> completePayment(HttpServletRequest request) { Map<String, Object> response = new HashMap<>(); logger.info("Payment ID: " + request.getParameter("paymentId")); logger.info("Payer ID: " + request.getParameter("payerId")); Payment payment = new Payment(); payment.setId(request.getParameter("paymentId")); PaymentExecution paymentExecution = new PaymentExecution(); paymentExecution.setPayerId(request.getParameter("payerId")); try { logger.info("Payment Execution: " + paymentExecution.toJSON()); APIContext context = new APIContext(clientId, clientSecret, "sandbox"); Payment createdPayment = payment.execute(context, paymentExecution); if(createdPayment != null){ response.put("status", "success"); response.put("payment", createdPayment); } } catch (PayPalRESTException e) { // TODO Logger logger.info("CompletePayment Exception: " + e.getDetails()); } return response; }
But the execute method of PaymentExecution throws java.net.URISyntaxException:
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Illegal character in path at index 48: v1/payments/payment/PAY-7RS28472XP740142YLPMYPOA /execute] with root cause
java.net.URISyntaxException: Illegal character in path at index 48: v1/payments/payment/PAY-7RS28472XP740142YLPMYPOA /execute
at java.net.URI$Parser.fail(URI.java:2848) ~[na:1.8.0_91]
at java.net.URI$Parser.checkChars(URI.java:3021) ~[na:1.8.0_91]
at java.net.URI$Parser.parseHierarchical(URI.java:3105) ~[na:1.8.0_91]
at java.net.URI$Parser.parse(URI.java:3063) ~[na:1.8.0_91]
at java.net.URI.<init>(URI.java:588) ~[na:1.8.0_91]
at java.net.URI.create(URI.java:850) ~[na:1.8.0_91]
at java.net.URI.resolve(URI.java:1036) ~[na:1.8.0_91]
at com.paypal.base.rest.RESTAPICallPreHandler.getEndPoint(RESTAPICallPreHandler.java:169) ~[rest-api-sdk-1.14.0.jar:na]
at com.paypal.base.rest.PayPalResource.createHttpConfiguration(PayPalResource.java:457) ~[rest-api-sdk-1.14.0.jar:na]
at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:293) ~[rest-api-sdk-1.14.0.jar:na]
at com.paypal.base.rest.PayPalResource.configureAndExecute(PayPalResource.java:228) ~[rest-api-sdk-1.14.0.jar:na]
at com.paypal.api.payments.Payment.execute(Payment.java:226) ~[rest-api-sdk-1.14.0.jar:na]
I think it because of the space between paymentId and /execute:
v1/payments/payment/PAY-7RS28472XP740142YLPMYPOA /execute
then its an exception in
RESTAPICallPreHandler.java:169
Could you please help me?
How can I solve this problem?
Thany you
... View more