我正在尝试使用 Paypal API 捕获一些付款,并且在将 CertificateFile 属性设置为证书文件位置的代码行上出现致命异常。
相关代码如下:
using com.paypal.sdk.profiles;
using com.paypal.sdk.services;
using com.paypal.sdk.util;
IAPIProfile profile = ProfileFactory.createSignatureAPIProfile();
profile.CertificateFile = @"~\MyTestCertificate.txt";
深入了解异常详细信息并没有给我更多信息,它或多或少只是确认确实抛出了致命异常。
像这样省略波浪号和反斜杠会引发相同的错误:
profile.CertificateFile = @"MyTestCertificate.txt";
我想也许我需要文件的内容,而不是位置,所以我尝试了以下但得到了同样的错误:
profile.CertificateFile = new StreamReader(@"MyTestCertificate.txt").ReadToEnd().ToString();
似乎无论您将 CertificateFile 属性设置为什么,都会出现致命异常。
几个问题:
- 我在哪里可以找到有关 Paypal API 中 IAPIProfile 类的文档,特别是该
CertificateFile
属性的文档 - 如果我不应该将证书文件的路径放在这个位置,我应该怎么做?
只是为了确认,MyTestCertificate.txt
已添加到我的解决方案中并Copy to Output Directory
设置为Copy Always
.
异常文本如下:
{“'com.paypal.sdk.exceptions.FatalException' 类型的异常被抛出。”}
StackTrace 看起来像这样:
at com.paypal.sdk.profiles.SignatureAPIProfile.set_CertificateFile(String value)
at MyProject_Payment_Processing.Paypal.DoCaptureCode(String authorization_id, String amount) in C:\Users\JMK\documents\visual studio 2010\Projects\MyProject Payment Processing\MyProject Payment Processing\Paypal.cs:line 16
at MyProject_Payment_Processing.Program.Main(String[] args) in C:\Users\JMK\documents\visual studio 2010\Projects\MyProject Payment Processing\MyProject Payment Processing\Program.cs:line 15
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.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Paypal API 使用 Log4Net 记录错误,如下所示:
2012 年 7 月 20 日 12:39:11 FATAL [FatalException] com.paypal.sdk.exceptions.FatalException:抛出了“com.paypal.sdk.exceptions.FatalException”类型的异常。
谢谢