2010-08-19 21 views
0

Je suis nouveau à la création de sites Web de commerce, et maintenant que j'ai besoin de vendre des logiciels sur Internet, je ne sais pas par où commencer. J'utilise ASP.NET et envisage d'utiliser Authorize.NET pour valider et traiter les cartes de crédit.Quelle est la meilleure façon d'accepter une carte de crédit dans ASP.NET? (Entre ASP.NET et Authorize.NET)

Je suis à la recherche d'une solution stable et fiable que je peux installer sur un seul serveur. Mon objectif secondaire (outre la vente de produits en ligne) est de se familiariser avec les logiciels de panier qui sont populaires et utilisés par les grandes entreprises. Peut-être que je devrais commencer avec le serveur MS Commerce?

+3

intégration avec Authorize.Net est super facile. – TheGeekYouNeed

+0

^^^ Je ne suis pas d'accord plus –

Répondre

0

Authorize.Net est très facile à mettre en œuvre avec ASP.NET

Fondamentalement vous pouvez faire transaction 3-4 façons:

  1. Commander simple Par bouton comme Paypal (http://developer.authorize.net/api/simplecheckout/)
  2. direct post: Supposons que vous peu plus la personnalisation tha n CheckOut simple. Créer un formulaire de commande que les messages directement à Authorize.Net http://developer.authorize.net/api/simplecheckout/

Par exemple:

<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 (Integration Server)
  2. AIM (intégration Advance méthode): donner le plein contrôle & personnalisation
  3. CIM (magasin carte client pas d'info & sur le serveur Auth.NET avec tokanization)

* Ci-dessous un échantillon de la fonction CIM pour effectuer une transaction, AIM est très similaire à la CIM seule différence est 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; 
     } 

Voici comment diviser le Msg Reponse (Format et d'ordre sera fixé pour toutes les transactions/sur le service Web 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]; 
        } 

================================== Code 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; 


     } 

CODE CIM (Tokanisation (carte non présente méthode)

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; 
     }