【发布时间】:2019-06-12 12:59:30
【问题描述】:
因此,我正在尝试使用我的沙盒帐户实施 PayPal 付款方式进行测试,并且我能找到的所有文档都适用于仍然使用 AppConfig 和/或 Webconfig 的 ASP.NET Core 版本。 我只有 appsettings.json,所以我不知道如何在这里实现这部分
<configuration>
<configSections>
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
</configSections>
<!-- PayPal SDK settings -->
<paypal>
<settings>
<add name="mode" value="sandbox" />
<add name="clientId" value="__CLIENT_ID__" />
<add name="clientSecret" value="__CLIENT_SECRET__" />
</settings>
</paypal>
</configuration>
显示在他们的GitHub page
我尝试将其添加到我的 appsettings.json
"PayPal": {
"mode": "sandbox",
"clientId": "xxxx",
"clientSecret": "xxxx"
}
然后这个
// Get a reference to the config
var config = ConfigManager.Instance.GetProperties();
// Use OAuthTokenCredential to request an access token from PayPal
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var payment = Payment.Get(apiContext, "PAY-0XL713371A312273YKE2GCNI");
这引发了我这个异常
FileNotFoundException: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
抛出它的那一行是var config = ConfigManager.Instance.GetProperties();
【问题讨论】:
标签: asp.net razor asp.net-core paypal