我正在尝试创建一个使用PayPal Adaptive Payments API向用户付费的程序。我正在尝试实施支付用户的隐式支付方式(所以我不必批准每一个)。我目前正在使用字典为配置动态传递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:
答案 0 :(得分:0)
问题是我的身份证明不正确,基本上是由于我在网上找到的各种不同的例子。
此外,我发现THIS指南最终是最有帮助的(并为我工作)。我不确定为什么我没有及早发现这一点。希望它能帮助将来的某个人。