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); }
void arWorkBench::sFillList() { _CCAmount->clear(); sFillCashrcptList(); sFillAropenCMList(); sFillAropenList(); sFillPreauthList(); }
void arWorkBench::sFillList() { _CCAmount->clear(); XSqlQuery currQ; currQ.prepare("SELECT cust_curr_id FROM cust WHERE (cust_id=:cust_id)"); currQ.bindValue(":cust_id", _cust->id()); currQ.exec(); if (currQ.first()) _aropenTotal->setId(currQ.value("cust_curr_id").toInt()); else if (currQ.lastError().type() != QSqlError::NoError) systemError(this, currQ.lastError().databaseText(), __FILE__, __LINE__); sFillCashrcptList(); sFillAropenCMList(); sFillAropenList(); sFillPreauthList(); }
// for multicurrency implementation see comments marked ##### in salesOrder.ui.h void arWorkBench::processYourPay() { QDomDocument odoc; // Build the order QDomElement root = odoc.createElement("order"); odoc.appendChild(root); QDomElement elem, sub; // add the 'credit card' elem = odoc.createElement("creditcard"); QString work_month; work_month.setNum(_ccard_month_expired); if (work_month.length() == 1) work_month = "0" + work_month; sub = odoc.createElement("cardexpmonth"); sub.appendChild(odoc.createTextNode(work_month)); elem.appendChild(sub); QString work_year; work_year.setNum(_ccard_year_expired); work_year = work_year.right(2); sub = odoc.createElement("cardexpyear"); sub.appendChild(odoc.createTextNode(work_year)); elem.appendChild(sub); sub = odoc.createElement("cardnumber"); sub.appendChild(odoc.createTextNode(_ccard_number)); elem.appendChild(sub); root.appendChild(elem); // Build 'merchantinfo' elem = odoc.createElement("merchantinfo"); sub = odoc.createElement("configfile"); sub.appendChild(odoc.createTextNode(configfile)); elem.appendChild(sub); root.appendChild(elem); // Build 'orderoptions' elem = odoc.createElement("orderoptions"); sub = odoc.createElement("ordertype"); sub.appendChild(odoc.createTextNode("POSTAUTH")); elem.appendChild(sub); sub = odoc.createElement("result"); sub.appendChild(odoc.createTextNode("LIVE")); elem.appendChild(sub); root.appendChild(elem); // Build 'payment' elem = odoc.createElement("payment"); QString tmp; sub = odoc.createElement("chargetotal"); sub.appendChild(odoc.createTextNode(tmp.setNum(_CCAmount->baseValue(), 'f', 2))); // ##### localValue()? elem.appendChild(sub); root.appendChild(elem); // Build 'transaction details' elem = odoc.createElement("transactiondetails"); sub = odoc.createElement("oid"); sub.appendChild(odoc.createTextNode(_backrefnum)); elem.appendChild(sub); root.appendChild(elem); // Process the order saved_order = odoc.toString(); if (_metrics->boolean("CCTest")) { _metrics->set("CCOrder", saved_order); } proc = new QProcess( this ); QString curl_path; #ifdef Q_WS_WIN curl_path = qApp->applicationDirPath() + "\\curl"; #elif defined Q_WS_MACX curl_path = "/usr/bin/curl"; #elif defined Q_WS_X11 curl_path = "/usr/bin/curl"; #endif QStringList curl_args; curl_args.append( "-k" ); curl_args.append( "-d" ); curl_args.append( saved_order ); curl_args.append( "-E" ); curl_args.append( pemfile ); _port.setNum(port); doServer = "https://" + _metrics->value("CCServer") + ":" + _port; curl_args.append( doServer ); QString proxy_login; QString proxy_server; if(_metrics->boolean("CCUseProxyServer")) { proxy_login = _metricsenc->value("CCProxyLogin") + ":" + _metricsenc->value("CCPassword") ; proxy_server = _metrics->value("CCProxyServer") + ":" + _metrics->value("CCProxyPort"); curl_args.append( "-x" ); curl_args.append( proxy_server ); curl_args.append( "-U" ); curl_args.append( proxy_login ); } _response = ""; connect( proc, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout()) ); QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) ); _editPreauth->setEnabled(FALSE); proc->start(curl_path, curl_args); if ( !proc->waitForStarted() ) { QMessageBox::critical( 0, tr("Fatal error"), tr("Could not start the %1 command.").arg(curl_path), tr("Quit") ); return; } while (proc->state() == QProcess::Running) qApp->processEvents(); _editPreauth->setEnabled(TRUE); QApplication::restoreOverrideCursor(); _response = "<myroot>" + _response + "</myroot>"; QString whyMe; if (_metrics->boolean("CCTest")) { whyMe = _ccard_number + " " + _response; _metrics->set("CCTestMe", whyMe); _metrics->set("CCOrder", saved_order); } /*if (_metrics->boolean("CCTest")) { QMessageBox::information(this, tr("YourPay"), tr("The return code was ") + _response, QMessageBox::Ok); }*/ QDomDocument doc; doc.setContent(_response); QDomNode node; root = doc.documentElement(); QString _r_avs; QString _r_ordernum; QString _r_error; QString _r_approved; QString _r_code; QString _r_score; QString _r_shipping; QString _r_tax; QString _r_tdate; QString _r_ref; QString _r_message; QString _r_time; node = root.firstChild(); while ( !node.isNull() ) { if ( node.isElement() && node.nodeName() == "r_avs" ) { QDomElement r_avs = node.toElement(); _r_avs = r_avs.text(); } if ( node.isElement() && node.nodeName() == "r_ordernum" ) { QDomElement r_ordernum = node.toElement(); _r_ordernum = r_ordernum.text(); } if ( node.isElement() && node.nodeName() == "r_error" ) { QDomElement r_error = node.toElement(); _r_error = r_error.text(); } if ( node.isElement() && node.nodeName() == "r_approved" ) { QDomElement r_approved = node.toElement(); _r_approved = r_approved.text(); } if ( node.isElement() && node.nodeName() == "r_code" ) { QDomElement r_code = node.toElement(); _r_code = r_code.text(); } if ( node.isElement() && node.nodeName() == "r_message" ) { QDomElement r_message = node.toElement(); _r_message = r_message.text(); } if ( node.isElement() && node.nodeName() == "r_time" ) { QDomElement r_time = node.toElement(); _r_time = r_time.text(); } if ( node.isElement() && node.nodeName() == "r_ref" ) { QDomElement r_ref = node.toElement(); _r_ref = r_ref.text(); } if ( node.isElement() && node.nodeName() == "r_tdate" ) { QDomElement r_tdate = node.toElement(); _r_tdate = r_tdate.text(); } if ( node.isElement() && node.nodeName() == "r_tax" ) { QDomElement r_tax = node.toElement(); _r_tax = r_tax.text(); } if ( node.isElement() && node.nodeName() == "r_shipping" ) { QDomElement r_shipping = node.toElement(); _r_shipping = r_shipping.text(); } if ( node.isElement() && node.nodeName() == "r_score") { QDomElement r_score = node.toElement(); _r_score = r_score.text(); } node = node.nextSibling(); } q.prepare( "UPDATE ccpay" " SET ccpay_amount = :ccpay_amount, " " ccpay_auth = FALSE, " " ccpay_status = :ccpay_status, " " ccpay_curr_id = :ccpay_curr_id " " WHERE ccpay_id = :ccpay_id;" ); q.bindValue(":ccpay_id", _preauth->id()); q.bindValue(":ccpay_amount",_CCAmount->baseValue()); // ##### localValue()? q.bindValue(":ccpay_curr_id",_CCAmount->baseId()); // ##### id()? doDollars = 0; if (_r_approved == "APPROVED") { QMessageBox::information(this, tr("YourPay"), tr("This transaction was approved\n") + _r_ref, QMessageBox::Ok); q.bindValue(":ccpay_status","C"); doDollars = _CCAmount->baseValue(); // ##### localValue()? } if (_r_approved == "DENIED") { QMessageBox::information(this, tr("YourPay"), tr("This transaction was denied\n") + _r_message, QMessageBox::Ok); q.bindValue(":ccpay_status","D"); } if (_r_approved == "DUPLICATE") { QMessageBox::information(this, tr("YourPay"), tr("This transaction is a duplicate\n") + _r_message, QMessageBox::Ok); q.bindValue(":ccpay_status","D"); } if (_r_approved == "DECLINED") { QMessageBox::information(this, tr("YourPay"), tr("This transaction is a declined\n") + _r_error, QMessageBox::Ok); q.bindValue(":ccpay_status","D"); } if (_r_approved == "FRAUD") { QMessageBox::information(this, tr("YourPay"), tr("This transaction is denied because of possible fraud\n") + _r_error, QMessageBox::Ok); q.bindValue(":ccpay_status","D"); } if (_r_approved.length() == 0 || _r_approved.isNull() || _r_approved.isEmpty()) { QMessageBox::information(this, tr("YourPay"), tr("<p>No Approval Code<br>%1<br>%2<br>%3") .arg(_r_error).arg(_r_message).arg(_response), QMessageBox::Ok); q.bindValue(":ccpay_status","X"); } q.exec(); //We need to a charge here to do a cash receipt // We need some logic for a successful charge and for a non-successful charge if (doDollars > 0) { // This is a sucessful charge q.prepare("INSERT INTO cashrcpt (cashrcpt_id," " cashrcpt_cust_id," " cashrcpt_amount," " cashrcpt_curr_id," " cashrcpt_fundstype, " " cashrcpt_docnumber," " cashrcpt_bankaccnt_id," " cashrcpt_notes," " cashrcpt_distdate) " "VALUES (nextval('cashrcpt_cashrcpt_id_seq'), :cashrcpt_cust_id," " :cashrcpt_amount, :cashrcpt_curr_id, :cashrcpt_fundstype," " :cashrcpt_docnumber, :cashrcpt_bankaccnt_id," " :cashrcpt_notes, current_date);"); q.bindValue(":cashrcpt_cust_id",_cust->id()); q.bindValue(":cashrcpt_amount",doDollars); q.bindValue(":cashrcpt_curr_id", _CCAmount->baseId()); // ##### id()? q.bindValue(":cashrcpt_fundstype",_ccard_type); q.bindValue(":cashrcpt_docnumber",_backrefnum); q.bindValue(":cashrcpt_bankaccnt_id",_metrics->value("CCDefaultBank").toInt()); q.bindValue(":cashrcpt_notes","Converted Pre-auth"); q.exec(); } //Clean up sFillCashrcptList(); sFillAropenCMList(); sFillAropenList(); sFillPreauthList(); _CCAmount->clear(); }