2014-10-06 39 views
-1

我正在尝试创建一个程序,用于使用PayPal自适应付款API向用户付款。我试图实现支付用户的隐式付款方式(所以我不必批准每一个)。我目前动态传递的PayPal凭证中使用词典的配置,例如:缺少错误 - 贝宝自适应付款API错误

accountConfig = new Dictionary<string, string>(); 
accountConfig.Add("X-PAYPAL-SECURITY-USERID", "I HAVE PUT MY USERID HERE"); 
accountConfig.Add("X-PAYPAL-SECURITY-SIGNATURE", "MY SIGNATURE HERE" 
accountConfig.Add("X-PAYPAL-SECURITY-PASSWORD", "MY PASSWORD HERE"); 
accountConfig.Add("X-PAYPAL-APPLICATIONID", "APP-80W284485P519543T"); 
accountConfig.Add("X-PAYPAL-REQUEST-DATA-FORMAT", "NV"); 
accountConfig.Add("X-PAYPAL-RESPONSE-DATA-FORMAT", "NV"); 

然后,我在配置付款如下:

AdaptivePaymentsService aps = new AdaptivePaymentsService(accountConfig); 
Receiver receiver = new Receiver { email = "RECEIVER EMAIL", amount = payment.CommissionAmount }; 
List<Receiver> l = new List<Receiver> { receiver }; 
RequestEnvelope re = new RequestEnvelope { errorLanguage = "en_US" }; 
PayRequest payRequest = new PayRequest(
    re, 
    "SERVICE", 
    "http://cancelUrl", 
    "USD", 
    new ReceiverList(l), 
    "http://returnUrl"); 
payRequest.senderEmail = "I HAVE PUT MY USERID HERE"; 
aps.Pay(payRequest); 

根据该文件,在隐含付款部分下,您应该能够使用API​​调用者的帐户电子邮件作为发件人电子邮件,这被认为是隐式付款。但是,我应该在哪里做这件事?如果我不喜欢它上面,将其添加到payRequest,我得到了以下错误消息MissingCredentialException

Missing credentials for 

没有其他的信息。我究竟做错了什么?

编辑:这里是异常的详细信息:

PayPal.Exception.MissingCredentialException was unhandled 
    HResult=-2146233088 
    Message=Missing credentials for 
    Source=PayPalCoreSDK 
    StackTrace: 
     at PayPal.NVP.PlatformAPICallPreHandler..ctor(Dictionary`2 config, String rawPayload, String serviceName, String method, String apiUserName, String accessToken, String accesstokenSecret) 
     at PayPal.AdaptivePayments.AdaptivePaymentsService.Pay(PayRequest payRequest, String apiUserName) 
     at PayPal.AdaptivePayments.AdaptivePaymentsService.Pay(PayRequest payRequest) 
     at MyApp.PayPalAdapter.PayPerson(Person person, Payment payment, String returnUrl, String cancelUrl) in c:\Projects\MyApp\MyApp\PayPalAdapter.cs:line 50 
     at MyApp.Scripts.ManagePersonPaymentsJob.PayPerson(Person person, Payment payment) in c:\Projects\MyApp\MyApp.Scripts\ManagePersonPaymentsJob.cs:line 71 
     at MyApp.Scripts.ManagePersonPaymentsJob.Run() in c:\Projects\MyApp\MyApp.Scripts\ManagePersonPaymentsJob.cs:line 60 
     at MyApp.Scripts.Program.Main(String[] args) in c:\Projects\MyApp\MyApp.Scripts\Program.cs:line 47 
     at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 
    InnerException: 
+0

你有没有看过或阅读完整的文档[自适应付款Paypal API](https://developer.paypal.com/docs/classic/adaptive-payments/integration-guide/APIntro/) – MethodMan 2014-10-06 21:22:14

+0

需要查看原始请求和响应,包括头文件。我这样做很多,并没有任何问题,所以你必须在某个地方失去一些东西。我会挖掘一个请求,以便我们可以比较。 – 2014-10-06 22:07:23

+0

@DJKRAZE我读过不少。如果有什么我明显错过的,你能指出吗? – muttley91 2014-10-07 14:16:57

回答

0

的问题是,我是不正确的做我的凭据,基本上是由于各种不同的例子,我在网上找到。

此外,我发现THIS指南,结果是最有帮助的(并为我工作)。我不知道为什么我没有早点绊倒。希望它能帮助未来的某个人。