2011-09-23 139 views
0

我正在嘗試在我的網站中使用DoDirectPayment方法。底層連接已關閉:發送時出現意外錯誤

這就是我所指的樣本:

using com.paypal.sdk.services; 
using com.paypal.sdk.profiles; 
using com.paypal.sdk.util; 
using com.paypal.soap.api; 

namespace ASPDotNetSamples 
{ 
    public class DoDirectPayment 
    { 
     public DoDirectPayment() 
     { 
     } 
     public string DoDirectPaymentCode(string paymentAction, string amount, string creditCardType, string creditCardNumber, string expdate_month, string cvv2Number, string firstName, string lastName, string address1, string city, string state, string zip, string countryCode, string currencyCode) 
     { 

      com.paypal.soap.api.DoDirectPaymentReq req = new com.paypal.soap.api.DoDirectPaymentReq(); 


      NVPCallerServices caller = new NVPCallerServices(); 
      IAPIProfile profile = ProfileFactory.createSignatureAPIProfile(); 

      // Set up your API credentials, PayPal end point, API operation and version. 
      profile.APIUsername = "sdk-three_api1.sdk.com"; 
      profile.APIPassword = "xxxxxxxxxxxxx"; 
      profile.APISignature = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; 
      profile.Environment = "sandbox"; 
      caller.APIProfile = profile; 

      NVPCodec encoder = new NVPCodec(); 
      encoder["VERSION"] = "51.0"; 
      encoder["METHOD"] = "DoDirectPayment"; 

      // Add request-specific fields to the request. 
      encoder["PAYMENTACTION"] = paymentAction; 
      encoder["AMT"] = amount; 
      encoder["CREDITCARDTYPE"] = creditCardType; 
      encoder["ACCT"] = creditCardNumber; 
      encoder["EXPDATE"] = expdate_month; 
      encoder["CVV2"] = cvv2Number; 
      encoder["FIRSTNAME"] = firstName; 
      encoder["LASTNAME"] = lastName; 
      encoder["STREET"] = address1; 
      encoder["CITY"] = city; 
      encoder["STATE"] = state; 
      encoder["ZIP"] = zip; 
      encoder["COUNTRYCODE"] = countryCode; 
      encoder["CURRENCYCODE"] = currencyCode; 

      // Execute the API operation and obtain the response. 
      string pStrrequestforNvp = encoder.Encode(); 
      string pStresponsenvp = caller.Call(pStrrequestforNvp); 

      NVPCodec decoder = new NVPCodec(); 
      decoder.Decode(pStresponsenvp); 
      return decoder["ACK"]; 

     } 
    } 
} 

這是鏈接:

https://cms.paypal.com/cms_content/US/en_US/files/developer/nvp_DoDirectPayment_cs.txt

當我通過適當的參數,並嘗試運行代碼我得到這個錯誤:「底層連接已關閉:發送時發生意外錯誤。「 on line:

pp_response = (DoDirectPaymentResponseType)caller.Call("DoDirectPayment", pp_Request); 

SOAP服務調用在dll中。任何人都可以指導我發生了什麼以及如何解決它?

+1

隱藏你的用戶名和密碼! – alex

+0

@亞歷克斯:哪一個?這是來自網站的樣本!不是我的用戶名和密碼。 – Jaggu

+0

對不起,我以爲他們是你的私人API密鑰。 – alex

回答

5
+0

您提供的鏈接不包含任何「直接付款」的名稱。他們是否停止支持它? – Jaggu

+0

@Jaggu如果你花時間看看網站你會發現api文檔,我已經更新了一個鏈接的答案,希望它有幫助,並且你明白你需要創建一個帳戶才能夠測試api。 – Joakim

+0

感謝Joakim。我仍然無法找到它。但你的第三個鏈接幫助我。 – Jaggu

相關問題