public bool Capture(SAPbouiCOM.Form form) { try { string strRef = ""; string amount = ""; if (!GetRefNoAndAmountFromRemark(form, ref strRef, ref amount)) { SBO_Application.MessageBox("Refrence number not found.", 1, "Ok", "", ""); return(false); } ueSecurityToken token = getToken(); TransactionRequestObject req = createRequest(form); req.RefNum = strRef; req.Command = "cc:capture"; string refNum = ""; if (runRequest(form, req, ref refNum)) { string remark = GetRemark(form); remark += string.Format(strHeaderCaptured + "ref. No.:{0} **\r\n", refNum, DateTime.Now.ToString("MM-dd-yyy hh:mm")); SetRemark(form, remark); SBO_Application.MessageBox("Transaction Captured. Reference Number:" + refNum, 1, "Ok", "", ""); //AddPayment(form, double.Parse(amount)); } } catch (Exception ex) { errorLog(ex); } return(true); }
private bool runRequest(SAPbouiCOM.Form form, TransactionRequestObject req, ref string refNum) { try { // form.Freeze(true); ueSecurityToken token = getToken(); TransactionResponse resp = new TransactionResponse(); resp = ebiz.runTransaction(token, req); //form.Freeze(false); if (resp.ErrorCode == "0") { AddCustomer(req); refNum = resp.RefNum; logTransaction(req, resp); return(true); } else { errorLog(resp.Error); SBO_Application.MessageBox("Can not process your transaction.\r\n" + resp.Error, 1, "Ok", "", ""); return(false); } }catch (Exception ex) { errorLog(ex); } return(false); }
private ueSecurityToken getToken() { ueSecurityToken token = new ueSecurityToken(); try { token.ClientIP = getIP(); token.SourceKey = sourceKey; token.PinHash = new ueHash(); token.PinHash.Seed = DateTime.Now.ToString("yyyyMMddhhmmssssss"); string prehashvalue = string.Concat(token.SourceKey, token.PinHash.Seed, pin); // combine data into single string token.PinHash.Type = "md5"; token.PinHash.HashValue = GenerateHash(prehashvalue); }catch (Exception ex) { errorLog(ex); } return(token); }
public bool Charge(SAPbouiCOM.Form form) { try { string strAmt = ""; string cardNo = ""; string exp = ""; string code = ""; if (!VerifyInput(form, ref strAmt, ref cardNo, ref exp, ref code)) { return(false); } ueSecurityToken token = getToken(); TransactionRequestObject req = createRequest(form); req.Details.Amount = double.Parse(strAmt); req.CreditCardData.CardCode = code; req.CreditCardData.CardNumber = cardNo; req.CreditCardData.CardExpiration = exp; req.Command = "cc:sale"; string refNum = ""; if (runRequest(form, req, ref refNum)) { string remark = GetRemark(form); remark += string.Format(strHeaderCharged + "ref. No.:{0} Amount:{1} {2}**\r\n", refNum, strAmt, DateTime.Now.ToString("MM-dd-yyy hh:mm")); SetRemark(form, remark); SBO_Application.MessageBox("Charge Completed. Reference Number:" + refNum + ", Amount:" + strAmt, 1, "Ok", "", ""); ClearInput(form); AddPayment(form, req.Details.Amount); } } catch (Exception ex) { errorLog(ex); } return(true); }
private void CustImpFormHandler(SAPbouiCOM.Form form, SAPbouiCOM.ItemEvent pVal) { try { if (pVal.BeforeAction) { } else { switch (pVal.EventType) { case SAPbouiCOM.BoEventTypes.et_CLICK: break; case SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED: { switch (pVal.ItemUID) { case btnClose: oCustImpForm.Close(); break; case btnImp: try { if (custObjForImport == null) { form.Items.Item(btnFind).Click(); } else { string cardcode = getComboBoxVal(form, cbCustomerID); if (cardcode == "") { showMessage("Please select a customer."); } else { if (custObjForImport == null) { form.Items.Item(btnFind).Click(); } else { if (SBO_Application.MessageBox("Import payment method(s) to " + cardcode + "?", 1, "Yes", "No") == 1) { int i = 0; foreach (PaymentMethod pm in custObjForImport.PaymentMethods) { if (!isPaymentMethodExists(cardcode, pm.CardNumber, pm.CardExpiration)) { CCCUST cccust = new CCCUST(); cccust.CustomerID = cardcode; cccust.active = 'Y'; cccust.email = custObjForImport.BillingAddress.Email; cccust.firstName = custObjForImport.BillingAddress.FirstName; cccust.lastName = custObjForImport.BillingAddress.LastName; cccust.street = custObjForImport.BillingAddress.Street; cccust.city = custObjForImport.BillingAddress.City; cccust.state = custObjForImport.BillingAddress.State; cccust.zip = custObjForImport.BillingAddress.Zip; cccust.expDate = pm.CardExpiration; cccust.cardCode = pm.CardCode; cccust.routingNumber = pm.Routing; cccust.checkingAccount = pm.Account; cccust.GroupName = getGroupName(cardcode); cccust.CustNum = custObjForImport.CustNum; cccust.MethodID = pm.MethodID; try { if (pm.MethodName != null && pm.MethodName != "") { if (pm.MethodName.IndexOf(" ") > 0) { string name = pm.MethodName; string[] s = name.Split(' '); cccust.firstName = s[0]; cccust.lastName = s[s.Length - 1]; } } } catch (Exception) { } int id = getNextTableID("@CCCUST"); string desc = cccust.firstName + " " + cccust.lastName; if (pm.MethodName != null && pm.MethodName != "") { desc = pm.MethodName; } if (pm.MethodType == "check") { cccust.methodDescription = id.ToString() + "_" + pm.Routing + " " + pm.Account + "(" + desc + ")"; cccust.checkingAccount = pm.Account; cccust.routingNumber = pm.Routing; } else { cccust.cardNum = pm.CardNumber; cccust.methodDescription = id.ToString() + "_" + pm.CardNumber + " " + pm.CardExpiration + "(" + desc + ")"; cccust.checkingAccount = pm.Account; cccust.cardType = pm.CardType; } string cardid = ""; cccust.CardName = getCardName(cccust.GroupName, cccust.cardType, "", ref cardid); cccust.CCAccountID = cardid; cccust.methodName = pm.MethodName; insert(cccust); SBO_Application.SetStatusBarMessage(string.Format("Import payment method {0} to {1}.", cccust.cardNum, cardcode), SAPbouiCOM.BoMessageTime.bmt_Medium, false); } i++; } } } } } }catch (Exception ex) { SBO_Application.SetStatusBarMessage(string.Format("Import payment method error: {0}.", ex.Message), SAPbouiCOM.BoMessageTime.bmt_Medium, true); } break; case btnFind: try { string custNum = getFormEditVal(form, editCustNum); if (custNum == "") { showMessage("Please enter customer number."); } else { SBO_Application.SetStatusBarMessage("Finding customer please wait...", SAPbouiCOM.BoMessageTime.bmt_Medium, false); ueSecurityToken token = getToken(""); custObjForImport = ebiz.getCustomer(token, custNum); SAPbouiCOM.ComboBox oCB = (SAPbouiCOM.ComboBox)form.Items.Item(cbPaymentMethod).Specific; try { while (oCB.ValidValues.Count > 0) { oCB.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index); } } catch (Exception) { } ComboAddItem(oCB, ""); foreach (PaymentMethod pm in custObjForImport.PaymentMethods) { string s = ""; string name = ""; name = custObjForImport.BillingAddress.FirstName + " " + custObjForImport.BillingAddress.LastName; if (pm.MethodName != null && pm.MethodName != "") { if (pm.MethodName.IndexOf(" ") > 0) { name = pm.MethodName; } } if (pm.MethodType == "check") { s = pm.Routing + " " + pm.Account + "(" + name + ")"; } else { s = pm.CardNumber + " " + pm.CardExpiration + "(" + name + ")"; } ComboAddItem(oCB, s); } oCB.Select(""); SBO_Application.SetStatusBarMessage(string.Format("{0} payment method(s) ready to import.", oCB.ValidValues.Count - 1), SAPbouiCOM.BoMessageTime.bmt_Medium, false); // form.Items.Item(btnImp).Click(); } }catch (Exception ex) { custObjForImport = null; SAPbouiCOM.ComboBox oCB = (SAPbouiCOM.ComboBox)form.Items.Item(cbPaymentMethod).Specific; try { while (oCB.ValidValues.Count > 0) { oCB.ValidValues.Remove(0, SAPbouiCOM.BoSearchKey.psk_Index); } } catch (Exception) { } ComboAddItem(oCB, ""); oCB.Select(""); SBO_Application.SetStatusBarMessage(string.Format("Find customer error: {0}.", ex.Message), SAPbouiCOM.BoMessageTime.bmt_Medium, true); errorLog(ex); } break; } } break; } } } catch (Exception ex) { errorLog(ex); } }