C#Paypal ORIGID失踪

时间:2016-10-28 14:43:56

标签: c# paypal

我有一个可行的解决方案,可以成功处理paypal付款。我已经接受了我的代码,只是稍微修改了一下,以便从paypal返回交易细节。

然而无论使用什么交易ID / PPREF,我使用paypal始终返回result = 7“ORGID missing”。 Paypal文档说这是因为无效的交易ID,但我正在复制和粘贴我的paypal历史中显示的内容。

try
  {
    // PayPal Payments Advanced: USING Hosted Pages
    /////////////////
    // Create the request. if a token hasn't already been created...
    HttpWebRequest req = (HttpWebRequest)WebRequest.Create("https://payflowpro.paypal.com"); // Live paypal


    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
   | SecurityProtocolType.Tls11
   | SecurityProtocolType.Tls12;

    //Set values for paypal flow post
    req.Method = "POST";
    req.ContentType = "application/x-www-form-urlencoded";

    // Build parameter string...
    System.Text.StringBuilder PayPalRequest = new    System.Text.StringBuilder();


    PayPalRequest.Append("ORIGID=").Append(txtPPREF.Text).Append("&");
    PayPalRequest.Append("TRXTYPE=I").Append("&");
    PayPalRequest.Append("TENDER=C").Append("&");
    PayPalRequest.Append("PARTNER=PayPal").Append("&");
    PayPalRequest.Append("VENDOR=myvendor").Append("&");
    PayPalRequest.Append("USER=myuser").Append("&");
    PayPalRequest.Append("PWD=mypassword").Append("&");
    PayPalRequest.Append("VERBOSITY=").Append("HIGH");

    //Send the request to PayPal and get the response
    System.IO.StreamWriter streamOut = new System.IO.StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
    streamOut.Write(PayPalRequest.ToString());
    streamOut.Close();
    System.IO.StreamReader streamIn = new System.IO.StreamReader(req.GetResponse().GetResponseStream());
    string strResponse = streamIn.ReadToEnd();
    streamIn.Close();

    if (strResponse.IndexOf("RESULT=0") > -1)
    {
      //Success
      Console.WriteLine("Paypal Secure Token Request Success: " + strResponse);
    }
    else
    {
      //Failure
      Console.WriteLine("Paypal Secure Token Request Error: " + strResponse.Trim());
    }
  }
  catch (Exception ex)
  {
    Console.WriteLine(ex.Message);
  }
}

0 个答案:

没有答案