简体   繁体   English

我如何从Paypal调用DoDirectPayment API调用

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

First of all, this relates to a desktop application rather than an ASP .Net application. 首先,这与桌面应用程序有关,而不与ASP .Net应用程序有关。

I have added a web reference to my project, and have built up the various data objects such as PayerInfo, Address and CreditCard. 我向项目添加了Web参考,并建立了各种数据对象,例如PayerInfo,Address和CreditCard。 The problem is though, how do i actually call the DoDirectPaymentRequest and pass in the objects? 问题是,我实际上该如何调用DoDirectPaymentRequest并传入对象? According to the documentation, i use a CallerService and ProfileFactory object, but i do not have these available to me. 根据文档,我使用CallerService和ProfileFactory对象,但是我没有这些可用。

Any ideas how i call the API from an EXE? 任何想法,我怎么从EXE调用API?

Regards 问候

Use Service Reference instead of Web Reference in your project. 在项目中使用Service Reference而不是Web Reference。 You should create an instance of PayPalAPIInterfaceClient or PayPalAPIAAInterfaceClient . 您应该创建PayPalAPIInterfaceClientPayPalAPIAAInterfaceClient的实例。 After that you'll have an ability to call DoDirectPayment. 之后,您将可以调用DoDirectPayment。

Example: 例:

        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