DoExpressCheckoutPayment处理付款然后超时

时间:2012-10-02 16:10:48

标签: c# asp.net paypal paypal-sandbox

从SetExpressCheckOut获取令牌和付款人ID后,我正在寻找实际从用户那里获得的钱。

使用paypal函数向导生成的代码,我正在调用ConfirmPayment函数。

问题是该功能被成功调用并处理来自用户的付款,但后来我收到了超时错误。所以我得到他们的钱,用户得到一个超时页面。不是保持客户的最佳方式。

The operation has timed out

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Net.WebException: The operation has timed out

Source Error: 

Line 313:
Line 314:        //Retrieve the Response returned from the NVP API call to PayPal
**Line 315:        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();**
Line 316:        string result;
Line 317:        using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))

我在第315行得到一个超时,它来自paypal函数的HTTPCall函数。

public string HttpCall(string NvpRequest)// CallNvpServer     {         string url = pendpointurl;

    //To Add the credentials from the profile
    string strPost = NvpRequest + "&" + buildCredentialsNVPString();
    strPost = strPost + "&BUTTONSOURCE=" + HttpUtility.UrlEncode( BNCode );

    HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
    objRequest.Timeout = Timeout;
    objRequest.Method = "POST";
    objRequest.ContentLength = strPost.Length;
    //Retrieve the Response returned from the NVP API call to PayPal
    **HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();** (Line 315)
    string result;
    using (StreamReader sr = new StreamReader(objResponse.GetResponseStream()))
    {
        result = sr.ReadToEnd();
    }

    return result;
}

我觉得这可能与Paypal的服务器有关,但无论哪种方式,它都不起作用,如果用户生活会惹恼用户。你们有没有想过为什么它会突然超时?之前在SetExpressCheckOut中使用相同的HTTPCall并且工作正常。

1 个答案:

答案 0 :(得分:0)

似乎paypalfunctions.cs中有一个变量决定了页面的超时。它设置为5000,我只是将它上升到50000,因为页面加载时间超过5秒并且超时。