DirectPayment方法贝宝问题

DirectPayment方法贝宝问题

问题描述:

我想实现直接付款方式,因为我有我的数据库中的用户的信用卡信息等。这就是我所说的样品:DirectPayment方法贝宝问题

using System; 
using System.Collections.Generic; 
using System.Text; 
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(); 
      /* 
      WARNING: Do not embed plaintext credentials in your application code. 
      Doing so is insecure and against best practices. 
      Your API credentials must be handled securely. Please consider 
      encrypting them for use in any production environment, and ensure 
      that only authorized individuals may view or modify them. 
      */ 

      // Set up your API credentials, PayPal end point, API operation and version. 
      profile.APIUsername = "sdk-three_api1.sdk.com"; 
      profile.APIPassword = "QFZCWN5HZM8VBG7Q"; 
      profile.APISignature = "AVGidzoSQiGWu.lGj3z15HLczXaaAcK6imHawrjefqgclVwBe8imgCHZ"; 
      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

但是,我得到错误“NVPCallerServices”无法找到。我已经参考了paypal_base。有人可以告诉我有什么问题吗?

是啊,这就是薪酬帕尔API :)

样品很可能有点过时。 NVPCallerServices类似乎现在被命名为CallerServices

所以尽量用

CallerServices caller = new CallerServices(); 
+1

更换线

NVPCallerServices caller = new NVPCallerServices(); 

我没想到这样的事情发生,因为我所指的最新文档 - 在他们的网站之一。贝宝是可敬的。不知道客户为什么喜欢这个。 – Jaggu

+0

感觉就像paypal有无数版本的sdks api文档网站和支付产品遍布整个网络......它真的很恶心:) – Jan

+0

贝宝文档的吸 - 我不知道我怎么会想出这个答案出这个答案。 –