我想最终建立贝宝付款。不过,第一步是玩一玩。我的快速起步失败了!
https://github.com/paypal/PayPal-NET-SDK/wiki/Quick-Start
显示代码示例。它解释说,首先,我需要下载
PayPal .NET SDK
通过Nuget打包。这很好,我在.NET框架上(不是核心)。我安装它。
第2阶段给出了一个完整的例子。我将一些Paypal配置设置添加到App.CONFIG文件中。多恩
第三阶段是出错的地方。我在我的C类中引用paypal.api。
我的代码的相关部分是
using PayPal.Api;
using System.Collections.Generic;
namespace TestProj.Payment
{
public class PaypalGateway
{
public void Sandbox()
{
var config = ConfigManager.Instance.GetProperties();// this is the fault
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
config
始终有0个实例
我的项目有一个具有正确值的app.config文件
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="paypal" type="PayPal.SDKConfigHandler, PayPal" />
</configSections>
<paypal>
<settings>
<add name="mode" value="sandbox" />
<add name="clientId" value="***" />
<add name="clientSecret" value="***" />
</settings>
</paypal>
如果我重命名我的
App.config
文件到
blah.nonsense
然后同样的问题发生了。就好像API在寻找一个没有正确配置的文件。