gpt4 book ai didi

c# - Paypal C# DoExpressCheckOut 身份验证错误 : 10002

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

我花了将近一天的时间试图解决这个问题,如果有任何提示或指导可以让这个该死的东西正常工作,我将不胜感激!我的 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!");
}
}

最佳答案

我就知道这一定很蠢!这就是答案
CustomSecurityHeaderType .. 我将它重新用于 GetDetails 和 DoExpressCheckout 调用。用户/通行证/签名信息在第一次调用时清除,发送到 paypalAAInt.DoExpressCheckoutPayment 时为空。好伤心。

关于c# - Paypal C# DoExpressCheckOut 身份验证错误 : 10002,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20054713/

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