Ejemplo n.º 1
0
 /** Retrieve the transfer type used for the payment */
 private TransferType validateTransferType(
     final MobileActionContext context, final AccountOwner to) {
   final TransferTypeQuery query = new TransferTypeQuery();
   query.setUniqueResult();
   query.setFromAccountType(context.getCurrentAccountType());
   query.setChannel(context.getChannel());
   query.setContext(TransactionContext.PAYMENT);
   query.setFromOwner(context.getAccountOwner());
   query.setToOwner(to);
   query.setUsePriority(true);
   final List<TransferType> types = transferTypeService.search(query);
   if (types == null || types.isEmpty()) {
     throw new MobileException("mobile.payment.error.noTransferType");
   }
   return types.get(0);
 }
Ejemplo n.º 2
0
  @Override
  protected ActionForward executeAction(final MobileActionContext context) throws Exception {
    final HttpServletRequest request = context.getRequest();
    final HttpSession session = request.getSession();
    if (RequestHelper.isGet(request)) {
      if (RequestHelper.isFromMenu(request)) {
        session.removeAttribute("mobileDoPaymentDTO");
      }
      // Form display: store the bookmark so, on errors, we will return to here
      storeBookmark(context);
      return context.getInputForward();
    } else {
      try {
        // Build the payment DTO
        final Member fromMember = context.getMember();
        final Member toMember = validateTo(context);
        final DoPaymentDTO payment = new DoPaymentDTO();
        payment.setChannel(context.getChannel());
        payment.setContext(TransactionContext.PAYMENT);
        payment.setFrom(fromMember);
        payment.setTo(toMember);
        payment.setAmount(validateAmount(context));
        payment.setDescription(validateDescription(context));
        payment.setTransferType(validateTransferType(context, toMember));

        // Check if the payment can be performed
        validatePayment(payment);

        // Store the DTO, so, the confirmation action will access it
        session.setAttribute("mobileDoPaymentDTO", payment);
      } catch (final MobileException e) {
        return MobileHelper.sendException(context.getActionMapping(), request, e);
      }
      return context.getSuccessForward();
    }
  }