【发布时间】:2014-12-01 05:34:06
【问题描述】:
我正在尝试创建一个程序,该程序将使用 PayPal Adaptive Payments API 向用户付款。我正在尝试实施付费用户的隐式付款方式(因此我不必批准每个人)。我目前正在使用 Dictionary 进行配置动态传递 PayPal 凭据,如下所示:
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:
【问题讨论】:
-
您是否看过或阅读了整个文档Adaptive Payment Paypal API
-
需要查看您收到的原始请求和响应,包括标头。我经常这样做并且没有任何问题,所以你一定在某个地方遗漏了一些东西。我会挖掘一个请求,以便我们进行比较。
-
@DJKRAZE 我已经读过不少了。如果有什么我明显遗漏的地方,你能指出来吗?
-
@AndrewAngell 如果您有任何我可以查看的示例代码,那会很有帮助。我正在尝试从我的请求中获取请求,但我似乎无法捕获它......
-
我使用 PHP 和 XML,所以我的示例可能对您没有多大用处。但是,如果您可以发布您的请求示例,我可以查看并尝试发现您的问题。提出您的请求应该很容易。在某些时候,您必须将它作为一个值传递给 PayPal 的 HTTP 请求。只需将其保存到日志文件或其他文件中即可。
标签: c# paypal paypal-sandbox paypal-adaptive-payments