简体   繁体   English

找不到PayPal API QueryParameters

[英]PayPal API QueryParameters not found

屏幕截图

I copied and pasted a section from here (You will have to scroll to the top - click C# on the right and scroll down/refresh) and have installed the PayPal API into the project Install-Package PayPal but QueryParameters is not found - is there a second part or something I should already know about? 我从此处复制并粘贴了一个部分(您必须滚动到顶部-单击右侧的C#,然后向下滚动/刷新),并将PayPal API Install-Package PayPal到项目Install-Package PayPal但是找不到QueryParameters是否存在第二部分或我应该已经知道的一些内容?


Code from site 来自站点的代码

OAuthTokenCredential tokenCredential =new OAuthTokenCredential("<CLIENT_ID>", "<CLIENT_SECRET>");

string accessToken = tokenCredential.GetAccessToken();
var parameters = new QueryParameters();
parameters.SetCount("10");

PaymentHistory paymentHistory = Payment.Get(accessToken, parameters);

AFAICS are the PayPal QueryParameters part of PayPal.Util . PayPal.UtilPayPal.Util的PayPal QueryParameters部分。 Please try if you can access this namespace. 请尝试是否可以访问此命名空间。

If not you can add it manually (as a class) using this link . 如果不是,您可以使用此链接手动(作为一个类)添加它。

You should also consider downloading the whole SDK if the above does not work using nuget . 如果上述方法不能通过nuget使用,则还应考虑下载整个SDK。

Some of the language tabs on the PayPal REST API Reference page have sample code that is woefully out-of-date (and in this case, completely incorrect since Payment.Get(...) is intended to return a single payment resource, not a list). PayPal REST API参考”页面上的某些语言选项卡上的示例代码已过时(在这种情况下,由于Payment.Get(...)用于返回单个payment资源,而不是返回单个payment资源,因此完全不正确Payment.Get(...)一个列表)。 The PayPal docs team is well aware of this issue and will be removing the language tabs in the near future in favor of the SDKs providing their own samples via GitHub. 贝宝(PayPal)文档团队非常了解此问题,并将在不久的将来删除语言标签,以支持SDK通过GitHub提供自己的示例。

I'd recommend checking out the PayPal .NET SDK samples project on GitHub, which does a much better job of showing you not only the code, but displaying the request/response details for each API operation. 我建议您查看GitHub上的PayPal .NET SDK示例项目 ,这样做不仅可以向您显示代码,而且还可以显示每个API操作的请求/响应详细信息,因此效果更好。

Regarding getting the payment history, you'll want to do the following using the PayPal .NET SDK: 关于获取付款历史记录,您将需要使用PayPal .NET SDK执行以下操作:

using PayPal.Api;

// Authenticate with PayPal and setup the APIContext object.
var config = ConfigManager.Instance.GetProperties();
var accessToken = new OAuthTokenCredential(config).GetAccessToken();
var apiContext = new APIContext(accessToken)
{
    Config = config
};

// Get the payment history
var paymentHistory = Payment.List(apiContext, count: 10, startIndex: 5);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM