在 ASP.NET 中接受信用卡的最佳方式是什么? (ASP.NET 和 Authorize.NET 之间)

发布于 2024-09-15 08:03:05 字数 201 浏览 3 评论 0原文

我是创建商业网站的新手,现在我需要通过互联网销售软件,我不知道从哪里开始。

我正在使用 ASP.NET,并正在考虑使用 Authorize.NET 来验证和处理信用卡。

我正在寻找一个可以安装在单个服务器上的稳定、可信的解决方案。我的第二个目标(除了在线销售产品之外)是熟悉流行且大型企业使用的购物车软件。也许我应该从 MS Commerce 服务器开始?

I'm new to creating commerce websites, and now that I need to sell software over the internet, I'm not sure where to start.

I'm using ASP.NET and am considering using Authorize.NET to validate and process the credit cards.

I'm looking for a stable, trusted solution that I can install on a single server. My secondary goal (besides selling products online) is to become familiar with shopping cart software that is popular, and in use by large businesses. Perhaps I should start with MS Commerce server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

止于盛夏 2024-09-22 08:03:05

这里有一百万个选项,但如果您正在编写代码,最简单的代码方式是使用 http://sharpauthorize。 com/

There are a million options here, but if you are writing the code, the easiest way code-wise is to use http://sharpauthorize.com/

就此别过 2024-09-22 08:03:05

Authorize.Net 非常容易使用 ASP.NET 实现

基本上您可以通过 3-4 种方式进行交易:

  1. 通过按钮简单结帐,如 Paypal (http://developer.authorize.net/api/simplecheckout/)
  2. Direct Post :假设您比 Simple CheckOut 多一点自定义。创建直接发布到 Authorize.Net http://developer.authorize.net/api/simplecheckout 的结帐表单/

例如:

<h1><%=ViewData["message"] %></h1>
<%using (Html.BeginSIMForm("http://YOUR_SERVER.com/home/sim",
1.99M,"YOUR_API_LOGIN","YOUR_TRANSACTION_KEY",true)){%>
<%=Html.CheckoutFormInputs(true)%>
<%=Html.Hidden("order_id","1234") %>
<input type = "submit" value = "Pay" />
<%}%>
  1. SIM(服务器集成)
  2. AIM(高级集成方法):给予完全控制和控制定制。
  3. CIM(使用tokanization在Auth.NET服务器上存储客户卡号和信息)

*下面是进行交易的CIM功能示例,AIM与CIM非常相似,唯一的区别是tokanization *

using ProjName.AuthApiSoap;  // USE AUth Webserice Reference

   public Tuple<string, string, string> CreateTransaction(long profile_id, long payment_profile_id, decimal amt, string DDD)
        {
            CustomerProfileWS.ProfileTransAuthCaptureType auth_capture = new CustomerProfileWS.ProfileTransAuthCaptureType();
            auth_capture.customerProfileId = profile_id;
            auth_capture.customerPaymentProfileId = payment_profile_id;
            auth_capture.amount = amt;//1.00m;
            auth_capture.order = new CustomerProfileWS.OrderExType();
            POSLib.POSManager objManager = new POSLib.POSManager();
            auth_capture.order.invoiceNumber = objManager.GetTimestamp(DateTime.Now);
            DateTime now = DateTime.Now;
            auth_capture.order.description = "Service  " + DDD;
            CustomerProfileWS.ProfileTransactionType trans = new CustomerProfileWS.ProfileTransactionType();
            trans.Item = auth_capture;
            CustomerProfileWS.CreateCustomerProfileTransactionResponseType response = SoapAPIUtilities.Service.CreateCustomerProfileTransaction(SoapAPIUtilities.MerchantAuthentication, trans, null);

            string AuthTranMsg = "";
            string AuthTranCode = "";
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranMsg = response.messages[i].text;  // To Get Message n for loop to check the [i] is not empty 
            }
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranCode = response.messages[i].code;   // To Get Code n for loop to check the [i] is not empty 
            }
            var tCompResp = new Tuple<string, string, string>(AuthTranCode, AuthTranMsg, response.directResponse);
            return tCompResp;
        }

这是如何拆分响应消息(格式和顺序将针对响应的网络服务上的所有交易/进行固定)

 var tResp = objManager.CreateTransaction(profID, paymProfID, Convert.ToDecimal(PmtToday), DDD);
                    string respCCNo = "";
                    string RespCCType = "";
                    string InvoiceNo = "";
                    string transType = "";
                    string approvalCode = "";
                    string AmtRequested = "";
                    string respName = "";
                    string respReasonText = "";
                    string respMD5Hash = "";
                    string respEmailId = "";
                    string respReasonCode = "";
                    string respMethod = "";
                    string respAVSResultCode = "";
                    string responseCode = "";
                    string transactionId = "0";
                    if (!string.IsNullOrEmpty(tCompResp.Item3))
                    {
                        string[] arrRespParts = tCompResp.Item3.Replace("|", "").Split(',');
                        responseCode = arrRespParts[0];
                        respReasonCode = arrRespParts[2];
                        respReasonText = arrRespParts[3];
                        approvalCode = arrRespParts[4];
                        respAVSResultCode = arrRespParts[5];
                        transactionId = arrRespParts[6].Replace("|", "");
                        InvoiceNo = arrRespParts[7];
                        AmtRequested = arrRespParts[9];
                        transType = arrRespParts[10];
                        respMethod = arrRespParts[11];
                        respName = arrRespParts[13] + " " + arrRespParts[14];
                        respEmailId = arrRespParts[23];
                        respMD5Hash = arrRespParts[37];
                        respCCNo = arrRespParts[50];
                        RespCCType = arrRespParts[51];
                    }

=== ===============================AIM 代码

 public Tuple<string, string, string> ECheckCreateTransAIM(string amount, string bankRoutingNo, string bankAccNo, string bankAccType, string bankName, string bankAccName, string echeckType, bool isCustomerEmail, string customerEmail, string mechantEMail)
        {
            //CustomValidator1.ErrorMessage = "";
            string AuthNetVersion = "3.1"; // Contains CCV support

            WebClient webClientRequest = new WebClient();
            System.Collections.Specialized.NameValueCollection InputObject = new System.Collections.Specialized.NameValueCollection(30);
            System.Collections.Specialized.NameValueCollection ReturnObject = new System.Collections.Specialized.NameValueCollection(30);
            byte[] ReturnBytes;
            string[] ReturnValues;
            string ErrorString;
            InputObject.Add("x_version", AuthNetVersion);
            InputObject.Add("x_delim_data", "True");
            InputObject.Add("x_login", MERCHANT_NAME);
            InputObject.Add("x_tran_key", TRANSACTION_KEY);
            InputObject.Add("x_relay_response", "False");
            //----------------------Set to False to go Live--------------------
            InputObject.Add("x_test_request", "False");
            //---------------------------------------------------------------------
            InputObject.Add("x_delim_char", ",");
            InputObject.Add("x_encap_char", "|");
            if (isCustomerEmail)
            {
                InputObject.Add("x_email", customerEmail);
                InputObject.Add("x_email_customer", "TRUE");                     //Emails Customer
            }
            InputObject.Add("x_merchant_email", mechantEMail);
            // FOR echeck            
            InputObject.Add("x_bank_aba_code", bankRoutingNo);
            InputObject.Add("x_bank_acct_num", bankAccNo);
            InputObject.Add("x_bank_acct_type", bankAccType);
            InputObject.Add("x_bank_name", bankName);
            InputObject.Add("x_bank_acct_name", bankAccName);
            InputObject.Add("x_method", "ECHECK");
            InputObject.Add("x_type", "AUTH_CAPTURE");
            InputObject.Add("x_amount", string.Format("{0:c2}", Convert.ToDouble(amount)));
            // Currency setting. Check the guide for other supported currencies           
            //needto change it to Actual Server URL
            //Set above Testmode=off to go live
            webClientRequest.BaseAddress = eCheckBaseAddress;  //"https://apitest.authorize.net/soap/v1/Service.asmx"; //"https://secure.authorize.net/gateway/transact.dll";
            ReturnBytes = webClientRequest.UploadValues(webClientRequest.BaseAddress, "POST", InputObject);
            ReturnValues = System.Text.Encoding.ASCII.GetString(ReturnBytes).Split(",".ToCharArray());
            if (ReturnValues[0].Trim(char.Parse("|")) == "1")  // Succesful Transaction
            {
                //AuthNetCodeLabel.Text = ReturnValues[4].Trim(char.Parse("|")); // Returned Authorisation Code
                //AuthNetTransIDLabel.Text = ReturnValues[6].Trim(char.Parse("|")); // Returned Transaction ID
                var tCompResp = new Tuple<string, string, string>("I00001", ReturnValues[3].Trim(char.Parse("|")), string.Join(",", ReturnValues));
                return tCompResp;
            }
            else
            {
                // Error!
                ErrorString = ReturnValues[3].Trim(char.Parse("|")) + " (" + ReturnValues[2].Trim(char.Parse("|")) + ")";
                if (ReturnValues[2].Trim(char.Parse("|")) == "45")
                {
                    if (ErrorString.Length > 1)
                        ErrorString += "<br />n";

                    // AVS transaction decline
                    ErrorString += "Address Verification System (AVS) " +
                      "returned the following error: ";

                    switch (ReturnValues[5].Trim(char.Parse("|")))
                    {
                        case "A":
                            ErrorString += " the zip code entered does not match the billing address.";
                            break;
                        case "B":
                            ErrorString += " no information was provided for the AVS check.";
                            break;
                        case "E":
                            ErrorString += " a general error occurred in the AVS system.";
                            break;
                        case "G":
                            ErrorString += " the credit card was issued by a non-US bank.";
                            break;
                        case "N":
                            ErrorString += " neither the entered street address nor zip code matches the billing address.";
                            break;
                        case "P":
                            ErrorString += " AVS is not applicable for this transaction.";
                            break;
                        case "R":
                            ErrorString += " please retry the transaction; the AVS system was unavailable or timed out.";
                            break;
                        case "S":
                            ErrorString += " the AVS service is not supported by your credit card issuer.";
                            break;
                        case "U":
                            ErrorString += " address information is unavailable for the credit card.";
                            break;
                        case "W":
                            ErrorString += " the 9 digit zip code matches, but the street address does not.";
                            break;
                        case "Z":
                            ErrorString += " the zip code matches, but the address does not.";
                            break;
                    }
                }

            }
            var tCompRespFail = new Tuple<string, string, string>(ReturnValues[6].ToString(), ErrorString, string.Join(",", ReturnValues));
            return tCompRespFail;


        }

CIM 代码(托坎化(卡不存在方法)

   public Tuple<string, string, string> CreateTransaction(long profile_id, long payment_profile_id, decimal amt, string DDD)
        {
            CustomerProfileWS.ProfileTransAuthCaptureType auth_capture = new CustomerProfileWS.ProfileTransAuthCaptureType();
            auth_capture.customerProfileId = profile_id;
            auth_capture.customerPaymentProfileId = payment_profile_id;
            auth_capture.amount = amt;//1.00m;
            auth_capture.order = new CustomerProfileWS.OrderExType();
            POSLib.POSManager objManager = new POSLib.POSManager();
            auth_capture.order.invoiceNumber = objManager.GetTimestamp(DateTime.Now);
            DateTime now = DateTime.Now;
            auth_capture.order.description = "Service  " + DDD;
            CustomerProfileWS.ProfileTransactionType trans = new CustomerProfileWS.ProfileTransactionType();
            trans.Item = auth_capture;
            CustomerProfileWS.CreateCustomerProfileTransactionResponseType response = SoapAPIUtilities.Service.CreateCustomerProfileTransaction(SoapAPIUtilities.MerchantAuthentication, trans, null);

            string AuthTranMsg = "";
            string AuthTranCode = "";
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranMsg = response.messages[i].text;  // To Get Message n for loop to check the [i] is not empty 
            }
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranCode = response.messages[i].code;   // To Get Code n for loop to check the [i] is not empty 
            }
            var tCompResp = new Tuple<string, string, string>(AuthTranCode, AuthTranMsg, response.directResponse);
            return tCompResp;
        }

Authorize.Net is Very easy to implement with ASP.NET

Basically you can make transaction in 3-4 ways:

  1. Simple Checkout Through Button like Paypal (http://developer.authorize.net/api/simplecheckout/)
  2. Direct Post : Suppose you little bit more customization than Simple CheckOut. Create a checkout form that posts directly to Authorize.Net http://developer.authorize.net/api/simplecheckout/

Eg:

<h1><%=ViewData["message"] %></h1>
<%using (Html.BeginSIMForm("http://YOUR_SERVER.com/home/sim",
1.99M,"YOUR_API_LOGIN","YOUR_TRANSACTION_KEY",true)){%>
<%=Html.CheckoutFormInputs(true)%>
<%=Html.Hidden("order_id","1234") %>
<input type = "submit" value = "Pay" />
<%}%>
  1. SIM (Server Integration)
  2. AIM (Advance Integration Method): Give full control & customization.
  3. CIM ( store Customer card no & info on Auth.NET server with tokanization)

*Below is a sample of CIM function to make a transaction, AIM is very much similar to CIM only difference is tokanization *

using ProjName.AuthApiSoap;  // USE AUth Webserice Reference

   public Tuple<string, string, string> CreateTransaction(long profile_id, long payment_profile_id, decimal amt, string DDD)
        {
            CustomerProfileWS.ProfileTransAuthCaptureType auth_capture = new CustomerProfileWS.ProfileTransAuthCaptureType();
            auth_capture.customerProfileId = profile_id;
            auth_capture.customerPaymentProfileId = payment_profile_id;
            auth_capture.amount = amt;//1.00m;
            auth_capture.order = new CustomerProfileWS.OrderExType();
            POSLib.POSManager objManager = new POSLib.POSManager();
            auth_capture.order.invoiceNumber = objManager.GetTimestamp(DateTime.Now);
            DateTime now = DateTime.Now;
            auth_capture.order.description = "Service  " + DDD;
            CustomerProfileWS.ProfileTransactionType trans = new CustomerProfileWS.ProfileTransactionType();
            trans.Item = auth_capture;
            CustomerProfileWS.CreateCustomerProfileTransactionResponseType response = SoapAPIUtilities.Service.CreateCustomerProfileTransaction(SoapAPIUtilities.MerchantAuthentication, trans, null);

            string AuthTranMsg = "";
            string AuthTranCode = "";
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranMsg = response.messages[i].text;  // To Get Message n for loop to check the [i] is not empty 
            }
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranCode = response.messages[i].code;   // To Get Code n for loop to check the [i] is not empty 
            }
            var tCompResp = new Tuple<string, string, string>(AuthTranCode, AuthTranMsg, response.directResponse);
            return tCompResp;
        }

This is how to split the Reponse Msg (Format and Order will be FIXED for all transaction/ on web service responsed )

 var tResp = objManager.CreateTransaction(profID, paymProfID, Convert.ToDecimal(PmtToday), DDD);
                    string respCCNo = "";
                    string RespCCType = "";
                    string InvoiceNo = "";
                    string transType = "";
                    string approvalCode = "";
                    string AmtRequested = "";
                    string respName = "";
                    string respReasonText = "";
                    string respMD5Hash = "";
                    string respEmailId = "";
                    string respReasonCode = "";
                    string respMethod = "";
                    string respAVSResultCode = "";
                    string responseCode = "";
                    string transactionId = "0";
                    if (!string.IsNullOrEmpty(tCompResp.Item3))
                    {
                        string[] arrRespParts = tCompResp.Item3.Replace("|", "").Split(',');
                        responseCode = arrRespParts[0];
                        respReasonCode = arrRespParts[2];
                        respReasonText = arrRespParts[3];
                        approvalCode = arrRespParts[4];
                        respAVSResultCode = arrRespParts[5];
                        transactionId = arrRespParts[6].Replace("|", "");
                        InvoiceNo = arrRespParts[7];
                        AmtRequested = arrRespParts[9];
                        transType = arrRespParts[10];
                        respMethod = arrRespParts[11];
                        respName = arrRespParts[13] + " " + arrRespParts[14];
                        respEmailId = arrRespParts[23];
                        respMD5Hash = arrRespParts[37];
                        respCCNo = arrRespParts[50];
                        RespCCType = arrRespParts[51];
                    }

==================================AIM Code

 public Tuple<string, string, string> ECheckCreateTransAIM(string amount, string bankRoutingNo, string bankAccNo, string bankAccType, string bankName, string bankAccName, string echeckType, bool isCustomerEmail, string customerEmail, string mechantEMail)
        {
            //CustomValidator1.ErrorMessage = "";
            string AuthNetVersion = "3.1"; // Contains CCV support

            WebClient webClientRequest = new WebClient();
            System.Collections.Specialized.NameValueCollection InputObject = new System.Collections.Specialized.NameValueCollection(30);
            System.Collections.Specialized.NameValueCollection ReturnObject = new System.Collections.Specialized.NameValueCollection(30);
            byte[] ReturnBytes;
            string[] ReturnValues;
            string ErrorString;
            InputObject.Add("x_version", AuthNetVersion);
            InputObject.Add("x_delim_data", "True");
            InputObject.Add("x_login", MERCHANT_NAME);
            InputObject.Add("x_tran_key", TRANSACTION_KEY);
            InputObject.Add("x_relay_response", "False");
            //----------------------Set to False to go Live--------------------
            InputObject.Add("x_test_request", "False");
            //---------------------------------------------------------------------
            InputObject.Add("x_delim_char", ",");
            InputObject.Add("x_encap_char", "|");
            if (isCustomerEmail)
            {
                InputObject.Add("x_email", customerEmail);
                InputObject.Add("x_email_customer", "TRUE");                     //Emails Customer
            }
            InputObject.Add("x_merchant_email", mechantEMail);
            // FOR echeck            
            InputObject.Add("x_bank_aba_code", bankRoutingNo);
            InputObject.Add("x_bank_acct_num", bankAccNo);
            InputObject.Add("x_bank_acct_type", bankAccType);
            InputObject.Add("x_bank_name", bankName);
            InputObject.Add("x_bank_acct_name", bankAccName);
            InputObject.Add("x_method", "ECHECK");
            InputObject.Add("x_type", "AUTH_CAPTURE");
            InputObject.Add("x_amount", string.Format("{0:c2}", Convert.ToDouble(amount)));
            // Currency setting. Check the guide for other supported currencies           
            //needto change it to Actual Server URL
            //Set above Testmode=off to go live
            webClientRequest.BaseAddress = eCheckBaseAddress;  //"https://apitest.authorize.net/soap/v1/Service.asmx"; //"https://secure.authorize.net/gateway/transact.dll";
            ReturnBytes = webClientRequest.UploadValues(webClientRequest.BaseAddress, "POST", InputObject);
            ReturnValues = System.Text.Encoding.ASCII.GetString(ReturnBytes).Split(",".ToCharArray());
            if (ReturnValues[0].Trim(char.Parse("|")) == "1")  // Succesful Transaction
            {
                //AuthNetCodeLabel.Text = ReturnValues[4].Trim(char.Parse("|")); // Returned Authorisation Code
                //AuthNetTransIDLabel.Text = ReturnValues[6].Trim(char.Parse("|")); // Returned Transaction ID
                var tCompResp = new Tuple<string, string, string>("I00001", ReturnValues[3].Trim(char.Parse("|")), string.Join(",", ReturnValues));
                return tCompResp;
            }
            else
            {
                // Error!
                ErrorString = ReturnValues[3].Trim(char.Parse("|")) + " (" + ReturnValues[2].Trim(char.Parse("|")) + ")";
                if (ReturnValues[2].Trim(char.Parse("|")) == "45")
                {
                    if (ErrorString.Length > 1)
                        ErrorString += "<br />n";

                    // AVS transaction decline
                    ErrorString += "Address Verification System (AVS) " +
                      "returned the following error: ";

                    switch (ReturnValues[5].Trim(char.Parse("|")))
                    {
                        case "A":
                            ErrorString += " the zip code entered does not match the billing address.";
                            break;
                        case "B":
                            ErrorString += " no information was provided for the AVS check.";
                            break;
                        case "E":
                            ErrorString += " a general error occurred in the AVS system.";
                            break;
                        case "G":
                            ErrorString += " the credit card was issued by a non-US bank.";
                            break;
                        case "N":
                            ErrorString += " neither the entered street address nor zip code matches the billing address.";
                            break;
                        case "P":
                            ErrorString += " AVS is not applicable for this transaction.";
                            break;
                        case "R":
                            ErrorString += " please retry the transaction; the AVS system was unavailable or timed out.";
                            break;
                        case "S":
                            ErrorString += " the AVS service is not supported by your credit card issuer.";
                            break;
                        case "U":
                            ErrorString += " address information is unavailable for the credit card.";
                            break;
                        case "W":
                            ErrorString += " the 9 digit zip code matches, but the street address does not.";
                            break;
                        case "Z":
                            ErrorString += " the zip code matches, but the address does not.";
                            break;
                    }
                }

            }
            var tCompRespFail = new Tuple<string, string, string>(ReturnValues[6].ToString(), ErrorString, string.Join(",", ReturnValues));
            return tCompRespFail;


        }

CIM CODE (Tokanisation (Card not present method)

   public Tuple<string, string, string> CreateTransaction(long profile_id, long payment_profile_id, decimal amt, string DDD)
        {
            CustomerProfileWS.ProfileTransAuthCaptureType auth_capture = new CustomerProfileWS.ProfileTransAuthCaptureType();
            auth_capture.customerProfileId = profile_id;
            auth_capture.customerPaymentProfileId = payment_profile_id;
            auth_capture.amount = amt;//1.00m;
            auth_capture.order = new CustomerProfileWS.OrderExType();
            POSLib.POSManager objManager = new POSLib.POSManager();
            auth_capture.order.invoiceNumber = objManager.GetTimestamp(DateTime.Now);
            DateTime now = DateTime.Now;
            auth_capture.order.description = "Service  " + DDD;
            CustomerProfileWS.ProfileTransactionType trans = new CustomerProfileWS.ProfileTransactionType();
            trans.Item = auth_capture;
            CustomerProfileWS.CreateCustomerProfileTransactionResponseType response = SoapAPIUtilities.Service.CreateCustomerProfileTransaction(SoapAPIUtilities.MerchantAuthentication, trans, null);

            string AuthTranMsg = "";
            string AuthTranCode = "";
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranMsg = response.messages[i].text;  // To Get Message n for loop to check the [i] is not empty 
            }
            for (int i = 0; i < response.messages.Length; i++)
            {
                AuthTranCode = response.messages[i].code;   // To Get Code n for loop to check the [i] is not empty 
            }
            var tCompResp = new Tuple<string, string, string>(AuthTranCode, AuthTranMsg, response.directResponse);
            return tCompResp;
        }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文