private void processOnline(){
  log.config("");
  if (!checkMandatory())   return;
  boolean approved=false;
  String info="";
  ValueNamePair vp=(ValueNamePair)paymentCombo.getSelectedItem();
  String PaymentRule=vp.getValue();
  if (PaymentRule.equals(X_C_Order.PAYMENTRULE_CreditCard)) {
    vp=(ValueNamePair)kTypeCombo.getSelectedItem();
    String CCType=vp.getValue();
    m_mPayment.setCreditCard(MPayment.TRXTYPE_Sales,CCType,kNumberField.getText(),"",kExpField.getText());
    m_mPayment.setA_Name(kNameField.getText());
    m_mPayment.setAmount(m_C_Currency_ID,m_Amount);
    m_mPayment.setPaymentProcessor();
    m_mPayment.setC_BPartner_ID(m_C_BPartner_ID);
    int C_Invoice_ID=Env.getContextAsInt(Env.getCtx(),m_WindowNo,"C_Invoice_ID");
    int C_Order_ID=Env.getContextAsInt(Env.getCtx(),m_WindowNo,"C_Order_ID");
    if (C_Invoice_ID == 0 && m_DocStatus.equals("CO"))     C_Invoice_ID=getInvoiceID(C_Order_ID,null);
    if (C_Invoice_ID != 0)     m_mPayment.setC_Invoice_ID(C_Invoice_ID);
 else     if (C_Order_ID != 0)     m_mPayment.setC_Order_ID(C_Order_ID);
    m_mPayment.setDateTrx(m_DateAcct);
    m_mPayment.setAmount(m_C_Currency_ID,m_Amount);
    if (!m_mPayment.save()) {
      ADialog.error(m_WindowNo,this,"PaymentError","PaymentNotCreated");
    }
 else {
      approved=m_mPayment.processOnline();
      info=m_mPayment.getR_RespMsg() + " (" + m_mPayment.getR_AuthCode()+ ") ID="+ m_mPayment.getR_PnRef();
      m_mPayment.saveEx();
      if (approved) {
        boolean ok=m_mPayment.processIt(DocAction.ACTION_Complete);
        m_mPayment.saveEx();
        if (ok)         ADialog.info(m_WindowNo,this,"PaymentProcessed",info + "\n" + m_mPayment.getDocumentNo());
 else         ADialog.error(m_WindowNo,this,"PaymentError","PaymentNotCreated");
        saveChanges();
        dispose();
      }
 else {
        ADialog.error(m_WindowNo,this,"PaymentNotProcessed",info);
      }
    }
  }
 else   ADialog.error(m_WindowNo,this,"PaymentNoProcessor");
}

private void processOnline ( ) { log . config ( "" ) ; if ( ! checkMandatory ( ) ) return ; boolean approved = false ; String info = "" ; ValueNamePair vp = ( ValueNamePair ) paymentCombo . getSelectedItem ( ) ; String PaymentRule = vp . getValue ( ) ; if ( PaymentRule . equals ( X_C_Order . PAYMENTRULE_CreditCard ) ) { vp = ( ValueNamePair ) kTypeCombo . getSelectedItem ( ) ; String CCType = vp . getValue ( ) ; m_mPayment . setCreditCard ( MPayment . TRXTYPE_Sales , CCType , kNumberField . getText ( ) , "" , kExpField . getText ( ) ) ; m_mPayment . setA_Name ( kNameField . getText ( ) ) ; m_mPayment . setAmount ( m_C_Currency_ID , m_Amount ) ; m_mPayment . setPaymentProcessor ( ) ; m_mPayment . setC_BPartner_ID ( m_C_BPartner_ID ) ; int C_Invoice_ID = Env . getContextAsInt ( Env . getCtx ( ) , m_WindowNo , "C_Invoice_ID" ) ; int C_Order_ID = Env . getContextAsInt ( Env . getCtx ( ) , m_WindowNo , "C_Order_ID" ) ; if ( C_Invoice_ID == 0 && m_DocStatus . equals ( "CO" ) ) C_Invoice_ID = getInvoiceID ( C_Order_ID , null ) ; if ( C_Invoice_ID != 0 ) m_mPayment . setC_Invoice_ID ( C_Invoice_ID ) ; else if ( C_Order_ID != 0 ) m_mPayment . setC_Order_ID ( C_Order_ID ) ; m_mPayment . setDateTrx ( m_DateAcct ) ; m_mPayment . setAmount ( m_C_Currency_ID , m_Amount ) ; if ( ! m_mPayment . save ( ) ) { ADialog . error ( m_WindowNo , this , "PaymentError" , "PaymentNotCreated" ) ; } else { approved = m_mPayment . processOnline ( ) ; info = m_mPayment . getR_RespMsg ( ) + " (" + m_mPayment . getR_AuthCode ( ) + ") ID=" + m_mPayment . getR_PnRef ( ) ; m_mPayment . saveEx ( ) ; if ( approved ) { boolean ok = m_mPayment . processIt ( DocAction . ACTION_Complete ) ; m_mPayment . saveEx ( ) ; if ( ok ) ADialog . info ( m_WindowNo , this , "PaymentProcessed" , info + "\n" + m_mPayment . getDocumentNo ( ) ) ; else ADialog . error ( m_WindowNo , this , "PaymentError" , "PaymentNotCreated" ) ; saveChanges ( ) ; dispose ( ) ; } else { ADialog . error ( m_WindowNo , this , "PaymentNotProcessed" , info ) ; } } } else ADialog . error ( m_WindowNo , this , "PaymentNoProcessor" ) ; }
process online ( sales only ) - if approved - exit
