Exemple #1
0
        private TransactionRequestObject GenerateTransactionRequest(string command, string strTransactionID)
        {
            TransactionRequestObject tro = new TransactionRequestObject();

            tro.CreditCardData = new CreditCardData();
            tro.AccountHolder  = Customer.FirstName + " " + Customer.LastName;

            Address address = new Address();

            address.FirstName = Customer.FirstName;
            address.LastName  = Customer.LastName;
            address.Address1  = Customer.Address;
            address.City      = Customer.City;
            address.State     = Customer.State;
            address.ZipCode   = Customer.Zip;
            address.Country   = Customer.Country;
            //address.Email = Customer.Email;
            //address.Phone = Customer.Phone;
            //tro.BillingAddress = address;
            tro.CreditCardData.CardNumber     = Card.Number;
            tro.CreditCardData.CardExpiration = Card.ExpMonth + Card.ExpYear;
            tro.CreditCardData.CardCode       = Card.CVVData;

            tro.Details    = GenerateTransactionwithDetail(InvoiceNumber, ExtInvoiceNumber);
            tro.CustomerID = GenerateNumberIfEmpty(Customer.Id);
            tro.LineItems  = GenerateLineItems(tro.Details.Amount);
            tro.Command    = command;  //ryan
            tro.RefNum     = strTransactionID;
            LastRequest    = tro;
            return(tro);
        }
Exemple #2
0
        public override void VoidTransaction(string strTransactionID)
        {
            //Reset();
            //TransactionId = strTransactionID;
            // m_approved = Service.runTransactionion(GenerateToken(), strTransactionID);

            TransactionRequestObject transactionRequestObject = GenerateTransactionRequest();

            transactionRequestObject.Command = "Void";
            transactionRequestObject.RefNum  = strTransactionID;

            //m_approved = Service.runTransaction(GenerateToken(), transactionRequestObject);
            TransactionResponse response = Client.runTransaction(GenerateToken(), transactionRequestObject);

            if (response.ResultCode == "A")
            {
                //MessageBox.Show(string.Concat("Transaction Approved, RefNum: ",
                //        response.RefNum));
                m_approved = true;
            }
            else
            {
                //    MessageBox.Show(string.Concat("Transaction Failed: ",
                //            response.Error));
                m_approved = false;
            }
        }
 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);
    }
Exemple #5
0
    private TransactionRequestObject Batch_createRequest(SAPbobsCOM.Documents doc)
    {
        TransactionRequestObject req = new TransactionRequestObject();

        try
        {
            req.BillingAddress = new GwAddress();
            req.ClientIP       = getIP();
            req.CustReceipt    = false;
            //true;
            req.Details                  = new TransactionDetail();
            req.Details.Clerk            = oCompany.UserName;
            req.Details.AllowPartialAuth = true;

            req.Details.Amount = Math.Round(doc.DocTotal, 2);

            req.Details.Discount = Math.Round(doc.TotalDiscount, 2);

            req.Details.Shipping = getShipping(doc);

            req.Details.Tax = doc.VatSum;

            req.Details.Invoice = doc.DocNum.ToString();
            req.Details.OrderID = GetSalesOrderDocNum(req.Details.Invoice);
            req.Details.PONum   = doc.NumAtCard;
            if (req.Details.PONum == "" || req.Details.PONum == null)
            {
                req.Details.PONum = doc.DocNum.ToString();
            }
            req.Details.ShipFromZip = getZipFromAddr(doc.Address2);
            req.Details.Description = doc.Comments;
            req.Details.Subtotal    = 0; // req.Details.Subtotal = Math.Round(req.Details.Amount - (req.Details.Shipping + req.Details.Tax - req.Details.Discount), 2);

            SAPbobsCOM.Document_Lines olines = doc.Lines;
            req.LineItems = new LineItem[olines.Count];

            for (int i = 0; i < olines.Count; i++)
            {
                olines.SetCurrentLine(i);
                req.LineItems[i] = new LineItem();
                req.LineItems[i].CommodityCode = merchantData.ItemCommodityCode == null ? olines.ItemCode : merchantData.ItemCommodityCode;
                req.LineItems[i].Qty           = olines.Quantity.ToString();
                req.LineItems[i].UnitPrice     = olines.Price.ToString();
                req.LineItems[i].ProductName   = olines.ItemDescription;
                req.LineItems[i].UnitOfMeasure = "EACH";
                req.LineItems[i].SKU           = olines.ItemCode;
                req.LineItems[i].CommodityCode = olines.ItemCode;
                req.LineItems[i].Taxable       = true;
                // req.LineItems[i].TaxableSpecified = true;
                req.LineItems[i].TaxRate = olines.TaxPercentagePerRow.ToString();
            }
        }
        catch (Exception ex)
        {
            errorLog(ex);
        }
        return(req);
    }
Exemple #6
0
        public override void ReAuthTransaction(string strTransactionID, double amount)
        {
            Reset();
            // ParseResponse(Service.captureTransaction(GenerateToken(), strTransactionID, amount));
            TransactionDetail transactiondetailObject = GenerateTransactionDetail();

            transactiondetailObject.Amount = amount;
            TransactionRequestObject transactionRequestObject = GenerateTransactionRequest();

            transactionRequestObject.Command = "Capture";
            transactionRequestObject.RefNum  = strTransactionID;
            transactionRequestObject.Details = transactiondetailObject;
            ParseResponse(Client.runTransaction(GenerateToken(), transactionRequestObject));
        }
Exemple #7
0
        public override void Capture(string strTransactionID, string strTransactionAmount)
        {
            string strOriginalAmount = TransactionOriginalAmount;

            m_objLog.LogMessage("eBizChargeGateway: Capture: transaction ID: " + strTransactionID + ", original amount: " + strOriginalAmount + ", amount: " + strTransactionAmount + ", remaining transactions: " + m_remainingTransactions.ToString(), 40);

            Reset();

            TransactionId     = strTransactionID;
            TransactionAmount = strTransactionAmount;

            double amount;

            double.TryParse(strTransactionAmount, out amount);
            double originalAmount;

            double.TryParse(strOriginalAmount, out originalAmount);
            if (m_remainingTransactions == 0)
            {
                if (amount > originalAmount)
                {
                    // need new authorization
                    m_objLog.LogMessage("eBizChargeGateway: Capture: Need new authorization: invoiced amount is greater than authorized amount: " + strTransactionAmount + " > " + strOriginalAmount + ", remaining transactions: " + m_remainingTransactions.ToString(), 40);
                    TransactionResponse newAuthResponse = Client.runTransaction(GenerateToken(), GenerateTransactionRequest("AuthOnly"));
                    if ("A" == newAuthResponse.ResultCode)
                    {
                        // reverse old authorization
                        Client.runTransaction(GenerateToken(), GenerateTransactionRequest("Void", strTransactionID));
                        m_objLog.LogMessage("eBizChargeGateway: Capture: new authroization succeeded. Auth amount: " + newAuthResponse.AuthAmount.ToString(), 40);
                        strTransactionID = newAuthResponse.RefNum;
                        TransactionId    = strTransactionID;
                    }
                }
            }

            TransactionRequestObject transactionRequestObject = GenerateTransactionRequest();

            transactionRequestObject.Command = "capture";

            transactionRequestObject.RefNum         = strTransactionID;
            transactionRequestObject.IfAuthExpired  = "PostAuth";
            transactionRequestObject.Details.Amount = amount;
            //transactionRequestObject.Details.AmountSpecified = true; // Ryan

            ParseResponse(Client.runTransaction(GenerateToken(), transactionRequestObject));

            m_EmailTransactionID = strTransactionID;
        }
Exemple #8
0
        public override void Refund(string strTransactionID, string strTransactionAmount)
        {
            Reset();
            m_objLog.LogMessage("eBizChargeGateway: Refund: start ", 40);

            TransactionAmount = strTransactionAmount;
            double amount;

            double.TryParse(strTransactionAmount, out amount);

            TransactionRequestObject transactionRequestObject = GenerateTransactionRequest();

            transactionRequestObject.Command = "Credit";

            transactionRequestObject.RefNum         = strTransactionID;
            transactionRequestObject.IfAuthExpired  = "PostAuth";
            transactionRequestObject.Details.Amount = amount;

            ParseResponse(Client.runTransaction(GenerateToken(), transactionRequestObject));
            m_objLog.LogMessage("eBizChargeGateway: Refund: end ", 40);
        }
 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);
 }
Exemple #10
0
        public async Task <IActionResult> Index()
        {
            //Live
            var           client        = new PaymentGateway.IeBizServiceClient();
            SecurityToken securityToken = new SecurityToken();

            //CreditCardData customer = new CreditCardData();
            //securityToken.UserId = "virtualterm";
            //securityToken.SecurityId = "8U5NF2nZQAm3G3Gw57oB8g7BObK7bzKP";
            //securityToken.Password = "******";
            securityToken.SecurityId = "99359f03-b254-4adf-b446-24957fcb46cb";
            securityToken.UserId     = "qbouser";
            securityToken.Password   = "******";
            SearchFilter[] searchFilters = new SearchFilter[0];

            dynamic dsd = await client.SearchInvoicesAsync(securityToken, "", "", "", "", searchFilters, 0, 200, "", false);

            PaymentMethodProfile payMethod = new PaymentMethodProfile();

            payMethod.CardExpiration = "0922";
            payMethod.CardNumber     = "4000100011112224";
            payMethod.AvsStreet      = "123 Main st.";
            payMethod.AvsZip         = "90046";
            payMethod.MethodName     = "My Visa";
            TransactionRequestObject transaction = new TransactionRequestObject();

            transaction.CreditCardData.CardNumber     = "4000100011112224";
            transaction.CreditCardData.CardExpiration = "0922";
            transaction.CreditCardData.AvsStreet      = "123 Main st.";
            transaction.CreditCardData.AvsZip         = "90046";
            transaction.CustomerID     = "";
            transaction.BillingAddress = new GwAddress {
                FirstName = "naqi", LastName = "ali"
            };
            transaction.Command         = "AuthOnly";
            transaction.CustReceipt     = true;
            transaction.CustReceiptName = "";
            transaction.AuthCode        = "";
            var dd = await client.runTransactionAsync(securityToken, transaction);

            CustomerTransactionRequest customerTransaction = new CustomerTransactionRequest();
            var ss = await client.runCustomerTransactionAsync(securityToken, "C-ABC530", "1186", customerTransaction);

            //PaymentMethodProfile payMethod = new PaymentMethodProfile();
            //payMethod.CardExpiration = "1212";
            //payMethod.CardNumber = "4000100011112224";
            //payMethod.AvsStreet = "123 Main st.";
            //payMethod.AvsZip = "90046";
            //payMethod.MethodName = "My Visa";
            // dynamic data = await client.GetCustomerAsync(securityToken, "C-ABC527", "7c944faf-a409-460d-a55d-1a2220c455cd");
            //if (data!=null)
            //{

            //}
            //else
            //{
            //Customer customer = new Customer();
            //    customer.CompanyName = "Naqi101";
            //    customer.FirstName = "Naqi";
            //    customer.LastName = "Ali";
            //    customer.Email = "*****@*****.**";
            //    customer.SoftwareId = ".Net API";
            //    customer.CustomerId = "C-ABC530";
            //    Address address = new Address();
            //    address.FirstName = "Naqi";
            //    address.LastName = "Testing";
            //    address.CompanyName = "Naqi101";
            //    address.Address1 = "123 main st.";
            //    address.City = "Hollywood";
            //    address.State = "ca";
            //    address.ZipCode = "91607";
            //    address.Country = "USA";
            //    customer.BillingAddress = address;
            //    PaymentMethodProfile[] payMethod = new PaymentMethodProfile[1];
            //    payMethod[0] = new PaymentMethodProfile();
            //    //payMethod[0].MethodType = "1212";
            //    payMethod[0].CardNumber = "4000100011112224";
            //    payMethod[0].CardExpiration = "0922";
            //    payMethod[0].AccountHolderName = "Ali";
            //    payMethod[0].AvsStreet = "abc";
            //    payMethod[0].CardCode = "123";
            //    payMethod[0].AvsZip = "54000";
            //    payMethod[0].MethodName = "My Visa";
            //    customer.PaymentMethodProfiles = payMethod;
            //}

            try
            {
                var sdt = await client.AddCustomerPaymentMethodProfileAsync(securityToken, "4b9fab71-9b3c-4d77-bff3-fc6c4cf54ec0", payMethod);

                //dynamic response = await client.AddCustomerAsync(securityToken, customer);
                //dynamic response = await client.UpdateCustomerAsync(securityToken, customer, "C-ABC527", "7c944faf-a409-460d-a55d-1a2220c455cd");
                //MessageBox.Show(string.Concat(response));
            }

            catch (Exception err)
            {
                //MessageBox.Show(err.Message);
            }
            return(View());
        }
    private TransactionRequestObject createRequest(SAPbouiCOM.Form form)
    {
        SAPbouiCOM.EditText      customer = form.Items.Item(fidCustID).Specific;
        TransactionRequestObject req      = new TransactionRequestObject();

        try
        {
            req.RecurringBilling = new RecurringBilling();

            req.AccountHolder         = "";
            req.AuthCode              = "";
            req.ClientIP              = getIP();
            req.CustomerID            = customer.Value;
            req.CheckData             = new CheckData();
            req.CheckData.Account     = "";
            req.CheckData.AccountType = "";
            req.Details                   = new TransactionDetail();
            req.Details.Amount            = getItemDoubleValue(form, fidBalance);
            req.Details.AmountSpecified   = true;
            req.Details.Discount          = getItemDoubleValue(form, fidDiscount);
            req.Details.DiscountSpecified = true;
            req.Details.Shipping          = getItemDoubleValue(form, fidFreight);
            req.Details.ShippingSpecified = true;
            req.Details.Tax               = getItemDoubleValue(form, fidTax);
            req.Details.TaxSpecified      = true;
            req.Details.Invoice           = getItemValue(form, fidRecordID);
            req.Details.OrderID           = getItemValue(form, fidRecordID);
            req.Details.PONum             = getItemValue(form, fidRecordID);
            req.Details.Description       = getItemValue(form, fidDesc);
            req.Details.Subtotal          = getItemDoubleValue(form, fidSubTotal);
            req.Details.SubtotalSpecified = true;
            req.BillingAddress            = new Address();
            req.BillingAddress.Company    = "";
            req.BillingAddress.FirstName  = theSAPCustomer.BillingAddress.FirstName;
            req.BillingAddress.LastName   = theSAPCustomer.BillingAddress.LastName;
            req.BillingAddress.Street     = theSAPCustomer.BillingAddress.Street;
            req.BillingAddress.City       = theSAPCustomer.BillingAddress.City;
            req.BillingAddress.State      = theSAPCustomer.BillingAddress.State;
            req.BillingAddress.Zip        = theSAPCustomer.BillingAddress.Zip;
            req.CreditCardData            = new CreditCardData();
            req.ShippingAddress           = new Address();
            req.ShippingAddress.Company   = "";
            req.ShippingAddress.FirstName = theSAPCustomer.BillingAddress.FirstName;
            req.ShippingAddress.LastName  = theSAPCustomer.BillingAddress.LastName;
            req.ShippingAddress.Street    = theSAPCustomer.BillingAddress.Street;
            req.ShippingAddress.City      = theSAPCustomer.BillingAddress.City;
            req.ShippingAddress.State     = theSAPCustomer.BillingAddress.State;
            req.ShippingAddress.Zip       = theSAPCustomer.BillingAddress.Zip;
            SAPbouiCOM.Matrix oMatrix = form.Items.Item(fidMatrix).Specific;
            if (oMatrix.RowCount >= 2)
            {
                req.LineItems = new LineItem[oMatrix.RowCount];
                for (int i = 1; i < oMatrix.RowCount; i++)
                {
                    //string msg = "row=" + i.ToString() + "\r\n";
                    req.LineItems[i - 1] = new LineItem();
                    req.LineItems[i - 1].CommodityCode = getMatrixItem(oMatrix, GetConfig("SAPFIDColDiscountRate"), i);
                    req.LineItems[i - 1].Qty           = getMatrixItem(oMatrix, GetConfig("SAPFIDColQty"), i);
                    req.LineItems[i - 1].UnitPrice     = getMatrixItem(oMatrix, GetConfig("SAPFIDColUnitPrice"), i);
                    req.LineItems[i - 1].TaxRate       = getMatrixItem(oMatrix, GetConfig("SAPFIDColTaxRate"), i);
                    req.LineItems[i - 1].ProductName   = getMatrixItem(oMatrix, GetConfig("SAPFIDColProductName"), i);
                    req.LineItems[i - 1].DiscountRate  = getMatrixItem(oMatrix, GetConfig("SAPFIDColDiscountRate"), i);
                    req.LineItems[i - 1].UnitOfMeasure = "EACH";
                    req.LineItems[i - 1].ProductRefNum = getMatrixItem(oMatrix, GetConfig("SAPFIDColProductRefNum"), i);
                    req.LineItems[i - 1].SKU           = getMatrixItem(oMatrix, GetConfig("SAPFIDColProductRefNum"), i);

                    /*
                     * for(int n=0; n < oMatrix.Columns.Count; n++)
                     * {
                     *  string v = getMatrixItem(oMatrix, n.ToString(), i);
                     *  msg = msg + n.ToString() + ":" + v + "\r\n";
                     * }
                     * errorLog(msg);
                     */
                }
            }
        }catch (Exception ex)
        {
            errorLog(ex);
        }
        return(req);
    }
    private void logTransaction(TransactionRequestObject req, TransactionResponse resp)
    {
        string sql = "";

        try
        {
            string cardLastFour = "";
            try
            {
                if (req.CreditCardData.CardNumber == null)
                {
                    cardLastFour = "";
                }
                else
                {
                    cardLastFour = req.CreditCardData.CardNumber.Substring(req.CreditCardData.CardNumber.Length - 4);
                }
            }catch (Exception)
            {}

            db.CommandTimeout = 30000;
            CCTRAN cctran = new CCTRAN();
            cctran.customerID              = req.CustomerID;
            cctran.customerName            = req.BillingAddress.Company;
            cctran.crCardNum               = cardLastFour;
            cctran.Description             = req.Details.Description;
            cctran.recID                   = req.Details.Invoice;
            cctran.acsUrl                  = resp.AcsUrl;
            cctran.authAmount              = resp.AuthAmount.ToString();
            cctran.authCode                = resp.AuthCode;
            cctran.avsResult               = resp.AvsResult;
            cctran.avsResultCode           = resp.AvsResultCode;
            cctran.batchNum                = resp.BatchNum;
            cctran.batchRef                = resp.BatchRefNum;
            cctran.cardCodeResult          = resp.CardCodeResult;
            cctran.cardCodeResultCode      = resp.CardCodeResultCode;
            cctran.cardLevelResult         = resp.CardLevelResult;
            cctran.cardLevelResultCode     = resp.CardLevelResultCode;
            cctran.conversionRate          = resp.ConversionRate.ToString();
            cctran.convertedAmount         = resp.ConvertedAmount.ToString();
            cctran.convertedAmountCurrency = resp.ConvertedAmountCurrency.ToString();
            cctran.custNum                 = resp.CustNum;
            cctran.error                   = resp.Error;
            cctran.errorCode               = resp.ErrorCode;
            cctran.isDuplicate             = resp.isDuplicate.ToString();
            cctran.payload                 = resp.Payload;
            cctran.profilerScore           = resp.ProfilerScore;
            cctran.profilerResponse        = resp.ProfilerResponse;
            cctran.profilerReason          = resp.ProfilerReason;
            cctran.refNum                  = resp.RefNum;
            cctran.remainingBalance        = resp.RemainingBalance.ToString();
            cctran.result                  = resp.Result;
            cctran.resultCode              = resp.ResultCode;
            cctran.status                  = resp.Status;
            cctran.statusCode              = resp.StatusCode;
            cctran.vpasResultCode          = resp.VpasResultCode;
            cctran.recDate                 = DateTime.Now;//Use local time not server time
            cctran.command                 = req.Command;
            cctran.amount                  = req.Details.Amount.ToString();
            db.CCTRANs.InsertOnSubmit(cctran);
            db.SubmitChanges();
        }catch (Exception ex)
        {
            errorLog(ex);
            errorLog(sql);
        }
    }