@Override public DoExpressCheckoutPaymentDTO doExpressCheckoutPayment( GetExpressCheckoutDetailsDTO details, ProfilePayPalDTO profile, OrderFullDTO order) throws PayPalFundingFailureException, PayPalException, PayPalFailureException, StockNotPresentException, PayPalPostPaymentException { // TODO Auto-generated method stub // VERIFICO LA GIACENZA orderService.checkQtaInStock(order.getIdOrder(), order); // effettuo il doCheckOut, si paga... DoExpressCheckoutPaymentDTO checkDTO = getWrapper(profile) .doExpressCheckoutPayment( details, profilePayPal.getNotifyUrl(), profilePayPal.getRedirectUrl()); order.setIdTransaction(checkDTO.getPAYMENTINFO_0_TRANSACTIONID()); order.setIdStato( TypeStateOrder.fromString(checkDTO.getPAYMENTINFO_0_PAYMENTSTATUS()).getState()); order.setPendingReason(checkDTO.getPAYMENTINFO_0_PENDINGREASON()); try { // aggiorno l'ordine con lo stato, se completed o pending facciamo // anche // il decremento della qta TypeStateOrder state = TypeStateOrder.fromString(checkDTO.getPAYMENTINFO_0_PAYMENTSTATUS()); log.info( String.format( "stato PayPal %s- stato Othala %s", checkDTO.getPAYMENTINFO_0_PAYMENTSTATUS(), Integer.toString(state.getState()))); if (isPaymentCompleted(checkDTO.getPAYMENTINFO_0_PAYMENTSTATUS()) || isPaymentPending(checkDTO.getPAYMENTINFO_0_PAYMENTSTATUS())) { orderService.confirmOrderPayment(order); } else { orderService.updateStateOrder(order.getIdOrder(), order, state); } // salvo il messaggio MessageIpnDTO ipn = new MessageIpnDTO(); ipn.setFgElaborato(false); ipn.setIdOrder(order.getIdOrder()); ipn.setIdTransaction(order.getIdTransaction()); ipn.setTxMessage(checkDTO.getOkMessage()); if (state.getState() == TypeStateOrder.PENDING.getState()) { ipn.setTxNote(checkDTO.getPAYMENTINFO_0_PENDINGREASON()); } ipn.setTxStato(checkDTO.getPAYMENTINFO_0_PAYMENTSTATUS()); messageIpnDAO.insertMessageIpn(ipn); } catch (Throwable e) { log.error("errore PaymentService dopo il pagamento", e); throw new PayPalPostPaymentException( e, order.getIdOrder(), "errore nel docheckout dopo il pagamento"); } return checkDTO; }
private void insertMessage(MessageIpnDTO ipnDTO) { // TODO Auto-generated method stub messageIpnDAO.insertMessageIpn(ipnDTO); }
private boolean exitsIdTransaction(String idTransaction, String txStato) { // TODO Auto-generated method stub return messageIpnDAO.getIdTransaction(idTransaction, txStato) > 0; }