2013-08-27 69 views
0

我正在开发一种机制,即一次将资金转移到PayPal的多个账户中。它通过以下代码使用对MassPay API的调用(凭据是混乱的)。MassPay PayPal API安全错误

 public static string TestMassPay() 
    { 
     //X509Certificate x509 = new X509Certificate("Certifcate Description"); 
     X509Certificate x509 = null; 
     HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(URL); 
     string postData = "METHOD=MassPay&EMAILSUBJECT=You+have+money!&RECEIVERTYPE=EmailAddress&CURRENCYCODE=USD&L_EMAIL0=mr.kaleemullah%40gmail.com&L_Amt0=1.00&L_UNIQUEID0=&L_NOTE0=&USER=ali_api1.sevdotcom.ae&PWD=TLPPC43GDDM9DKZ9&SIGNATURE=Are9-8DOFiZXJtjX-8nkuOpzmTl2AQTy0kHQ5oey6i4QxuaeJ0z-Amhk&VERSION=1&SOURCE=1"; 

     objRequest.Timeout = TimeOut; 

     objRequest.Method = "POST"; 

     objRequest.ContentLength = postData.Length; 

     if (null != x509) 
     { 
      objRequest.ClientCertificates.Add(x509); 

     } 

     using (StreamWriter myWriter = new StreamWriter(objRequest.GetRequestStream())) 
     { 
      myWriter.Write(postData); 

     } 

     using (WebResponse response = objRequest.GetResponse()) 
     { 

      using (StreamReader sr = new StreamReader(response.GetResponseStream())) 
      { 
       string strResponse = sr.ReadToEnd(); 
       NameValueCollection qscoll = HttpUtility.ParseQueryString(strResponse); 
       return strResponse; 
      } 
     } 
    } 

它给了我下面我用Google搜索了错误很好,但没有发现任何错误

&L_LONGMESSAGE0=Security%20header%20is%20not%20valid 

我想我需要提供有关我无法在文档中找到任何内容的安全证书的详细信息。 谢谢

回答

0

你正在通过SUBJECT; SUBJECT定义了代表(第三方访问)进行API调用的帐户。 “你有钱!”不是有效的帐户,并没有授予您任何权限,因此存在安全错误。

您可能想用EMAILSUBJECT代替;有关更多详细信息,请参见MassPay NVP API document

+0

我也使用EMAILSUBJECT不是主题属性,请检查我认为X509Certificate x509 = null;应该初始化,但我不知道哪个值 – LojiSmith

+0

我会推荐使用http://paypal.github.io/#merchant的.Net SDK - 它有一个示例,向您演示如何执行MassPay:https: //github.com/paypal/merchant-sdk-dotnet/blob/master/Samples/PayPalAPISample/APICalls/MassPay.aspx.cs – Praveen