PayPal C#DoExpressCheckOut身份验证错误:10002

时间:2013-11-18 18:08:58

标签: c# paypal express-checkout

我花了将近一天时间试图解决这个问题,并希望得到任何提示或指导让这个该死的东西起作用! 我的SetExpressCheckOut和GetExpressCheckOut函数正常工作,但我从PayPal获取对象..

但最后一步DoExpressCheckOut失败并显示以下错误消息:“您没有权限进行此API调用”因此它无法成为我的凭据,因为我在执行Set和Get调用时使用了相同的内容。

我有标准的PayPal帐户(不是专业版) 我正在使用实时终点:https://api-3t.paypal.com/2.0/ 并通过API用户名/密码/签名

连接

我到处寻找是否有特定的API权限可以在PayPal上配置,但我没有运气......

这是代码。我很感激帮助......

public bool DoExpressCheckout(string token)
        {
            var getDetailsResponse = new GetExpressCheckoutDetailsResponseType();
            var getDetailsRequestType = new GetExpressCheckoutDetailsRequestType();
            var getDetailsReq = new GetExpressCheckoutDetailsReq();
            getDetailsRequestType.Version = GetVersionOrDefault();
            getDetailsRequestType.Token = token;
            getDetailsReq.GetExpressCheckoutDetailsRequest = getDetailsRequestType;

            var requestType = new DoExpressCheckoutPaymentRequestType();
            requestType.Version = GetVersionOrDefault(); // 109

             try
            {
                var type2 = new CustomSecurityHeaderType
                {
                    Credentials = new UserIdPasswordType()
                    {
                        Username = ConfigurationManager.AppSettings["PAYPAL_API_USERNAME"],
                        Password = ConfigurationManager.AppSettings["PAYPAL_API_PASSWORD"],
                        Signature = ConfigurationManager.AppSettings["PAYPAL_API_SIGNATURE"],
                    }
                };

                var paypalAAInt = new PayPalAPIAAInterfaceClient();

                getDetailsResponse = paypalAAInt.GetExpressCheckoutDetails(ref type2, getDetailsReq);
                if (getDetailsResponse.Errors != null && getDetailsResponse.Errors.Length > 0)
                {
                    throw new Exception("Exception(s) occured when calling PayPal. First exception: " +
                        getDetailsResponse.Errors[0].LongMessage + getDetailsResponse.Errors.Length.ToString());
                }

                if (getDetailsResponse.Ack == AckCodeType.Success)
                {
                     var payReq = new DoExpressCheckoutPaymentReq()
                        {
                            DoExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType()
                            {
                                Version = GetVersionOrDefault(), //109
                                DoExpressCheckoutPaymentRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType()
                                {
                                    Token = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails.Token,
                                    PaymentAction = PaymentActionCodeType.Sale,
                                    PaymentActionSpecified = true,
                                    PayerID = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails.PayerInfo.PayerID,
                                    PaymentDetails = new PaymentDetailsType[] {
                                        new PaymentDetailsType()
                                        {
                                            OrderTotal = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails.PaymentDetails[0].OrderTotal

                                        }
                                    }
                                }
                            }
                        };

                     var resp = paypalAAInt.DoExpressCheckoutPayment(ref type2, payReq);
                     if (resp.Errors != null && resp.Errors.Length > 0)
                     {
                         // ######### IT DIES HERE ################3
                         throw new Exception("Exception(s) occured when calling PayPal. First exception: " +
                             resp.Errors[0].LongMessage + resp.Errors.Length.ToString());
                     }

                     if (resp.Ack == AckCodeType.Success)
                         return true;
                     }
                     else
                         return false;

                return false;
            }


            catch (Exception ex)
            {
                Logger.LogError(ex, null, null, "Problem in PayPal DoExpressCheckOut function");
                throw new Exception("There was a problem processing your request. You have not been charged!");
            }
        }

1 个答案:

答案 0 :(得分:1)

我知道它必须是愚蠢的东西!这是答案
CustomSecurityHeaderType ..我正在重复使用GetDetails和DoExpressCheckout调用。用户/通行证/签名信息在第一次通话时清除,当发送到paypalAAInt.DoExpressCheckoutPayment时它是空的。好悲伤。

相关问题