Exemplo n.º 1
0
void arWorkBench::sVoidPreauth()
{
  CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
  if (! cardproc->errorMsg().isEmpty())
  {
    QMessageBox::warning( this, tr("Credit Card Error"), cardproc->errorMsg() );
    _CCAmount->setFocus();
    return;
  }

  _postPreauth->setEnabled(false);
  _voidPreauth->setEnabled(false);
  int ccpayid   = _preauth->id();
  QString ordernum;
  int returnVal = cardproc->voidPrevious(ccpayid);
  if (returnVal < 0)
    QMessageBox::critical(this, tr("Credit Card Processing Error"),
			  cardproc->errorMsg());
  else if (returnVal > 0)
    QMessageBox::warning(this, tr("Credit Card Processing Warning"),
			 cardproc->errorMsg());
  else if (! cardproc->errorMsg().isEmpty())
    QMessageBox::information(this, tr("Credit Card Processing Note"),
			 cardproc->errorMsg());
  else
    _CCAmount->clear();

  sFillCashrcptList();
  sFillAropenCMList();
  sFillAropenList();
  sFillPreauthList();

  _voidPreauth->setEnabled(true);
  _postPreauth->setEnabled(true);
}
Exemplo n.º 2
0
// pcompany should be "" except when checking for errors in configCC
CreditCardProcessor * CreditCardProcessor::getProcessor(const QString pcompany)
{
  if (DEBUG)
    qDebug("CCP:getProcessor(%s)", pcompany.toAscii().data());

  if (pcompany == "Authorize.Net")
    return new AuthorizeDotNetProcessor();

  else if (pcompany == "Verisign")
    return new VerisignProcessor();

  else if (pcompany == "YourPay")
    return new YourPayProcessor();

  else if (! pcompany.isEmpty())
  {
    _errorMsg = errorMsg(-14).arg(pcompany);
    return 0;
  }

  CreditCardProcessor *processor = 0;

  if (_metrics->value("CCCompany") == "Authorize.Net")
    processor = new AuthorizeDotNetProcessor();

  else if (_metrics->value("CCCompany") == "Verisign")
    processor = new VerisignProcessor();

  else if ((_metrics->value("CCCompany") == "YourPay"))
    processor = new YourPayProcessor();

  else
    _errorMsg = errorMsg(-14).arg(_metrics->value("CCServer"));

  // reset to 0 if the config is bad and we're not configuring the system
  if (processor && processor->testConfiguration() != 0 && pcompany.isEmpty())
  {
    delete processor;
    processor = 0;
  }

  if (processor)
    processor->reset();

  return processor;
}
Exemplo n.º 3
0
void dspCreditCardTransactions::sPostPreauth()
{
  CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
  if (! cardproc)
  {
    QMessageBox::critical(this, tr("Credit Card Processing Error"),
                          CreditCardProcessor::errorMsg());
    return;
  }
  if (! cardproc->errorMsg().isEmpty())
  {
    QMessageBox::warning( this, tr("Credit Card Error"), cardproc->errorMsg() );
    _CCAmount->setFocus();
    return;
  }

  _postPreauth->setEnabled(false);
  _voidPreauth->setEnabled(false);
  int ccpayid   = _preauth->id();
  QString neworder = _preauth->currentItem()->text("docnumber");
  QString reforder = neworder;
  int returnVal = cardproc->chargePreauthorized("-2",
						_CCAmount->localValue(),
						_CCAmount->id(),
						neworder, reforder, ccpayid);
  if (returnVal < 0)
    QMessageBox::critical(this, tr("Credit Card Processing Error"),
			  cardproc->errorMsg());
  else if (returnVal > 0)
    QMessageBox::warning(this, tr("Credit Card Processing Warning"),
			 cardproc->errorMsg());
  else if (! cardproc->errorMsg().isEmpty())
    QMessageBox::information(this, tr("Credit Card Processing Note"),
			 cardproc->errorMsg());
  else
    _CCAmount->clear();

  sFillList();
  
  _voidPreauth->setEnabled(true);
  _postPreauth->setEnabled(true);
}
Exemplo n.º 4
0
void configureCC::sSave()
{
  _metrics->set("CCAccept",          _ccAccept->isChecked());
  _metrics->set("CCTest",            _ccTest->isChecked());
  _metrics->set("CCValidDays",       _ccValidDays->value());
  _metrics->set("CCCompany",         _ccCompany->currentText());
  _metrics->set("CCServer",          _ccServer->text());
  _metrics->set("CCPort",            _ccPort->text());
  _metrics->set("CCUseProxyServer",  _ccUseProxyServer->isChecked());
  _metrics->set("CCProxyServer",     _ccProxyServer->text());
  _metrics->set("CCProxyPort",       _ccProxyPort->text());
  _metrics->set("CCDefaultBank",     _ccDefaultBank->id());
  _metrics->set("CCEncKeyName",      _ccEncKeyName->text());
  _metrics->set("CCWinEncKey",       _ccWinEncKey->text());
  _metrics->set("CCLinEncKey",       _ccLinEncKey->text());
  _metrics->set("CCMacEncKey",       _ccMacEncKey->text());

  _metrics->set("CCANVer",               _anVersion->currentText());
  _metrics->set("CCANDelim",             _anDelim->text());
  _metrics->set("CCANEncap",             _anEncap->text());
  _metrics->set("CCANDuplicateWindow",   _anDuplicateWindow->cleanText());
  _metrics->set("CCANMD5HashSetOnGateway", _anMD5HashSetOnGateway->isChecked());
  if (_anMD5HashWarn->isChecked())
    _metrics->set("CCANMD5HashAction", QString("W"));
  else if (_anMD5HashFail->isChecked())
    _metrics->set("CCANMD5HashAction", QString("F"));

  if (_anCurrFixed->isChecked())
    _metrics->set("CCANCurrency", _anCurrFixedValue->id());
  else // if (_anCurrTransaction->isChecked())
    _metrics->set("CCANCurrency", QString("TRANS"));
  _metrics->set("CCANWellsFargoSecureSource", _anUsingWellsFargoSecureSource->isChecked());

  _metrics->set("CCYPWinPathPEM",    _ccYPWinPathPEM->text());
  _metrics->set("CCYPLinPathPEM",    _ccYPLinPathPEM->text());
  _metrics->set("CCYPMacPathPEM",    _ccYPMacPathPEM->text());
  _metrics->set("CCYPLinkShield",    _ccYPLinkShield->isChecked());
  _metrics->set("CCYPLinkShieldMax", _ccYPLinkShieldMax->text());

  _metrics->set("CCConfirmPreauth",       _confirmPreauth->isChecked());
  _metrics->set("CCConfirmCharge",        _confirmCharge->isChecked());
  _metrics->set("CCConfirmChargePreauth", _confirmChargePreauth->isChecked());
  _metrics->set("CCConfirmCredit",        _confirmCredit->isChecked());

  _metrics->set("CCEnablePreauth",       _enablePreauth->isChecked());
  _metrics->set("CCEnableCharge",        _enableCharge->isChecked());
  _metrics->set("CCEnableChargePreauth", _enableChargePreauth->isChecked());
  _metrics->set("CCEnableCredit",        _enableCredit->isChecked());

  _metrics->set("CCRequireCVV", _cvvRequired->isChecked());
  if(_cvvNone->isChecked())
    _metrics->set("CCCVVCheck", QString("X"));
  else if(_cvvWarn->isChecked())
    _metrics->set("CCCVVCheck", QString("W"));
  else if(_cvvReject->isChecked())
    _metrics->set("CCCVVCheck", QString("F"));

  if(_avsNone->isChecked())
    _metrics->set("CCAvsCheck", QString("X"));
  else if(_avsWarn->isChecked())
    _metrics->set("CCAvsCheck", QString("W"));
  else if(_avsReject->isChecked())
    _metrics->set("CCAvsCheck", QString("F"));

  QString str;
  if (_cvvNotMatch->isChecked())
    str += "N";
  if (_cvvNotProcessed->isChecked())
    str += "P";
  if (_cvvNotOnCard->isChecked())
    str += "S";
  if (_cvvInvalidIssuer->isChecked())
    str += "U";
  _metrics->set("CCCVVErrors", str);

  if (_avsAddrNotMatch->isChecked() && _avsAddrNotAvail->isChecked())
    _metrics->set("CCAvsAddr", QString("NX"));
  else if (_avsAddrNotMatch->isChecked())
    _metrics->set("CCAvsAddr", QString("N"));
  else if (_avsAddrNotAvail->isChecked())
    _metrics->set("CCAvsAddr", QString("X"));

  if (_avsZIPNotMatch->isChecked() && _avsZIPNotAvail->isChecked())
    _metrics->set("CCAvsZIP", QString("NX"));
  else if (_avsZIPNotMatch->isChecked())
    _metrics->set("CCAvsZIP", QString("N"));
  else if (_avsZIPNotAvail->isChecked())
    _metrics->set("CCAvsZIP", QString("X"));

  if(_testsAllFail->isChecked())
    _metrics->set("CCTestResult", QString("F"));
  else if(_testsSomeFail->isChecked())
    _metrics->set("CCTestResult", QString("S"));
  else if(_testsAllPass->isChecked())
    _metrics->set("CCTestResult", QString("P"));

  _metrics->load();

  if (0 != _metricsenc)
  {
    _metricsenc->set("CCLogin",         _ccLogin->text());
    _metricsenc->set("CCPassword",      _ccPassword->text());
    _metricsenc->set("CCProxyLogin",    _ccProxyLogin->text());
    _metricsenc->set("CCProxyPassword", _ccProxyPassword->text());
    _metricsenc->set("CCYPStoreNum",    _ccYPStoreNum->text());
    _metricsenc->set("CCANMD5Hash",     _anMD5Hash->text());

    _metricsenc->load();
  }

  CreditCardProcessor *cardproc =
		  CreditCardProcessor::getProcessor(_ccCompany->currentText());
  if (! cardproc)
  {
    QMessageBox::warning(this, tr("Error getting Credit Card Processor"),
			 tr("<p>Internal error finding the right Credit Card "
			    "Processor. The application saved what it could "
			    "but you should re-open this window and double-"
			    "check all of the settings before continuing."));
  }
  else if (cardproc && cardproc->testConfiguration() != 0)
  {
    if (QMessageBox::question(this, tr("Invalid Credit Card Configuration"),
			      tr("<p>The configuration has been saved but "
				 "at least one configuration option appears "
				 "to be invalid:<p>%1"
				 "<p>Would you like to fix it now?")
			      .arg(cardproc->errorMsg()),
			      QMessageBox::Yes | QMessageBox::Default,
			      QMessageBox::No) == QMessageBox::Yes)
      return;
  }

  accept();
}
Exemplo n.º 5
0
void arWorkBench::sCCRefundCM()
{
    if (_aropenCM->altId() < 0)
    {
        QMessageBox::warning(this, tr("Cannot Refund by Credit Card"),
                             tr("<p>The application cannot refund this "
                                "transaction using a credit card."));
        return;
    }

    int     ccardid = -1;
    double  total   =  0.0;
    double  tax     =  0.0;
    double  freight =  0.0;
    double  duty    =  0.0;
    int     currid  = -1;
    bool    taxexempt = false;
    QString docnum;
    QString refnum;
    int     ccpayid = -1;

    q.prepare("SELECT cmhead_id "
              "FROM cmhead "
              "WHERE (cmhead_number=:cmheadnumber);");
    q.bindValue(":cmheadnumber", _aropenCM->currentItem()->text(1));
    q.exec();
    if (q.first())
    {
        ParameterList ccp;
        ccp.append("cmhead_id", q.value("cmhead_id"));
        MetaSQLQuery ccm = mqlLoad(":/so/creditMemoCreditCard.mql");
        XSqlQuery ccq = ccm.toQuery(ccp);
        if (ccq.first())
        {
            ccardid = ccq.value("ccard_id").toInt();
            total   = ccq.value("total").toDouble();
            tax     = ccq.value("tax_in_cmcurr").toDouble();
            taxexempt = ccq.value("cmhead_tax_id").isNull();
            freight = ccq.value("cmhead_freight").toDouble();
            currid  = ccq.value("cmhead_curr_id").toInt();
            docnum  = ccq.value("cmhead_number").toString();
            refnum  = ccq.value("cohead_number").toString();
            ccpayid = ccq.value("ccpay_id").toInt();
        }
        else if (ccq.lastError().type() != QSqlError::None)
        {
            systemError(this, ccq.lastError().databaseText(), __FILE__, __LINE__);
            return;
        }
        else
        {
            QMessageBox::critical(this, tr("Credit Card Processing Error"),
                                  tr("Could not find a Credit Card to use for "
                                     "this Credit transaction."));
            return;
        }
    }
    else if (q.lastError().type() != QSqlError::None)
    {
        systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
        return;
    }
    else // cmhead not found - maybe it's just an open item
    {
        q.prepare("SELECT ccard_id, aropen_amount - aropen_paid AS balance,"
                  "       aropen_curr_id, aropen_docnumber "
                  "FROM aropen, ccard "
                  "WHERE ((aropen_cust_id=ccard_cust_id)"
                  "  AND  (ccard_active)"
                  "  AND  (aropen_open)"
                  "  AND  (aropen_id=:aropenid));");
        q.bindValue(":aropenid", _aropenCM->id());
        q.exec();

        if (q.first())
        {
            ccardid = q.value("ccard_id").toInt();
            total   = q.value("balance").toDouble();
            currid  = q.value("aropen_curr_id").toInt();
            docnum  = q.value("aropen_docnumber").toString();
        }
        else if (q.lastError().type() != QSqlError::None)
        {
            systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
            return;
        }
        else
        {
            QMessageBox::critical(this, tr("Credit Card Processing Error"),
                                  tr("Could not find a Credit Card to use for "
                                     "this Credit transaction."));
            return;
        }
    }

    CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
    if (! cardproc)
        QMessageBox::critical(this, tr("Credit Card Processing Error"),
                              CreditCardProcessor::errorMsg());
    else
    {
        int refid = _aropenCM->id();
        int returnVal = cardproc->credit(ccardid, -2, total, tax, taxexempt,
                                         freight, duty, currid,
                                         docnum, refnum, ccpayid, "aropen", refid);
        if (returnVal < 0)
            QMessageBox::critical(this, tr("Credit Card Processing Error"),
                                  cardproc->errorMsg());
        else if (returnVal > 0)
            QMessageBox::warning(this, tr("Credit Card Processing Warning"),
                                 cardproc->errorMsg());
        else if (! cardproc->errorMsg().isEmpty())
            QMessageBox::information(this, tr("Credit Card Processing Note"),
                                     cardproc->errorMsg());
    }

    sFillList();
}
Exemplo n.º 6
0
void returnAuthorizationWorkbench::sProcess()
{
  if (!checkSitePrivs(_radue->id()))
    return;
  
  bool _post = ((_radue->altId() > 1) ||
		(_radue->altId() == 1 && _postmemos->isChecked())) ;

  q.prepare("SELECT createRaCreditMemo(:rahead_id,:post) AS result;");
  q.bindValue(":rahead_id",_radue->id());
  q.bindValue(":post",QVariant(_post));
  q.exec();
  if (q.first())
  {
    int cmheadid = q.value("result").toInt();
    if (cmheadid < 0)
    {
      systemError(this, storedProcErrorLookup("createRaCreditMemo", cmheadid), __FILE__, __LINE__);
      return;
    }
    q.prepare( "SELECT cmhead_number "
               "FROM cmhead "
               "WHERE (cmhead_id=:cmhead_id);" );
    q.bindValue(":cmhead_id", cmheadid);
    q.exec();
    if (q.first())
    {
      QMessageBox::information( this, tr("New Credit Memo Created"),
                                tr("<p>A new CreditMemo has been created and "
				                   "assigned #%1")
                                   .arg(q.value("cmhead_number").toString()));
	  if (_printmemo->isChecked())
	  {
		ParameterList params;
		params.append("cmhead_id", cmheadid);
		if (_post)
		  params.append("posted");

		printCreditMemo newdlg(this, "", TRUE);
		newdlg.set(params);
		newdlg.exec();
	  }
      if (_radue->altId() == 2)
      {
        ParameterList params;
        params.append("cmhead_id", cmheadid);

        returnAuthCheck newdlg(this, "", TRUE);
        newdlg.set(params);
        if (newdlg.exec() != XDialog::Rejected)
          sFillListDue();
      }
      else if (_radue->altId() == 3)
      {
	ParameterList ccp;
	ccp.append("cmhead_id", cmheadid);
  MetaSQLQuery ccm = mqlLoad("creditMemoCreditCards", "detail");
	XSqlQuery ccq = ccm.toQuery(ccp);
	if (ccq.first())
	{
	  int ccpayid = ccq.value("ccpay_id").toInt();
	  CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
	  if (! cardproc)
	    QMessageBox::critical(this, tr("Credit Card Processing Error"),
				  CreditCardProcessor::errorMsg());
	  else if (! cardproc->errorMsg().isEmpty())
	    QMessageBox::critical(this, tr("Credit Card Processing Warning"),
				 cardproc->errorMsg());
	  else
	  {
	    QString docnum = q.value("cmhead_number").toString();
	    QString refnum = ccq.value("cohead_number").toString();
	    int refid = -1;
	    int returnValue = cardproc->credit(ccq.value("ccard_id").toInt(),
					 -2,
					 ccq.value("total").toDouble(),
					 ccq.value("tax_in_cmcurr").toDouble(),
					 ccq.value("cmhead_tax_id").isNull(),
					 ccq.value("cmhead_freight").toDouble(),
					 0,
					 ccq.value("cmhead_curr_id").toInt(),
					 docnum, refnum, ccpayid,
					 QString(), refid);
	    if (returnValue < 0)
	      QMessageBox::critical(this, tr("Credit Card Processing Error"),
				    cardproc->errorMsg());
	    else if (returnValue > 0)
	      QMessageBox::warning(this, tr("Credit Card Processing Warning"),
				   cardproc->errorMsg());
	    else if (! cardproc->errorMsg().isEmpty())
	      QMessageBox::information(this, tr("Credit Card Processing Note"),
				   cardproc->errorMsg());
	  }
	  // requery regardless 'cause the new credit memo means nothing's "due"
	  sFillListDue();
	}
	else if (ccq.lastError().type() != QSqlError::NoError)
	{
	  systemError(this, ccq.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
	else
	{
	  QMessageBox::critical(this, tr("Credit Card Processing Error"),
				tr("Could not find a Credit Card to use for "
				   "this Credit transaction."));
	  sFillListDue();
	  return;
	}
      }
      else
	sFillListDue();
    }
    else if (q.lastError().type() != QSqlError::NoError)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
  else if (q.lastError().type() != QSqlError::NoError)
  {
    systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
}
Exemplo n.º 7
0
void openSalesOrders::sDelete()
{
  if ( QMessageBox::warning(this, tr("Delete Sales Order?"),
                            tr("<p>Are you sure that you want to completely "
			       "delete the selected Sales Order?"),
			    QMessageBox::Yes,
			    QMessageBox::No | QMessageBox::Default) == QMessageBox::Yes)
  {
    q.prepare("SELECT deleteSo(:sohead_id) AS result;");
    q.bindValue(":sohead_id", _so->id());
    q.exec();
    if (q.first())
    {
      bool closeInstead = false;
      int result = q.value("result").toInt();
      if (result == -4 && _privleges->check("ProcessCreditCards"))
      {
	if ( QMessageBox::question(this, tr("Cannot Delete Sales Order"),
				   storedProcErrorLookup("deleteSo", result) + 
				   "<br>Would you like to refund the amount "
				   "charged and close the Sales Order instead?",
				   QMessageBox::Yes | QMessageBox::Default,
				   QMessageBox::No) == QMessageBox::Yes)
	{
	  CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
	  if (! cardproc)
	    QMessageBox::critical(this, tr("Credit Card Processing Error"),
				  CreditCardProcessor::errorMsg());
	  else
	  {
	    XSqlQuery ccq;
	    ccq.prepare("SELECT ccpay_ccard_id, ccpay_curr_id,"
			"       SUM(ccpay_amount     * sense) AS amount,"
			"       SUM(ccpay_r_tax      * sense) AS tax,"
			"       SUM(ccpay_r_shipping * sense) AS freight "
			"FROM (SELECT ccpay_ccard_id, ccpay_curr_id, "
			"             CASE WHEN ccpay_status = 'C' THEN  1"
			"                  WHEN ccpay_status = 'R' THEN -1"
			"             END AS sense,"
			"             ccpay_amount,"
			"             COALESCE(ccpay_r_tax::NUMERIC, 0) AS ccpay_r_tax,"
			"             COALESCE(ccpay_r_shipping::NUMERIC, 0) AS ccpay_r_shipping "
			"      FROM ccpay, payco "
			"      WHERE ((ccpay_id=payco_ccpay_id)"
			"        AND  (ccpay_status IN ('C', 'R'))"
			"        AND  (payco_cohead_id=:coheadid)) "
			"      ) AS dummy "
			"GROUP BY ccpay_ccard_id, ccpay_curr_id;");
	    ccq.bindValue(":coheadid", _so->id());
	    ccq.exec();
	    if (ccq.first())
	    do
	    {
	      QString docnum = _so->currentItem()->text(0);
	      QString refnum = docnum;
	      int ccpayid = -1;
	      int coheadid = _so->id();
	      int returnVal = cardproc->credit(ccq.value("ccpay_ccard_id").toInt(),
					       -2,
					       ccq.value("amount").toDouble(),
					       ccq.value("tax").toDouble(),
					       true,
					       ccq.value("freight").toDouble(),
					       0,
					       ccq.value("ccpay_curr_id").toInt(),
					       docnum, refnum, ccpayid,
					       "cohead", coheadid);
	      if (returnVal < 0)
	      {
		QMessageBox::critical(this, tr("Credit Card Processing Error"),
				      cardproc->errorMsg());
		return;
	      }
	      else if (returnVal > 0)
	      {
		QMessageBox::warning(this, tr("Credit Card Processing Warning"),
				     cardproc->errorMsg());
		closeInstead = true;
	      }
	      else if (! cardproc->errorMsg().isEmpty())
	      {
		QMessageBox::information(this, tr("Credit Card Processing Note"),
				     cardproc->errorMsg());
		closeInstead = true;
	      }
	    } while (ccq.next());
	    else if (ccq.lastError().type() != QSqlError::None)
	    {
	      systemError(this, ccq.lastError().databaseText(),
			  __FILE__, __LINE__);
	      return;
	    }
	    else
	    {
	      systemError(this, tr("Could not find the ccpay records!"),
			  __FILE__, __LINE__);
	      return;
	    }

	  }
	}
      }
      else if (result == -1 || result == -5)
      {
	if ( QMessageBox::question(this, tr("Cannot Delete Sales Order"),
				   storedProcErrorLookup("deleteSo", result) + 
				   "<br>Would you like to Close the selected "
				   "Sales Order instead?",
				   QMessageBox::Yes | QMessageBox::Default,
				   QMessageBox::No) == QMessageBox::Yes)
	  closeInstead = true;
      }
      else if (result < 0)
      {
	systemError(this, storedProcErrorLookup("deleteSo", result),
		    __FILE__, __LINE__);
	return;
      }

      if (closeInstead)
      {
	q.prepare( "UPDATE coitem "
		   "SET coitem_status='C' "
		   "WHERE ((coitem_status <> 'X')"
		   "  AND  (coitem_cohead_id=:sohead_id));" );
	q.bindValue(":sohead_id", _so->id());
	q.exec();
	if (q.lastError().type() != QSqlError::None)
	{
	  systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
	  return;
	}
      }

      omfgThis->sSalesOrdersUpdated(-1);
      omfgThis->sProjectsUpdated(-1);
    }
    else if (q.lastError().type() != QSqlError::None)
    {
      systemError(this, q.lastError().databaseText(), __FILE__, __LINE__);
      return;
    }
  }
}
Exemplo n.º 8
0
void dspAROpenItems::sCCRefundCM()
{
  XSqlQuery dspCCRefundCM;
  if (list()->id("ccard_number") < 0)
  {
    QMessageBox::warning(this, tr("Cannot Refund by Credit Card"),
			 tr("<p>The application cannot refund this "
			    "transaction using a credit card."));
    return;
  }
  
  int     ccardid = -1;
  double  total   =  0.0;
  double  tax     =  0.0;
  double  freight =  0.0;
  double  duty    =  0.0;
  int     currid  = -1;
  bool    taxexempt = false;
  QString docnum;
  QString refnum;
  int     ccpayid = list()->currentItem()->id("ccard_number");

  dspCCRefundCM.prepare("SELECT ccpay_ccard_id, aropen_amount - aropen_paid AS balance, "
	    "       aropen_curr_id, aropen_docnumber "
            "FROM aropen "
            "     JOIN payaropen ON (aropen_id=payaropen_aropen_id) "
            "     JOIN ccpay ON (payaropen_ccpay_id=ccpay_id) "
            "WHERE ((aropen_id=:aropen_id)"
            "  AND  (ccpay_id=:ccpay_id));");
  dspCCRefundCM.bindValue(":aropen_id", list()->id());
  dspCCRefundCM.bindValue(":ccpay_id",  ccpayid);
  dspCCRefundCM.exec();
  if (dspCCRefundCM.first())
  {
    ccardid = dspCCRefundCM.value("ccpay_ccard_id").toInt();
    total   = dspCCRefundCM.value("balance").toDouble();
    currid  = dspCCRefundCM.value("aropen_curr_id").toInt();
    docnum  = dspCCRefundCM.value("aropen_docnumber").toString();
  }
  else if (dspCCRefundCM.lastError().type() != QSqlError::NoError)
  {
    systemError(this, dspCCRefundCM.lastError().databaseText(), __FILE__, __LINE__);
    return;
  }
  else
  {
    QMessageBox::critical(this, tr("Credit Card Processing Error"),
                          tr("Could not find a Credit Card to use for "
                             "this Credit transaction."));
    return;
  }

  CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();
  if (! cardproc)
    QMessageBox::critical(this, tr("Credit Card Processing Error"),
			  CreditCardProcessor::errorMsg());
  else
  {
    int refid = list()->id();
    int returnVal = cardproc->credit(ccardid, "-2", total, tax, taxexempt,
				     freight, duty, currid,
				     docnum, refnum, ccpayid, "aropen", refid);
    if (returnVal < 0)
      QMessageBox::critical(this, tr("Credit Card Processing Error"),
			    cardproc->errorMsg());
    else if (returnVal > 0)
      QMessageBox::warning(this, tr("Credit Card Processing Warning"),
			   cardproc->errorMsg());
    else if (! cardproc->errorMsg().isEmpty())
      QMessageBox::information(this, tr("Credit Card Processing Note"),
			   cardproc->errorMsg());
  }

  sFillList();
}
Exemplo n.º 9
0
bool configureCC::sSave()
{
  emit saving();

  _metrics->set("CCAccept",          _ccAccept->isChecked());
  _metrics->set("CCTest",            _ccTest->isChecked());
  _metrics->set("CCValidDays",       _ccValidDays->value());
  _metrics->set("CCCompany",         _ccCompany->currentText());
  _metrics->set("CCServer",          _ccServer->text());
  _metrics->set("CCPort",            _ccPort->text());
  _metrics->set("CCUseProxyServer",  _ccUseProxyServer->isChecked());
  _metrics->set("CCProxyServer",     _ccProxyServer->text());
  _metrics->set("CCProxyPort",       _ccProxyPort->text());

  XSqlQuery ccbankq;
  ccbankq.prepare("SELECT setCCBankAccnt(:cctype, :bankaccnt_id) AS result;");

  ccbankq.bindValue(":cctype", "A");
  if (_amexBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _amexBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _amexBank->setFocus();
    return false;
  }

  ccbankq.bindValue(":cctype", "D");
  if (_discoverBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _discoverBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _discoverBank->setFocus();
    return false;
  }

  ccbankq.bindValue(":cctype", "M");
  if (_mastercardBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _mastercardBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _mastercardBank->setFocus();
    return false;
  }

  /*
  ccbankq.bindValue(":cctype", "P");
  if (_paypalBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _paypalBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _paypalBank->setFocus();
    return false;
  }
  */

  ccbankq.bindValue(":cctype", "V");
  if (_visaBank->isValid())
    ccbankq.bindValue(":bankaccnt_id", _visaBank->id());
  else
    ccbankq.bindValue(":bankaccnt_id", QVariant());
  ccbankq.exec();
  if (ccbankq.lastError().type() != QSqlError::NoError)
  {
    systemError(this, ccbankq.lastError().text(), __FILE__, __LINE__);
    _visaBank->setFocus();
    return false;
  }

  _metrics->set("CCYPWinPathPEM",    _ccYPWinPathPEM->text());
  _metrics->set("CCYPLinPathPEM",    _ccYPLinPathPEM->text());
  _metrics->set("CCYPMacPathPEM",    _ccYPMacPathPEM->text());
  _metrics->set("CCYPLinkShield",    _ccYPLinkShield->isChecked());
  _metrics->set("CCYPLinkShieldMax", _ccYPLinkShieldMax->text());

  _metrics->set("CCConfirmPreauth",       _confirmPreauth->isChecked());
  _metrics->set("CCConfirmCharge",        _confirmCharge->isChecked());
  _metrics->set("CCConfirmChargePreauth", _confirmChargePreauth->isChecked());
  _metrics->set("CCConfirmCredit",        _confirmCredit->isChecked());

  _metrics->set("CCEnablePreauth",       _enablePreauth->isChecked());
  _metrics->set("CCEnableCharge",        _enableCharge->isChecked());
  _metrics->set("CCEnableChargePreauth", _enableChargePreauth->isChecked());
  _metrics->set("CCEnableCredit",        _enableCredit->isChecked());

  _metrics->set("CCPrintReceipt",        _printReceipt->isChecked());

  _metrics->set("CCRequireCVV", _cvvRequired->isChecked());
  if(_cvvNone->isChecked())
    _metrics->set("CCCVVCheck", QString("X"));
  else if(_cvvWarn->isChecked())
    _metrics->set("CCCVVCheck", QString("W"));
  else if(_cvvReject->isChecked())
    _metrics->set("CCCVVCheck", QString("F"));

  if(_avsNone->isChecked())
    _metrics->set("CCAvsCheck", QString("X"));
  else if(_avsWarn->isChecked())
    _metrics->set("CCAvsCheck", QString("W"));
  else if(_avsReject->isChecked())
    _metrics->set("CCAvsCheck", QString("F"));

  QString str;
  if (_cvvNotMatch->isChecked())
    str += "N";
  if (_cvvNotProcessed->isChecked())
    str += "P";
  if (_cvvNotOnCard->isChecked())
    str += "S";
  if (_cvvInvalidIssuer->isChecked())
    str += "U";
  _metrics->set("CCCVVErrors", str);

  if (_avsAddrNotMatch->isChecked() && _avsAddrNotAvail->isChecked())
    _metrics->set("CCAvsAddr", QString("NX"));
  else if (_avsAddrNotMatch->isChecked())
    _metrics->set("CCAvsAddr", QString("N"));
  else if (_avsAddrNotAvail->isChecked())
    _metrics->set("CCAvsAddr", QString("X"));

  if (_avsZIPNotMatch->isChecked() && _avsZIPNotAvail->isChecked())
    _metrics->set("CCAvsZIP", QString("NX"));
  else if (_avsZIPNotMatch->isChecked())
    _metrics->set("CCAvsZIP", QString("N"));
  else if (_avsZIPNotAvail->isChecked())
    _metrics->set("CCAvsZIP", QString("X"));

  if(_testsAllFail->isChecked())
    _metrics->set("CCTestResult", QString("F"));
  else if(_testsSomeFail->isChecked())
    _metrics->set("CCTestResult", QString("S"));
  else if(_testsAllPass->isChecked())
    _metrics->set("CCTestResult", QString("P"));

  _metrics->load();

  if (0 != _metricsenc)
  {
    _metricsenc->set("CCLogin",         _ccLogin->text());
    _metricsenc->set("CCPassword",      _ccPassword->text());
    _metricsenc->set("CCProxyLogin",    _ccProxyLogin->text());
    _metricsenc->set("CCProxyPassword", _ccProxyPassword->text());
    _metricsenc->set("CCYPStoreNum",    _ccYPStoreNum->text());
    _metricsenc->set("CCPTDivisionNumber", _ccPTDivisionNumber->text());

    _metricsenc->load();
  }

  for (int i = 0; i < _configcclist.size(); i++)
    if (! _configcclist.at(i)->sSave())
      return false;

  if (_ccAccept->isChecked())
  {
    CreditCardProcessor *cardproc =
        CreditCardProcessor::getProcessor(_ccCompany->currentText());
    if (! cardproc)
    {
      QMessageBox::warning(this, tr("Error getting Credit Card Processor"),
                           tr("<p>Internal error finding the right Credit Card "
                              "Processor. The application saved what it could "
                              "but you should re-open this window and double-"
                              "check all of the settings before continuing."));
    }
    else if (cardproc && cardproc->testConfiguration() != 0)
    {
      if (QMessageBox::question(this, tr("Invalid Credit Card Configuration"),
                                tr("<p>The configuration has been saved but "
                                   "at least one configuration option appears "
                                   "to be invalid:<p>%1"
                                   "<p>Would you like to fix it now?")
        .arg(cardproc->errorMsg()),
        QMessageBox::Yes | QMessageBox::Default,
        QMessageBox::No) == QMessageBox::Yes)
        return false;
    }
  }

  configureEncryption *encryption = _keyPage->findChild<configureEncryption*>("_encryption");
  if (encryption && ! encryption->sSave())
    return false;

  return true;
}
Exemplo n.º 10
0
void arWorkBench::precheckCreditCard()
{
  CreditCardProcessor *cardproc = CreditCardProcessor::getProcessor();

  if (cardproc->checkConfiguration() < 0)
  {
    QMessageBox::warning( this, tr("Credit Card Error"),
			  cardproc->errorMsg() );
    _CCAmount->setFocus();
    _passPrecheck = false;
  }

  q.prepare( "SELECT ccpay.*, "
             "       ccard_active, "
             "       formatbytea(decrypt(setbytea(ccard_number), setbytea(:key), 'bf')) AS ccard_number,"
             "       formatccnumber(decrypt(setbytea(ccard_number), setbytea(:key), 'bf')) AS ccard_number_x,"
             "       formatbytea(decrypt(setbytea(ccard_month_expired), setbytea(:key), 'bf')) AS ccard_month_expired,"
             "       formatbytea(decrypt(setbytea(ccard_year_expired), setbytea(:key), 'bf')) AS ccard_year_expired, "
             "       ccard_type "
             "FROM ccpay, ccard "
             "WHERE ((ccpay_ccard_id=ccard_id) "
             " AND (ccpay_id=:ccpay_id));");
  q.bindValue(":ccpay_id", _preauth->id());
  q.bindValue(":key",key);
  q.exec();
  q.first();
  
  _ccActive = q.value("ccard_active").toBool();
  
  if (!_ccActive)
  {
    QMessageBox::warning( this, tr("Invalid Credit Card"),
                          tr("The Credit Card you are attempting to use is not active.") );
    _CCAmount->setFocus();
    _passPrecheck = false;
    return;
  }
  
  _ccard_type = q.value("ccard_type").toString();
  _ccard_number = q.value("ccard_number").toString();
  _ccard_month_expired = q.value("ccard_month_expired").toInt();
  _ccard_year_expired = q.value("ccard_year_expired").toInt();
  _ccard_type = q.value("ccard_type").toString();
  _backrefnum = q.value("ccpay_yp_r_ordernum").toString();
  
  YourPay = false;
  VeriSign = false;
  
  if (_metrics->value("CCServer") == "test-payflow.verisign.com"  ||  _metrics->value("CCServer") == "payflow.verisign.com") 
  {
    VeriSign = true; 
  }
  
  if (_metrics->value("CCServer") == "staging.linkpt.net"  ||  _metrics->value("CCServer") == "secure.linkpt.net") 
  {
    YourPay = true; 
  }
  
  if (!YourPay && !VeriSign)
  {
    QMessageBox::warning( this, tr("Invalid Credit Card Service Selected"),
                            tr("OpenMFG only supports YourPay and VeriSign.  You have not selected either of these as your credit card processors.") );
    _CCAmount->setFocus();
    _passPrecheck = false;
    return;
  }
  
  if (YourPay)
  {
    // Set up all of the YourPay parameters
    _storenum = _metricsenc->value("CCYPStoreNum");
     
#ifdef Q_WS_WIN
    _pemfile = _metrics->value("CCYPWinPathPEM");
#elif defined Q_WS_MACX
    _pemfile = _metrics->value("CCYPMacPathPEM");
#elif defined Q_WS_X11
    _pemfile = _metrics->value("CCYPLinPathPEM");
#endif
      
    if (_CCAmount->baseValue() <= 0)
    {
      QMessageBox::warning( this, tr("Charge Amount Missing or incorrect"),
                            tr("The Charge Amount must be greater than 0.00") );
      _CCAmount->setFocus();
      _passPrecheck = false;
      return;
    }
    
    configfile = new char[strlen(_storenum.latin1()) + 1];
    strcpy(configfile, _storenum.latin1());
    host = new char[strlen(_metrics->value("CCServer").latin1()) + 1];
    strcpy(host, _metrics->value("CCServer").latin1());
    pemfile = new char[strlen(_pemfile.latin1()) + 1];
    strcpy(pemfile, _pemfile.latin1());
  }
}