【问题标题】:Set Express Checkout method returning an failure in the ack设置 Express Checkout 方法在 ack 中返回失败
【发布时间】:2013-03-05 05:56:28
【问题描述】:

我想在不重定向浏览器的情况下为客户在 paypal 中执行快速结帐流程。我已经写了类似的代码

        string sAPIUser = apiuser;
        string sAPIPassword = password;
        string sAPISignature = "signature";
        string sAPIEndpoint = "https://api-3t.sandbox.paypal.com/nvp";           
        string sAppID = "APP-80W284485P519543T";

        StringBuilder sRequest = new StringBuilder();

        ASCIIEncoding encoding = new ASCIIEncoding();
        string postData = ("&METHOD=SetExpressCheckout");
        postData += ("&VERSION=63.0");
        postData += ("&PAYMENTREQUEST_0_AMT=10.00");
        postData += ("&PAYMENTREQUEST_0_CURRENCYCODE=USD");
        postData += ("&PAYMENTREQUEST_0_PAYMENTACTION=Sale");
        postData += ("CANCELURL=http://www.google.com");
        postData += ("RETURNURL=http://www.google.com");
        byte[] data = encoding.GetBytes(postData);

// 准备网络请求...

   HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(sAPIEndpoint);
   myRequest.Method = "POST";
   myRequest.Headers.Add("X-PAYPAL-SECURITY-USERID", sAPIUser);
   myRequest.Headers.Add("X-PAYPAL-SECURITY-PASSWORD", sAPIPassword);
   myRequest.Headers.Add("X-PAYPAL-SECURITY-SIGNATURE", sAPISignature);
   myRequest.Headers.Add("X-PAYPAL-SERVICE-VERSION", "1.3.0");
   myRequest.Headers.Add("X-PAYPAL-REQUEST-DATA-FORMAT", "NV");
   myRequest.Headers.Add("X-PAYPAL-RESPONSE-DATA-FORMAT", "NV");
   myRequest.Headers.Add("X-PAYPAL-APPLICATION-ID", sAppID);
   myRequest.ContentType = "application/x-www-form-urlencoded";
   myRequest.ContentLength = data.Length;
   // Send the request, read the response
   Stream newStream = myRequest.GetRequestStream();
   newStream.Write(data, 0, data.Length);
   newStream.Close();
   HttpWebResponse response = (HttpWebResponse)myRequest.GetResponse();
   Stream responseStream = response.GetResponseStream();
   Encoding encoding2 = Encoding.GetEncoding("utf-8");
   StreamReader reader = new StreamReader(responseStream, encoding2);
   string theResponse = reader.ReadToEnd();
   theResponse = HttpUtility.HtmlDecode(theResponse);

但我在theResponse 变量中收到失败消息。我在做什么错误。错误是这样的

    TIMESTAMP=2013%2d03%2d05T05%3a55%3a38Z&CORRELATIONID=5c10035aca937&ACK=Failure&VERSION=63%2e0&BUILD=5331358&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Authentication%2fAuthorization%20Failed&L_LONGMESSAGE0=You%20do%20not%20have%20permissions%20to%20make%20this%20API%20call&L_SEVERITYCODE0=Error

我该如何解决这个问题。

【问题讨论】:

  • 在您的问题中留下您的 api 凭据是个坏主意。你可能想删除那些。

标签: paypal payment-gateway


【解决方案1】:

确保您使用的凭据适用于您的沙盒帐户,而不是您的真实帐户。您的代码看起来像是指向沙箱,因此您需要使用沙箱凭据。此外,如果这不是您的全部代码,请确保您没有传递名为“SUBJECT”的变量并使用电子邮件地址填充它。

【讨论】:

  • 我没有使用任何主题变量
  • 10002 错误仅由有限的几个原因引起。您对所指向的端点使用了错误的凭据,端点错误,或者您正在传递主题变量并且您无权对您在主题中传递的帐户执行 API 调用.尝试将您的 API 凭据从您的测试帐户重新复制到您的代码中。
  • 是的,我发现错误我错过了 cancelurl 和 returnurl 的 & 符号
猜你喜欢
  • 2018-10-28
  • 2016-03-15
  • 1970-01-01
  • 1970-01-01
  • 2014-04-14
  • 2019-11-10
  • 2010-12-05
  • 2012-10-22
  • 2010-12-03
相关资源
最近更新 更多