授权.NET测试帐户在本地主机上正常工作,但在实际站点上没有

时间:2014-01-23 11:05:14

标签: c# asp.net authorize.net

我正在测试authorize.net付款,它在本地主机支付处理上运行良好。但是当我将它上传到我的带有测试帐户的实际网站时,我会收到错误

**Object reference not set to an instance of an object. at Billing.readHtmlPage(String url)** 

    string[] authorizeServer = readHtmlPage("https://test.authorize.net/gateway/transact.dll").Split('|');
    //Error is Here
    if (authorizeServer[0].ToLower() == "approved" || authorizeServer[0].ToLower() == "1")
    {
    //Process Payment
    }

private String readHtmlPage(string url)
    {
        String result = "";

        //Test Account ID
String strPost =   
"x_login=xxxxx"&x_type=AUTH_CAPTURE&x_method=CC&x_tran_key=xxxxx&x_relay_response=&FALSE&" + "x_card_num=" + ccNum.Text + "&x_exp_date=" + ddl_CCM.SelectedValue + "/" + 

ddl_CCY.SelectedValue +
               "&x_amount=" + lbl_Gtotal.Text +
               "&x_first_name=" + ccFName.Text + "&x_last_name=" + ccLName.Text +
               "&x_address=" + Server.UrlEncode(hf_street.Value) + "&x_city=" + 

hf_city.Value +
               "&x_state=" + hf_state.Value + "&x_zip=" + hf_zip.Value;
        StreamWriter myWriter = null;

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

        try
        {
            myWriter = new StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(strPost);

        }
        catch (Exception e)
        {
            return e.Message;
        }
        finally
        {
            myWriter.Close();
        }

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

            sr.Close();
        }
        return result;
    }

任何帮助都会很好,非常有用,谢谢

0 个答案:

没有答案