Пример #1
0
  private boolean startVoucher(TransactionBean tab) throws Exception {
    LOG.debug("# SendMoneyPage.startVoucher()");
    StartVoucher request = getNewMobiliserRequest(StartVoucher.class);
    StartVoucherResponse response = null;
    request.setAmount(tab.getAmount());
    request.setAutoCapture(tab.isAutoCapture());
    request.setOrderChannel(tab.getOrderChannel());
    request.setOrderID(tab.getOrderId());
    request.setPayee(tab.getPayee());
    request.setPayer(tab.getPayer());
    request.setText(tab.getText());
    request.setUsecase(tab.getUsecase());
    response = wsStartVoucherClient.startvoucher(request);
    transaction = response.getTransaction();

    if (!evaluateMobiliserResponse(response)) {
      LOG.warn("# Error during start voucher preauthorization");
      return false;
    }

    LOG.info(
        "# start voucher preauthorise transaction[{}] money successfully finished",
        tab.getModule());

    // Calculate fees and amounts
    long payeeFee = 0;
    long payerFee = 0;
    for (MoneyFeeType mft : response.getMoneyFee()) {
      if (mft.isPayee()) {
        payeeFee += mft.getValue();
        payeeFee += mft.getVat();
      } else {
        // isPayer
        payerFee += mft.getValue();
        payerFee += mft.getVat();
      }
    }

    tab.setFeeAmount(payerFee + payeeFee);
    tab.setDebitAmount(tab.getAmount().getValue() + payerFee);
    tab.setCreditAmount(tab.getAmount().getValue() - payeeFee);
    tab.setAuthenticationMethodPayee(
        Integer.valueOf(response.getAuthenticationMethods().getAuthMethodPayee().getId()));
    tab.setAuthenticationMethodPayer(
        Integer.valueOf(response.getAuthenticationMethods().getAuthMethodPayer().getId()));
    tab.setPreAuthFinished(true);
    tab.setRefTransaction(response.getTransaction());
    return true;
  }
Пример #2
0
  private void sendMoneyNext() {
    LOG.debug("#SendMoneyPage.sendMoneyNext()");

    if (getTxnText().length() > Integer.valueOf(Constants.MAX_LENGTH_SEND_MONEY_TXN_TEXT)) {
      error(getLocalizer().getString("sendMoney.text.length.error", this));
      return;
    }

    PhoneNumber pn = new PhoneNumber(getRecipient(), getConfiguration().getCountryCode());

    com.sybase365.mobiliser.util.tools.wicketutils.security.Customer loggedInCustomer =
        getMobiliserWebSession().getLoggedInCustomer();

    convertAmount();
    TransactionBean tab = new TransactionBean();
    VatAmount vatAmnt = new VatAmount();
    SVA sva = null;
    try {
      WalletEntry wallet = getSvaPI(getMobiliserWebSession().getLoggedInCustomer().getCustomerId());
      if (PortalUtils.exists(wallet)) sva = wallet.getSva();
      if (PortalUtils.exists(sva)) {
        vatAmnt.setCurrency(
            PortalUtils.exists(sva.getCurrency())
                ? sva.getCurrency()
                : getConfiguration().getCurrency());
      } else {
        vatAmnt.setCurrency(getConfiguration().getCurrency());
      }

    } catch (Exception e1) {
      LOG.error("# Error while getting SVA's payment instrument", e1);
    }

    vatAmnt.setValue(amount);

    tab.setAmount(vatAmnt);
    tab.setAutoCapture(true);
    tab.setUsecase(Integer.valueOf(Constants.USE_CASE_SEND_MONEY));
    tab.setText(txnText);

    TransactionParticipant payer = new TransactionParticipant();
    Identifier payerId = new Identifier();
    payerId.setType(Constants.IDENT_TYPE_CUST_ID);
    payerId.setValue(String.valueOf(loggedInCustomer.getCustomerId()));
    payer.setIdentifier(payerId);
    tab.setPayer(payer);

    TransactionParticipant payee = new TransactionParticipant();
    Identifier payeeId = new Identifier();
    payeeId.setType(Constants.IDENT_TYPE_MSISDN);
    payeeId.setValue(pn.getInternationalFormat());
    payee.setIdentifier(payeeId);
    tab.setPayee(payee);
    tab.setModule(Constants.MODULE_SEND_MONEY);

    Customer payeeCustomer =
        getCustomerByIdentification(Constants.IDENT_TYPE_MSISDN, pn.getInternationalFormat());

    try {
      if (PortalUtils.exists(payeeCustomer)) {
        if (handleTransaction(tab)) setResponsePage(new SendMoneyFriendConfirmPage(tab, false));
      } else {
        if (startVoucher(tab)) setResponsePage(new SendMoneyFriendConfirmPage(tab, true));
      }
    } catch (Exception e) {
      LOG.error("# An error occurred during Preauthorization", e);
      error(getLocalizer().getString("preauthorization.error", this));
      return;
    }
  }