gpt4 book ai didi

c# - 如何从 Paypal 调用 DoDirectPayment API 调用

转载 作者:太空宇宙 更新时间:2023-11-03 16:11:45 27 4
gpt4 key购买 nike

首先,这涉及桌面应用程序而不是 ASP .Net 应用程序。

我已经为我的项目添加了一个 Web 引用,并构建了各种数据对象,例如 PayerInfo、Address 和 CreditCard。但问题是,我实际上如何调用 DoDirectPaymentRequest 并传入对象?根据文档,我使用了 CallerService 和 ProfileFactory 对象,但我没有这些可用的对象。

关于如何从 EXE 调用 API 有什么想法吗?

问候

最佳答案

在您的项目中使用服务引用而不是网络引用。您应该创建 PayPalAPIInterfaceClientPayPalAPIAAInterfaceClient 的实例。之后,您将能够调用 DoDirectPayment。

示例:

        DoDirectPaymentResponseType result;
using (_client = new PayPalAPIAAInterfaceClient())
{

DoDirectPaymentRequestType pp_Request = new DoDirectPaymentRequestType();
pp_Request.Version = _version;
pp_Request.DoDirectPaymentRequestDetails = new DoDirectPaymentRequestDetailsType();
pp_Request.DoDirectPaymentRequestDetails.IPAddress = ipAddress;
pp_Request.DoDirectPaymentRequestDetails.CreditCard = new CreditCardDetailsType();
pp_Request.DoDirectPaymentRequestDetails.CreditCard.CreditCardNumber = CCNum;

// ..FILL DATA

// NOTE: The only currency supported by the Direct Payment API at this time is US dollars (USD).
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.currencyID = CurrencyCodeType.USD;
pp_Request.DoDirectPaymentRequestDetails.PaymentDetails.OrderTotal.Value = amountOfUSD;

var dp = new DoDirectPaymentReq
{
DoDirectPaymentRequest = pp_Request
};

var credentials = new CustomSecurityHeaderType
{
Credentials = new UserIdPasswordType
{
Username = _username,
Password = _password,
Signature = _signature,
AppId = ApiId
}
};

result = _client.DoDirectPayment(ref credentials, dp);
}

关于c# - 如何从 Paypal 调用 DoDirectPayment API 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12147720/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com