private void HandleCCLogSelect(SAPbouiCOM.Form form) { try { string CustomerID = getCustomerID(form); SAPbouiCOM.Matrix oMatrix = (SAPbouiCOM.Matrix)form.Items.Item(mxtCCLog).Specific; for (int i = 1; i <= oMatrix.RowCount; i++) { if (oMatrix.IsRowSelected(i)) { string id = getMatrixItem(oMatrix, "ccTRANSID", i); string cmd = getMatrixItem(oMatrix, "command", i); string refnum = getMatrixItem(oMatrix, "RefNum", i); string SOID = getMatrixItem(oMatrix, "OrderID", i); string custNum = getMatrixItem(oMatrix, "custNum", i); if (cmd == "cc:authonly" && form.TypeEx == FORMSALESORDER) { bAuto = false; if (SBO_Application.MessageBox("Void preauth transaction " + refnum + "?", 1, "Yes", "No") == 1) { if (voidTransaction(refnum)) { voidUpdateTrans(id); populateLog(form); } } } if (cmd == "cc:authonly" || cmd == "cc:sale" || cmd == "check") { bAuto = false; SAPCust sapcust = getCustomerByID(CustomerID, refnum); string email = getFormItemVal(form, editEmail); if (email == "") { email = getCustEmail(CustomerID); } if (email != "" && email != null) { if (SBO_Application.MessageBox("Send email receipt to " + email + "?", 1, "Yes", "No") == 1) { try { SecurityToken token = getToken(sapcust.cccust.CCAccountID); EmailReceiptResponse resp = ebiz.EmailReceipt(token, refnum, refnum, "vterm_customer", email); if (resp.ErrorCode == 0) { SBO_Application.MessageBox("Receipt sent."); } else { SBO_Application.MessageBox("Failed to send receipt.\r\n" + resp.Error); } } catch (Exception ex2) { SBO_Application.MessageBox("Failed to send receipt.\r\n" + ex2.Message); } } } } } } }catch (Exception ex) { errorLog(ex); } }
public bool job_runCustomerTrans(SAPCust sapcust, SAPbobsCOM.Documents oDoc, CCJOB job, string amt ="") { try { string cmd = "cc:sale"; if (sapcust.custObj.PaymentMethodProfiles[0].MethodType == "check") cmd = "check"; confirmNum = ""; CustomerTransactionRequest req = job_createCustomRequest(job, oDoc, amt); req.Command = cmd; trace("Job_runCustomRequest: amount = " + req.Details.Amount + ", tax=" + req.Details.Tax + ",Subtotal=" + req.Details.Subtotal + ",shipping=" + req.Details.Shipping + ",Discount=" + req.Details.Discount + string.Format("runCustomerTrans, token={0}, method={1}:{2}", sapcust.custObj.CustomerToken, sapcust.custObj.PaymentMethodProfiles[0].MethodID, sapcust.custObj.PaymentMethodProfiles[0].CardNumber)); req.CustReceipt = cfgsendCustomerEmail == "Y" ? true : false; req.CustReceiptName = "vterm_customer"; req.CustReceiptEmail = sapcust.custObj.Email; if (req.Command == "cc:authonly" && cfgPreAuthEmail != "Y") req.CustReceipt = false; if (req.CustReceiptEmail == "") req.CustReceipt = false; SecurityToken token = getToken(sapcust.cccust.CCAccountID); TransactionResponse resp = new TransactionResponse(); resp = ebiz.runCustomerTransaction(token, sapcust.custObj.CustomerToken, sapcust.custObj.PaymentMethodProfiles[0].MethodID, req); confirmNum = resp.RefNum; sendReceipt(token, sapcust, resp); int invoiceID = 0; if (oDoc != null) invoiceID = oDoc.DocEntry; job_logCustomTransaction(req, resp, sapcust, job, invoiceID.ToString()); if (resp.Error.ToLower() == "approved") { job.Result = "Success"; job.LastRunDate = DateTime.Today; update(job); return true; } else { if (resp.ResultCode == "D") { if (req.CustReceiptEmail != "" && req.CustReceiptEmail != null && cfgCustomerReceipt != "") { try { EmailReceiptResponse emresp = ebiz.EmailReceipt(token, resp.RefNum, resp.RefNum, cfgCustomerReceipt, req.CustReceiptEmail); if (emresp.ErrorCode == 0) { showStatus("Declined receipt sent.", SAPbouiCOM.BoMessageTime.bmt_Medium,false); } else showStatus("Failed to send declined receipt.\r\n" + resp.Error, SAPbouiCOM.BoMessageTime.bmt_Medium,true); } catch (Exception ex2) { showStatus("Failed to send receipt.\r\n" + ex2.Message, SAPbouiCOM.BoMessageTime.bmt_Medium, false); } } } string err = "Job Failed. ID:" + job.jobID + "\r\n" + resp.Error; job.Result = err; job.LastRunDate = DateTime.Today; update(job); errorLog(err); return false; } } catch (Exception ex) { string err = "Job Failed. ID:" + job.jobID + "\r\n" + ex.Message; job.Result = err; job.LastRunDate = DateTime.Today; update(job); errorLog(ex); return false; } }