예제 #1
0
        public void SendTest_AuthCap_PPD_Saving_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            string responseString = "1|1|1|This transaction has been approved.||P|2207739411||AuthCap transaction approved testing|15.18|ECHECK|auth_capture||||||||||||||||||||||||||D05070D0B41BC42B614A666B05631712|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckRequest(EcheckType.PPD, (decimal)15.18, "125000024", "123456", BankAccountType.Savings, "Bank of Seattle", "Sue Zhu", "1234");
            string description = "AuthCap transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
        public ProcessPaymentResult Process(ProcessPaymentRequest request)
        {
            var method = _paymentMethodService.GetById(request.Payment.PaymentMethod.Id);
            var settings = AuthorizeNetConfig.Deserialize(method.PaymentProcessorData);

            var authRequest = CreateGatewayRequest(settings, request);
            var gateway = new Gateway(settings.LoginId, settings.TransactionKey, settings.SandboxMode);
            var response = gateway.Send(authRequest, request.Payment.Description);

            var result = new ProcessPaymentResult();

            if (response.Approved)
            {
                result.PaymentStatus = PaymentStatus.Success;
            }
            else
            {
                result.PaymentStatus = PaymentStatus.Failed;
                result.Message = response.ResponseCode + ": " + response.Message;
            }

            result.ThirdPartyTransactionId = response.TransactionID;

            return result;
        }
예제 #3
0
        public void SendTest_AuthCap_Approved_CustomerIP()
        {
            //check login / password
            string sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            string responseString = "1|1|1|This transaction has been approved.|7339F5|Y|2207176015||testing|20.10|CC|auth_capture||||||||||||||||||||||||||7639D026F54F4DF70EA3F7DE5A350929||2|||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new AuthorizationRequest("4111111111111111", "0224", (decimal)20.10, "AuthCap transaction approved testing", true);
            string description = "AuthCap transaction approved testing";
            request.CustId = "CID1234";
            request.CustomerIp = "CIP456789";
            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0);
            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #4
0
        static void Main(string[] args)
        {
            //step 1 - create the request
            var request = new AuthorizationRequest("4111111111111111", "1216", 10.00M, "Test Transaction");

            //These are optional calls to the API
            //request.AddCardCode("321");

            //Customer info - this is used for Fraud Detection
            //request.AddCustomer("id", "first", "last", "address", "state", "zip");

            //order number
            //request.AddInvoice("invoiceNumber");

            //Custom values that will be returned with the response
            //request.AddMerchantValue("merchantValue", "value");

            //Shipping Address
            //request.AddShipping("id", "first", "last", "address", "state", "zip");

            //step 2 - create the gateway, sending in your credentials and setting the Mode to Test (boolean flag)
            //which is true by default
            //this login and key are the shared dev account - you should get your own if you
            //want to do more testing
            var gate = new Gateway("API-LOGIN", "TRANSACTION-KEY",true);

            //step 3 - make some money
            var response = gate.Send(request);

            Console.WriteLine("{0}: {1}",response.ResponseCode, response.Message);
            Console.Read();
        }
예제 #5
0
        //pretend this is injected with IoC
        IGateway OpenGateway() {
            //we used the form builder so we can now just load it up
            //using the form reader
            var login = ConfigurationManager.AppSettings["ApiLogin"];
            var transactionKey = ConfigurationManager.AppSettings["TransactionKey"];

            //this is set to test mode - change as needed.
            var gate = new Gateway(login, transactionKey, true);
            return gate;
        }
예제 #6
0
        public ActionResult CreditCardTest()
        {
            //What sends our transaction request
            Gateway target = new Gateway("7es9Ud9Zj2TH", "93LxQ9m54wUh26Y7", true);
            //Creating an authorization request

            IGatewayRequest request = new AuthorizationRequest("5424000000000015", "0224", (decimal)20.10, "AuthCap transaction approved testing", true);
            string description = "AuthCap transaction approved testing";
            IGatewayResponse response = target.Send(request, description);
            request.Address = "123 Main St. Denver CO 80203";

            return Content("OK");
        }
예제 #7
0
        public ActionResult Make(PaymentInputModel inputModel)
        {
            var job = (Job)Session["Job"];

            // todo wrap - up in service
            var request = new AuthorizationRequest(inputModel.CardNumber.ToString(), inputModel.ExpiryDate, job.Quote.Total, job.Reference);

            var gate = new Gateway(paymentSettings.GetApiLogin(), paymentSettings.GetTransactionKey());

            var response = gate.Send(request);

            if (response.Approved)
            {
                jobService.MakePayment(job, response.Amount, response.TransactionID);
                jobService.SaveJob(job);

                Session["Job"] = job;

                var responseViewModel = new PaymentResponseViewModel
                {
                    ResponseCode = response.ResponseCode,
                    Message = response.Message,
                    TransactionId = response.TransactionID,
                    Amount = response.Amount,
                    Timestamp = job.PaymentMade.Value,
                    JobReference = job.Reference
                };

                Session["PaymentResult"] = responseViewModel;

                return RedirectToUmbracoPage(1185);
            }

            var viewModel = new PaymentViewModel
            {
                Total = job.Quote.Total
            };

            return View("Index", viewModel);
        }
예제 #8
0
        //-------------------------------------------------------------------------------------------
        public IGatewayResponse Bill(WeavverEntityContainer data, Sales_Orders order, Logistics_Addresses primaryAddress, Logistics_Addresses billingAddress)
        {
            string memo = "WEB PURCHASE";
               // Add the credit to the ledger.
               Accounting_LedgerItems item = new Accounting_LedgerItems();
               item.Id = Guid.NewGuid();
               item.OrganizationId = OrganizationId;
               if (order.Orderee.HasValue)
                    item.AccountId = order.Orderee.Value;
               else
                    item.AccountId = order.Id;
               item.LedgerType = LedgerType.Receivable.ToString();
               item.TransactionId = order.Id;
               item.PostAt = DateTime.UtcNow;
               item.Code = CodeType.Payment.ToString();
               item.Memo = "Payment from Card " + Number.Substring(Number.Length - 4);
               item.Amount = Math.Abs(order.Total.Value);

            //               order.BillingContactEmail

               // Submit to Authorize.Net
               var request = new AuthorizationRequest(Number, ExpirationMonth.ToString("D2") + ExpirationYear.ToString("D2"), order.Total.Value, memo, true);
               request.AddCustomer("", order.PrimaryContactNameFirst, order.PrimaryContactNameLast, primaryAddress.Line1, primaryAddress.State, primaryAddress.ZipCode);
               request.AddMerchantValue("OrderId", order.Id.ToString());
               request.AddMerchantValue("CreatedBy", order.CreatedBy.ToString());
               request.AddMerchantValue("LedgerItemId", item.Id.ToString());
               request.AddShipping("", order.BillingContactNameFirst, order.BillingContactNameLast, billingAddress.Line1, billingAddress.State, billingAddress.ZipCode);
               var gate = new Gateway(ConfigurationManager.AppSettings["authorize.net_loginid"], ConfigurationManager.AppSettings["authorize.net_transactionkey"], (ConfigurationManager.AppSettings["authorize.net_testmode"] == "true"));

               var response = gate.Send(request, memo);
               item.ExternalId = response.TransactionID;
               if (!response.Approved)
               {
                    //item.Voided = true;
                    //item.VoidedBy = Guid.Empty;
                    item.Memo += "\r\nPayment failed: Code " + response.ResponseCode + ", " + response.Message;
               }
               data.Accounting_LedgerItems.Add(item);
               return response;
        }
        public ProcessPaymentResult Process(PaymentProcessingContext context)
        {
            var settings = context.ProcessorConfig as AuthorizeNetConfig;

            var authRequest = CreateGatewayRequest(settings, context);
            var gateway = new Gateway(settings.LoginId, settings.TransactionKey, settings.SandboxMode);
            var response = gateway.Send(authRequest, context.Payment.Description);

            var result = new ProcessPaymentResult();

            if (response.Approved)
            {
                result.PaymentStatus = PaymentStatus.Success;
            }
            else
            {
                result.PaymentStatus = PaymentStatus.Failed;
                result.Message = response.ResponseCode + ": " + response.Message;
            }

            result.ThirdPartyTransactionId = response.TransactionID;

            return result;
        }
예제 #10
0
        public void SendTest_Credit_Approved()
        {
            // Test setup.
            const string transId = "????";               // A settled eCheck transaction id
            const decimal creditAmount = (decimal) 1.50; // Amount to request credit for; less than the settled amount minus refund amount.
            const string accountType = "eCheck";         // The account type used in the transaction, such as eCheck
            const string accountLast4Digits = "????";    // The last 4 digitals of the account number used in the transaction, such as 3456

            //check ApiLoginid / TransactionKey
            var sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            var responseString = "1|1|1|This transaction has been approved.||P|2207741772||Credit transaction approved testing|"+creditAmount+"|CC|credit||||||||||||[email protected]||||||||||||||574B2D5282D8A2914AEB7272AECD4B71|||||||||||||XXXX"+accountLast4Digits+"|"+accountType+"||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            var target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckCreditRequest(transId, creditAmount, accountLast4Digits);
            const string description = "Credit transaction approved testing";

            var actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.Greater(long.Parse(actual.TransactionID),  0);
        }
예제 #11
0
        public void SendTest_UnlinkedCredit_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            const string responseString = "4|1|193|The transaction is currently under review.||P|2207750459||UnlinkedCredit transaction approved testing|15.15|ECHECK|||||||||||||||||||||||||||028371CBD0646BDA25EC4206BF2FC7A5|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            var target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckUnlinkedCreditRequest(EcheckType.PPD, (decimal)15.15, "125000024", "123456", BankAccountType.Checking, "Bank of Seattle", "Sue Zhu", "1234");
            request.DuplicateWindow = "0";
            const string description = "UnlinkedCredit transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #12
0
        public void SendTest_Capture_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            string responseString = "1|1|1|This transaction has been approved.||P|2207740902||Capture transaction approved testing|15.12|ECHECK|capture_only||||||||||||||||||||||||||5ABF0956B17EC73A611AACF31C38E6C5|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckCaptureRequest("ASD123", EcheckType.WEB, (decimal)15.12, "125000024", "123456", BankAccountType.Checking, "Bank of Seattle", "Sue Zhu", "1234");
            string description = "Capture transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #13
0
        public void SendTest_PriorAuthCapture_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount = (decimal)15.13;
            string transID = SendAuthOnly(amount + 1);
            Assert.IsTrue(transID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(transID) > 0);

            //start testing
            string responseString = "1|1|1|This transaction has been approved.||P|2207741298||Auth transaction approved testing|15.13|ECHECK|prior_auth_capture|||||||||||||||||||||0.00|0.00|0.00|FALSE||8F5A7C40A02E09A38B2E00AAA0C0E821||||||||||||||Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckPriorAuthCaptureRequest(transID, amount);
            string description = "PriorAuthCapture transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #14
0
        public override VoidProcessPaymentResult VoidProcessPayment(VoidProcessPaymentEvaluationContext context)
        {
            var retVal = new VoidProcessPaymentResult();

            if (context.Payment.PaymentStatus == PaymentStatus.Cancelled)
            {
                var request = new VoidRequest(context.Payment.OuterId);
                var gate = new Gateway(ApiLogin, TxnKey, true);

                var response = gate.Send(request);

                if (response.Approved)
                {
                    context.Payment.IsCancelled = true;
                    retVal.IsSuccess = true;
                    retVal.NewPaymentStatus = context.Payment.PaymentStatus = PaymentStatus.Voided;
                    context.Payment.VoidedDate = context.Payment.CancelledDate = DateTime.UtcNow;
                }
                else
                {
                    retVal.ErrorMessage = response.Message;
                }
            }
            else
            {
                throw new NullReferenceException("Only authorized payments can be voided");
            }
            return retVal;
        }
예제 #15
0
        public void SendTest_Auth_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            string responseString = "1|1|1|This transaction has been approved.||P|2207740049||Auth transaction approved testing|15.11|ECHECK|auth_only||||||||||||||||||||||||||C1C4BF36B72CD3D6671063648096D7B7|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckAuthorizationRequest(EcheckType.WEB, (decimal)15.11, "125000024", "123456", BankAccountType.Checking, "Bank of Seattle", "Sue Zhu", "1234");
            string description = "Auth transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #16
0
        protected bool CreateCharge(out string auth_status,
                                     out string auth_code,
                                     out string auth_message,
                                     out string auth_response_code,
                                     out string auth_transaction_id,
                                     out decimal amt,
                                     decimal deposit,
                                     long transaction_id)
        {
            var apiKey = String.Empty;
            var transKey = String.Empty;

            var isTest = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestMode"]);

            if (isTest)
            {
                apiKey = System.Configuration.ConfigurationManager.AppSettings["TestAPIkEY"];
                transKey = System.Configuration.ConfigurationManager.AppSettings["TestTransactionKey"];
            }
            else
            {
                apiKey = System.Configuration.ConfigurationManager.AppSettings["APIKey"];
                transKey = System.Configuration.ConfigurationManager.AppSettings["TransactionKey"];
            }

            amt = deposit;

            var request = new AuthorizationRequest(CreditCardNumberTextBox.Text.Trim(),
                                                   MonthTextBox.Text.Trim() + YearTextBox.Text.Trim(),
                                                   amt,
                                                   "Myss.com Product Checkout - $" + amt,
                                                   AddressTextBox.Text.Trim(),
                                                   CityTextBox.Text.Trim(),
                                                   State.SelectedValue,
                                                   ZipTextBox.Text.Trim(),
                                                   CVVTextBox.Text.Trim(),
                                                   FirstNameTextBox.Text,
                                                   LastNameTextBox.Text);

            //Custom values that will be returned with the response
            //request.AddMerchantValue("email", EmailTextBox.Text);

            //order number
            request.AddInvoice(EmailTextBox.Text);

            //Shipping Address
            //request.AddShipping("id", "first", "last", "address", "state", "zip");

            //step 2 - create the gateway, sending in your credentials
            var gate = new Gateway(apiKey, transKey, isTest);

            //step 3 - make some money
            var response = gate.Send(request);

            if (!response.Approved)
            {
                string CardNumber = CreditCardNumberTextBox.Text.Trim();
                var sb = new StringBuilder();
                sb.Append("Name: ").Append(FirstNameTextBox.Text.Trim()).Append(" ").AppendLine(LastNameTextBox.Text.Trim());
                sb.Append("Email: ").AppendLine(EmailTextBox.Text.Trim());
                sb.Append("Card Ending With: ").AppendLine(CardNumber.Substring(CardNumber.Length - 4));
                sb.Append("Card Processor Error Message: ").AppendLine(response.ToString());

                auth_status = "declined";
                auth_code = response.AuthorizationCode;
                auth_message = response.Message;
                auth_response_code = response.ResponseCode;
                auth_transaction_id = response.TransactionID;
                try
                {
                    controller.UpateCMEDShopTransaction(transaction_id,
                                        auth_status,
                                        auth_code,
                                        auth_message,
                                        auth_response_code,
                                        auth_transaction_id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }

                Util.SendMail("*****@*****.**", "*****@*****.**", "Myss.com Purchase Credit Card Not Accepted", sb.ToString(), false);
                throw new CardAuthourize("Failed charging your credit card: error: [" + response.Message + "]  please try a different card");

            }

            auth_status = "approved";
            auth_code = response.AuthorizationCode;
            auth_message = response.Message;
            auth_response_code = response.ResponseCode;
            auth_transaction_id = response.TransactionID;

            return true;
        }
예제 #17
0
        public void SendTest_PriorAuthCapture_Approved()
        {
            //check login / password
            string sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount = (decimal)20.13;
            string transID = SendAuthOnly(amount + 1, true);
            Assert.IsTrue(transID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(transID) > 0);

            //start testing
            string responseString = "1|1|1|This transaction has been approved.|P9A0ET|P|2207700131||PriorAuthCapture transaction approved testing|20.13|CC|prior_auth_capture||||||||||||||||||||||||||4C66E6649DF48EDEBBD917A1656CD68C|||||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new PriorAuthCaptureRequest(amount, transID);
            request.DuplicateWindow = "0";
            string description = "PriorAuthCapture transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0);
            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #18
0
        public void SendTest_UnlinkedCredit_InvalidExpirationDate()
        {
            //check login / password
            string sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            string responseString = "3|1|7|Credit card expiration date is invalid.||P|0||UnlinkedCredit transaction approved testing|20.15|CC|credit||||||||||||||||||||||||||76688C1759F2A7C3616A595012F99289|||||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;            
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|')); 
         
            Gateway target = new Gateway(ApiLogin, TransactionKey, true);
            IGatewayRequest request = new UnlinkedCredit((decimal)20.15, "4111111111111111", "24");
            request.DuplicateWindow = "0";
            string description = "UnlinkedCredit transaction InvalidExpirationDate testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) == 0);
        }
예제 #19
0
        public void SendTest_UnlinkedCredit_Approved()
        {
            //check login / password
            string sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            string responseString = "1|1|1|This transaction has been approved.||P|2207179642||UnlinkedCredit transaction approved testing|20.15|CC|credit||||||||||||||||||||||||||1F01159A9561E77E4AD004FF64069B05|||||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new UnlinkedCredit((decimal)20.15, "4111111111111111", "0224");
            request.DuplicateWindow = "0";
            string description = "UnlinkedCredit transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);
            
            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #20
0
        private bool CreateCharge(out int amt, int deposit)
        {
            var apiKey = String.Empty;
            var transKey = String.Empty;

            var isTest = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestMode"]);

            if (isTest)
            {
                apiKey = System.Configuration.ConfigurationManager.AppSettings["TestAPIkEY"];
                transKey = System.Configuration.ConfigurationManager.AppSettings["TestTransactionKey"];
            }
            else
            {
                apiKey = System.Configuration.ConfigurationManager.AppSettings["APIKey"];
                transKey = System.Configuration.ConfigurationManager.AppSettings["TransactionKey"];
            }

            amt = deposit;

            var request = new AuthorizationRequest(CreditCardNumberTextBox.Text.Trim(),
                                                   MonthTextBox.Text.Trim() + YearTextBox.Text.Trim(),
                                                   amt,
                                                   "Myss.com Reflections Classes - " + amt,
                                                   AddressTextBox.Text.Trim(),
                                                   CityTextBox.Text.Trim(),
                                                   State.SelectedValue,
                                                   ZipTextBox.Text.Trim(),
                                                   CVVTextBox.Text.Trim(),
                                                   FirstNameTextBox.Text,
                                                   LastNameTextBox.Text);

            //Custom values that will be returned with the response
            //request.AddMerchantValue("email", EmailTextBox.Text);

            //order number
            request.AddInvoice(EmailTextBox.Text);

            //Shipping Address
            //request.AddShipping("id", "first", "last", "address", "state", "zip");

            //step 2 - create the gateway, sending in your credentials
            var gate = new Gateway(apiKey, transKey, isTest);

            //step 3 - make some money
            var response = gate.Send(request);

            if (!response.Approved)
            {
                string CardNumber = CreditCardNumberTextBox.Text.Trim();
                var sb = new StringBuilder();
                sb.Append("Name: ").Append(FirstNameTextBox.Text.Trim()).Append(" ").AppendLine(LastNameTextBox.Text.Trim());
                sb.Append("Email: ").AppendLine(EmailTextBox.Text.Trim());
                sb.Append("Card Ending With: ").AppendLine(CardNumber.Substring(CardNumber.Length - 4));
                sb.Append("Card Processor Error Message: ").AppendLine(response.ToString());

                Util.SendMail("*****@*****.**", "*****@*****.**", "Myss.com Reflections Classes Credit Card Not Accepted", sb.ToString(), false);
                lblErrorMessage.Text = "Unable to process your credit card. Please verify the information or try another card. ";
                throw new InvalidOperationException("Subscription failed: " + response.ToString());

            }
            return true;
        }
예제 #21
0
        private IGatewayResponse ChargeConsumer(CartCheckOut checkOutDetails, CartSummary cartSummary)
        {
            var paymentRequest = new AuthorizationRequest(checkOutDetails.CardNumber,
                                                    string.Format("{0}{1}", checkOutDetails.ExpirationMonth, checkOutDetails.ExpirationYear),
                                                    cartSummary.TotalCost,
                                                    "Dirty Girl Cart Purchase",
                                                    true);

            paymentRequest.FirstName = checkOutDetails.CardHolderFirstname;
            paymentRequest.LastName = checkOutDetails.CardHolderLastname;
            paymentRequest.Zip = checkOutDetails.CardHolderZipCode;
            paymentRequest.CardCode = checkOutDetails.CCVNumber;

            var totalTax = 0.0M;
            foreach (var item in cartSummary.CartItems)
            {
                paymentRequest.AddLineItem(item.PurchaseItemId.ToString(), item.ItemName, item.DiscountDescription, 1, item.ItemTotal, item.Taxable);
                if (item.Taxable)
                    totalTax += (item.StateTax + item.LocalTax);
            }

            paymentRequest.AddTax(totalTax);

            var gateway = new Gateway(DirtyGirlServiceConfig.Settings.PaymentGatewayId, DirtyGirlServiceConfig.Settings.PaymentGatewayKey, true);
            gateway.TestMode = DirtyGirlServiceConfig.Settings.PaymentTestMode;

            return gateway.Send(paymentRequest);
        }
예제 #22
0
        private string SendAuthOnly(decimal amount, bool returnTransID)
        {
            string responseString = "1|1|1|This transaction has been approved.|P9A0ET|Y|2207700131||AuthOnly transaction approved testing|11.21|CC|auth_only||||||||||||||||||||||||||C4DB0F58C8BE75212AB0261BF7F1BE21||2|||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new AuthorizationRequest("4111111111111111", "0224", amount, "AuthOnly transaction approved testing", false);
            string description = "Auth only transaction approved testing";

            IGatewayResponse response = target.Send(request, description);

            if (response.Approved)
            {
                if (returnTransID)
                {
                    return response.TransactionID;
                }
                else
                {
                    return response.AuthorizationCode;
                }
            }
            else
            {
                return "";
            }
        }
예제 #23
0
        public void SendTest_Void_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount = (decimal)15.16;
            string transID = SendAuthOnly(amount);
            Assert.IsTrue(transID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(transID) > 0);

            //start testing
            string responseString = "1|1|1|This transaction has been approved.||P|2207750596||Void transaction approved testing|0.00|ECHECK|void||||||||||||||||||||||||||53BCDE1CC703090924414B0BE71F3D12||||||||||||||Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckVoidRequest(transID);
            string description = "Void transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #24
0
        public void SendTest_FailedCredit_ReasonResponseCode()
        {
            //check login / password
            string sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            string transID = "1";

            string responseString = "3|1|54|The referenced transaction does not meet the criteria for issuing a credit.|||0||Fail to Credit invalid transaction|6.14|CC|credit||||||||||||||||||||||||||E5FBFF01C6A66AA75C1EE966943CAEAC|||||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new CreditRequest(transID, (decimal)6.14, "1111");
            string description = "Fail to Credit invalid transaction";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);
            Assert.AreEqual(((GatewayResponse)expected).ResponseReasonCode, ((GatewayResponse)expected).ResponseReasonCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.AreEqual(expected.TransactionID, actual.TransactionID);
        }
예제 #25
0
        private string SendAuthOnly(decimal amount)
        {
            string responseString = "1|1|1|This transaction has been approved.||P|2207740049||Auth transaction approved testing|15.13|ECHECK|auth_only||||||||||||||||||||||||||C1C4BF36B72CD3D6671063648096D7B7|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckAuthorizationRequest(EcheckType.WEB, amount, "125000024", "123456", BankAccountType.Checking, "Bank of Seattle", "Sue Zhu", "1234");
            string description = "Auth transaction approved testing";

            IGatewayResponse response = target.Send(request, description);

            if (response.Approved)
            {
                return response.TransactionID;
            }
            else
            {
                return "";
            }
        }
예제 #26
0
        public void SendTest_AuthCap_CCD_BusinessChecking_Approved()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            string responseString = "1|1|1|This transaction has been approved.||P|2211133545||AuthCap transaction approved testing|15.17|ECHECK|auth_capture||||||||||||||||||||||||||0D5993C7EC85C7C2C67046EF108D5870|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckRequest(EcheckType.CCD, (decimal)15.17, "125000024", "123456", BankAccountType.BusinessChecking, "Bank of Seattle", "Sue Zhu", "1234");
            string description = "AuthCap transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #27
0
        public void SendTest_AuthCap_PPD_BusinessChecking_Denied()
        {
            //check ApiLoginid / TransactionKey
            string sError = CheckApiLoginTransactionKey();
            Assert.IsTrue(sError == "", sError);

            string responseString = "3|1|244|This eCheck.Net type is not allowed for this Bank Account Type.||P|0||AuthCap transaction approved testing|15.18|ECHECK|auth_capture||||||||||||||||||||||||||CEB5EEB8C910EFD2D8B660A7F0A2A9CD|||||||||||||XXXX3456|Bank Account||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new EcheckRequest(EcheckType.PPD, (decimal)15.18, "125000024", "123456", BankAccountType.BusinessChecking, "Bank of Seattle", "Sue Zhu", "1234");
            string description = "AuthCap transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) == 0);
        }
예제 #28
0
        public void SendTest_Capture_Approved()
        {
            //check login / password
            string sError = CheckLoginPassword();
            Assert.IsTrue(sError == "", sError);

            //setup
            decimal amount = (decimal)20.12;
            string authCode = SendAuthOnly(amount + 1, false);
            Assert.IsTrue(authCode.Trim().Length > 0);

            //start testing
            string responseString = "1|1|1|This transaction has been approved.|X297JA|P|2207700989||Capture transaction approved testing|20.12|CC|capture_only||||||||||||||||||||||||||13E5B43A154FFEDF556537BEA77BAB80|||||||||||||XXXX1111|Visa||||||||||||||||";
            LocalRequestObject.ResponseString = responseString;
            IGatewayResponse expected = new GatewayResponse(responseString.Split('|'));

            Gateway target = new Gateway(ApiLogin, TransactionKey, true);

            IGatewayRequest request = new CaptureRequest(authCode, "4111111111111111", "0224", amount);
            string description = "Capture transaction approved testing";

            IGatewayResponse actual = target.Send(request, description);

            Assert.AreEqual(expected.Amount, actual.Amount);
            Assert.AreEqual(expected.Approved, actual.Approved);
            Assert.AreEqual(expected.CardNumber, actual.CardNumber);
            Assert.AreEqual(expected.Message, actual.Message);
            Assert.AreEqual(expected.ResponseCode, actual.ResponseCode);

            Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0);
            Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
            Assert.IsTrue(long.Parse(actual.TransactionID) > 0);
        }
예제 #29
0
        public ActionResult Authorize() {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer customer = new Customer();
            Settings settings = ViewBag.settings;
            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage(ctx);
            if (!customer.Cart.Validate()) {
                return RedirectToAction("Index", "Cart");
            }

            if (customer.Cart.GetPaymentID() > 0) {
                UDF.ExpireCart(ctx, customer.ID);
                return RedirectToAction("Index", "Cart");
            }

            customer.BindAddresses();

            decimal amount = customer.Cart.getTotal();
            string cardnum = Request.Form["cardnumber"];
            string month = Request.Form["expiremonth"];
            string year = Request.Form["expireyear"];
            string cvv = Request.Form["cvv"];
            string first = Request.Form["first"];
            string last = Request.Form["last"];

            //step 1 - create the request
            IGatewayRequest request = new AuthorizationRequest(cardnum, month + year, amount, "Transaction");

            //These are optional calls to the API
            request.AddCardCode(cvv);

            //Customer info - this is used for Fraud Detection
            request.AddCustomer(customer.ID.ToString(), first, last, customer.Cart.Billing.street1 + ((customer.Cart.Billing.street2 != "") ? " " + customer.Cart.Billing.street2 : ""), customer.Cart.Billing.State1.abbr, customer.Cart.Billing.postal_code);

            //order number
            //request.AddInvoice("invoiceNumber");

            //Custom values that will be returned with the response
            //request.AddMerchantValue("merchantValue", "value");

            //Shipping Address
            request.AddShipping(customer.ID.ToString(), customer.Cart.Shipping.first, customer.Cart.Shipping.last, customer.Cart.Shipping.street1 + ((customer.Cart.Shipping.street2 != "") ? " " + customer.Cart.Shipping.street2 : ""), customer.Cart.Shipping.State1.abbr, customer.Cart.Shipping.postal_code);


            //step 2 - create the gateway, sending in your credentials and setting the Mode to Test (boolean flag)
            //which is true by default
            //this login and key are the shared dev account - you should get your own if you 
            //want to do more testing
            bool testmode = false;
            if (settings.Get("AuthorizeNetTestMode").Trim() == "true") {
                testmode = true;
            }

            Gateway gate = new Gateway(settings.Get("AuthorizeNetLoginKey"), settings.Get("AuthorizeNetTransactionKey"), testmode);
            customer.Cart.SetStatus((int)OrderStatuses.PaymentPending);

            //step 3 - make some money
            IGatewayResponse response = gate.Send(request);
            if (response.Approved) {
                customer.Cart.AddPayment("credit card", response.AuthorizationCode, "Complete");
                customer.Cart.SetStatus((int)OrderStatuses.PaymentComplete);
                customer.Cart.SendConfirmation(ctx);
                customer.Cart.SendInternalOrderEmail(ctx);
                int cartid = customer.Cart.ID;
                
                Cart new_cart = new Cart().Save();
                new_cart.UpdateCart(ctx, customer.ID);
                DateTime cookexp = Request.Cookies["hdcart"].Expires;
                HttpCookie cook = new HttpCookie("hdcart", new_cart.ID.ToString());
                cook.Expires = cookexp;
                Response.Cookies.Add(cook);

                customer.Cart = new_cart;
                customer.Cart.BindAddresses();

                return RedirectToAction("Complete", new { id = cartid });
            } else {
                customer.Cart.SetStatus((int)OrderStatuses.PaymentDeclined);
                return RedirectToAction("Index", new { message = response.Message });
            }
        }
예제 #30
0
        private bool CreateCharge()
        {
            var apiKey = System.Configuration.ConfigurationManager.AppSettings["APIKeySmithEvents"];
            var transKey = System.Configuration.ConfigurationManager.AppSettings["TransactionKeySmithEvents"];
            var isTest = Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["IsTestModeSmithEvents"]);

            var amt = Convert.ToDecimal(PaymentDropDown.SelectedValue);

            var tour = Request.QueryString["tour"];
            var key = tour + "Title";
            var tour_title = System.Configuration.ConfigurationManager.AppSettings[key];
            var title = "Smith Events - " + tour_title.ToUpper();

            var request = new AuthorizationRequest(CreditCardNumberTextBox.Text.Trim(), MonthTextBox.Text.Trim() + YearTextBox.Text.Trim(), amt,
                   title + amt, AddressTextBox.Text.Trim(), CityTextBox.Text.Trim(), State.SelectedValue, ZipTextBox.Text.Trim(),
                   CVCTextBox.Text.Trim(), FirstNameTextBox.Text, LastNameTextBox.Text);

            //step 2 - create the gateway, sending in your credentials
            var gate = new Gateway(apiKey, transKey, isTest);

            //step 3 - make some money
            var response = gate.Send(request);
            if (!response.Approved)
            {
                Util.SendMail("*****@*****.**", "*****@*****.**", title, response.Message, false);
                throw new InvalidOperationException("Charge failed: " + response.Message);
            }
            return true;
        }