/** * Shows details for a payment, by ID. * @deprecated Please use {@link #get(APIContext, String)} instead. * @param accessToken * Access Token used for the API call. * @param paymentId * String * @return Payment * @throws PayPalRESTException */ public static Payment get(String accessToken, String paymentId) throws PayPalRESTException { APIContext apiContext = new APIContext(accessToken); return get(apiContext, paymentId); }
@Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { try { // ### Api Context // Pass in a `ApiContext` object to authenticate // the call and to send a unique request id // (that ensures idempotency). The SDK generates // a request id if you do not pass one explicitly. APIContext apiContext = new APIContext(clientID, clientSecret, mode); // Retrieve the payment object by calling the // static `get` method // on the Payment class by passing a valid // AccessToken and Payment ID Payment payment = Payment.get(apiContext, "PAY-0XL713371A312273YKE2GCNI"); LOGGER.info("Payment retrieved ID = " + payment.getId() + ", status = " + payment.getState()); ResultPrinter.addResult(req, resp, "Get Payment", Payment.getLastRequest(), Payment.getLastResponse(), null); } catch (PayPalRESTException e) { ResultPrinter.addResult(req, resp, "Get Payment", Payment.getLastRequest(), null, e.getMessage()); } req.getRequestDispatcher("response.jsp").forward(req, resp); }
@Test(groups = "integration", dependsOnMethods = { "testCreatePaymentAPI" }) public void testGetPaymentAPI() throws PayPalRESTException { payment = Payment.get(TestConstants.SANDBOX_CONTEXT, createdPaymentID); }
@Test(groups = "integration", dependsOnMethods = { "testFailCreatePaymentAPI" }) public void testFailGetPaymentAPI() { try { Payment.get(TestConstants.SANDBOX_CONTEXT, (String) null); } catch (IllegalArgumentException e) { Assert.assertTrue(e != null, "Illegal Argument Exception not thrown for null arguments"); } catch (PayPalRESTException e) { logger.error("response code: " + e.getResponsecode()); logger.error("message: " + e.getMessage()); Assert.fail(); } }