2013-08-27 71 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