PayPal C# DoExpressCheckOut 身份验证错误:10002
Posted
技术标签:
【中文标题】PayPal C# DoExpressCheckOut 身份验证错误:10002【英文标题】:PayPal C# DoExpressCheckOut Authentication Error: 10002 【发布时间】:2013-12-02 00:17:24 【问题描述】:我已经花了将近一天的时间试图解决这个问题,希望能提供任何提示或指导来让这该死的东西正常工作! 我的 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】:我知道这一定很愚蠢!这是答案 CustomSecurityHeaderType.. 我将它用于 GetDetails 和 DoExpressCheckout 调用。用户/通行证/签名信息在第一次调用时被清除,当发送到 paypalAAInt.DoExpressCheckoutPayment 时它是空的。好悲伤。
【讨论】:
这让我省了一些挫败感。 Tnx!以上是关于PayPal C# DoExpressCheckOut 身份验证错误:10002的主要内容,如果未能解决你的问题,请参考以下文章