Hi there all...

i'm implementing Authorize.net and i wanna know...

do i need to add a web reference i.e web service...

or do i need any .dll files.....?

No, you can do it all in managed code.

Sandbox/Live transaction URL:

private string PostingURL
    {
      get
      {
        if (_testMode)
          return @"https://test.authorize.net/gateway/transact.dll";
        else
          return @"https://secure.authorize.net/gateway/transact.dll";
      }
    }

To post:

public void Post()
    {
      string postURL = this.PostingURL;
      string args = GetPostUrlArgs();
      string result = string.Empty;

      HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(postURL);
      objRequest.Method = "POST";
      objRequest.ContentLength = args.Length;
      objRequest.ContentType = "application/x-www-form-urlencoded";

      StreamWriter myWriter = null;
      try
      {
        myWriter = new StreamWriter(objRequest.GetRequestStream());
        myWriter.Write(args);
      }
      finally
      {
        myWriter.Close();
        myWriter.Dispose();
      }

      HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
      using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
      {
        result = sr.ReadToEnd();
        sr.Close();
        sr.Dispose();
      }

      this.Response = new CcTxResponse(result);

The posting arguments (You should probably use a string builder instead of string.Format() but I didn't realize how long it would be when I started):

private string GetPostUrlArgs()
    {
      //"x_login=YOUR-LOG-IN-ID&x_tran_key=YOUR-TRANSACTION-KEY&x_method=CC&x_type=AUTH_CAPTURE&x_amount=1.00&x_delim_data=TRUE&x_delim_char=|&x_relay_response=FALSE&x_card_num=4111111111111111&x_exp_date=052009&x_test_request=TRUE&x_version=3.1";
      string result = string.Format(
        @"x_login={0}&" +
        @"x_tran_key={1}&" +
        @"x_method={2}&" +
        @"x_type={3}&" +
        @"x_amount={4:F2}&" +
        @"x_delim_data={5}&" +
        @"x_delim_char={6}&" +
        @"x_relay_response={7}&" +
        @"x_card_num={8}&" +
        @"x_exp_date={9}&" +
        @"x_test_request={10}&" +
        @"x_version={11}"
        ,
        x_login, //0
        x_tran_key, //1
        x_method, //2
        x_type, //3
        this.Amount, //4
        BoolToString(x_delim_data), //5
        x_delim_char, //6
        BoolToString(x_relay_response), //7
        HttpUtility.UrlEncode(this.CardNumber), //8
        HttpUtility.UrlEncode(this.ExpirationDate), //9
        BoolToString(this.TestMode), //10
        HttpUtility.UrlEncode(x_version) //11
        );

      if (this.EmailReceipt)
        result += string.Format("&x_email={0}", HttpUtility.UrlEncode(this.Email));
      

      return result;
    }

Man o Man....you are my God...

Thank you so much...i did the same but in html format..

u did well...u r genius....

No, you can do it all in managed code.

Sandbox/Live transaction URL:

private string PostingURL
    {
      get
      {
        if (_testMode)
          return @"https://test.authorize.net/gateway/transact.dll";
        else
          return @"https://secure.authorize.net/gateway/transact.dll";
      }
    }

To post:

public void Post()
    {
      string postURL = this.PostingURL;
      string args = GetPostUrlArgs();
      string result = string.Empty;

      HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(postURL);
      objRequest.Method = "POST";
      objRequest.ContentLength = args.Length;
      objRequest.ContentType = "application/x-www-form-urlencoded";

      StreamWriter myWriter = null;
      try
      {
        myWriter = new StreamWriter(objRequest.GetRequestStream());
        myWriter.Write(args);
      }
      finally
      {
        myWriter.Close();
        myWriter.Dispose();
      }

      HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
      using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
      {
        result = sr.ReadToEnd();
        sr.Close();
        sr.Dispose();
      }

      this.Response = new CcTxResponse(result);

The posting arguments (You should probably use a string builder instead of string.Format() but I didn't realize how long it would be when I started):

private string GetPostUrlArgs()
    {
      //"x_login=YOUR-LOG-IN-ID&x_tran_key=YOUR-TRANSACTION-KEY&x_method=CC&x_type=AUTH_CAPTURE&x_amount=1.00&x_delim_data=TRUE&x_delim_char=|&x_relay_response=FALSE&x_card_num=4111111111111111&x_exp_date=052009&x_test_request=TRUE&x_version=3.1";
      string result = string.Format(
        @"x_login={0}&" +
        @"x_tran_key={1}&" +
        @"x_method={2}&" +
        @"x_type={3}&" +
        @"x_amount={4:F2}&" +
        @"x_delim_data={5}&" +
        @"x_delim_char={6}&" +
        @"x_relay_response={7}&" +
        @"x_card_num={8}&" +
        @"x_exp_date={9}&" +
        @"x_test_request={10}&" +
        @"x_version={11}"
        ,
        x_login, //0
        x_tran_key, //1
        x_method, //2
        x_type, //3
        this.Amount, //4
        BoolToString(x_delim_data), //5
        x_delim_char, //6
        BoolToString(x_relay_response), //7
        HttpUtility.UrlEncode(this.CardNumber), //8
        HttpUtility.UrlEncode(this.ExpirationDate), //9
        BoolToString(this.TestMode), //10
        HttpUtility.UrlEncode(x_version) //11
        );

      if (this.EmailReceipt)
        result += string.Format("&x_email={0}", HttpUtility.UrlEncode(this.Email));
      

      return result;
    }

hi therei'm working in test account....can you help pe me with..

automated recurring billing....!

No, you can do it all in managed code.

Sandbox/Live transaction URL:

private string PostingURL
    {
      get
      {
        if (_testMode)
          return @"https://test.authorize.net/gateway/transact.dll";
        else
          return @"https://secure.authorize.net/gateway/transact.dll";
      }
    }

To post:

public void Post()
    {
      string postURL = this.PostingURL;
      string args = GetPostUrlArgs();
      string result = string.Empty;

      HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(postURL);
      objRequest.Method = "POST";
      objRequest.ContentLength = args.Length;
      objRequest.ContentType = "application/x-www-form-urlencoded";

      StreamWriter myWriter = null;
      try
      {
        myWriter = new StreamWriter(objRequest.GetRequestStream());
        myWriter.Write(args);
      }
      finally
      {
        myWriter.Close();
        myWriter.Dispose();
      }

      HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
      using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
      {
        result = sr.ReadToEnd();
        sr.Close();
        sr.Dispose();
      }

      this.Response = new CcTxResponse(result);

The posting arguments (You should probably use a string builder instead of string.Format() but I didn't realize how long it would be when I started):

private string GetPostUrlArgs()
    {
      //"x_login=YOUR-LOG-IN-ID&x_tran_key=YOUR-TRANSACTION-KEY&x_method=CC&x_type=AUTH_CAPTURE&x_amount=1.00&x_delim_data=TRUE&x_delim_char=|&x_relay_response=FALSE&x_card_num=4111111111111111&x_exp_date=052009&x_test_request=TRUE&x_version=3.1";
      string result = string.Format(
        @"x_login={0}&" +
        @"x_tran_key={1}&" +
        @"x_method={2}&" +
        @"x_type={3}&" +
        @"x_amount={4:F2}&" +
        @"x_delim_data={5}&" +
        @"x_delim_char={6}&" +
        @"x_relay_response={7}&" +
        @"x_card_num={8}&" +
        @"x_exp_date={9}&" +
        @"x_test_request={10}&" +
        @"x_version={11}"
        ,
        x_login, //0
        x_tran_key, //1
        x_method, //2
        x_type, //3
        this.Amount, //4
        BoolToString(x_delim_data), //5
        x_delim_char, //6
        BoolToString(x_relay_response), //7
        HttpUtility.UrlEncode(this.CardNumber), //8
        HttpUtility.UrlEncode(this.ExpirationDate), //9
        BoolToString(this.TestMode), //10
        HttpUtility.UrlEncode(x_version) //11
        );

      if (this.EmailReceipt)
        result += string.Format("&x_email={0}", HttpUtility.UrlEncode(this.Email));
      

      return result;
    }

1) Stop hitting reply with all that code in it. It makes the thread too long
2) This thread is solved and the new question you are asking is a different topic. Start a new thread
3) What is your question about recurring billing? (put this in the NEW thread).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.