繁体   English   中英

我如何从Paypal调用DoDirectPayment API调用

[英]How do I call the DoDirectPayment API call from Paypal

首先,这与桌面应用程序有关,而不与ASP .Net应用程序有关。

我向项目添加了Web参考,并建立了各种数据对象,例如PayerInfo,Address和CreditCard。 问题是,我实际上该如何调用DoDirectPaymentRequest并传入对象? 根据文档,我使用CallerService和ProfileFactory对象,但是我没有这些可用。

任何想法,我怎么从EXE调用API?

问候

在项目中使用Service Reference而不是Web Reference。 您应该创建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);
        }

暂无
暂无

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

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