我正在嘗試使用PayPal API執行一些付款操作,並且我將CertificateFile屬性設置爲我的證書文件的位置時出現致命異常。Paypal API在指向我的證書文件時摔倒了
相關的代碼如下:
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屬性設置爲什麼,您都會遇到致命異常。
幾個問題:
- 我在哪裏可以找到貝寶API中的IAPIProfile類的文檔,特別是文檔中的
CertificateFile
財產 - 如果我不應該把路給我證書文件在這個位置,我該怎麼辦?
只是爲了確認,MyTestCertificate.txt
添加到我的解決方案和Copy to Output Directory
設置爲Copy Always
。
例外全文如下:
{"Exception of type 'com.paypal.sdk.exceptions.FatalException' was thrown."}
堆棧跟蹤看起來是這樣的:
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的它記錄錯誤像這樣:
20 Jul 2012 12:39:11 FATAL [FatalException] com.paypal.sdk.exceptions.FatalException: Exception of type 'com.paypal.sdk.exceptions.FatalException' was thrown.
謝謝
什麼是例外+跟蹤 – Woot4Moo 2012-07-20 11:15:15
更新,出現異常的問題+追查 – JMK 2012-07-20 11:21:29
是否有內部異常? – Rafal 2012-07-20 11:26:43