public PayByIdPreviewResponse payByIdPreview(PayByIdPreviewRequest request) { PayByIdPreviewResponse payByIdPreviewResponse = new PayByIdPreviewResponse(); Payment payment = paymentDao.getPaymentsInfo(request.getPaymentId(), PaymentStatus.PENDING); if (payment != null) { payByIdPreviewResponse.setAmount(payment.getAmount()); payByIdPreviewResponse.setMerchantName(payment.getDiscount().getMerchant().getName()); payByIdPreviewResponse.setMerchantId( String.valueOf(payment.getDiscount().getMerchant().getId())); } return payByIdPreviewResponse; }
public PayByIdResponse payById(PayByIdRequest request) { PayByIdResponse response = new PayByIdResponse(); response.setSuccess(false); Long paymentId; try { paymentId = Long.valueOf(request.getPaymentId()); } catch (NumberFormatException e) { return response; } Customer customer = customerDao.get(request.getCustomerId()); if (customer == null) { return response; } Payment payment = paymentDao.get(paymentId); payment.setCustomer(customer); payment.setScore(request.getScore()); payment.setComment(request.getComment()); payment.setStatus(PaymentStatus.DONE); // todo add Pending Service Status payment.setPaymentDate(new Date()); payment.setReferenceNumber( payment.getGeneratedPaymentId() + "-" + payment.getDiscount().getId() + "-" + payment.getId()); paymentDao.saveOrUpdate(payment); // todo important must Service call from in bank response.setSuccess(true); return response; }