0

我从贝宝沙盒中获得身份验证失败,我将请求作为名称值对发送到贝宝..

代码如下:`

final String PayPalConstants.ENCODE_TYPE="UTF-8";
final StringBuffer encodedStringBuffer = new StringBuffer();
encodedStringBuffer.append("X-PAYPAL-SECURITY-USERID=" + URLEncoder.encode(getAdaptivePaymentUserName(), PayPalConstants.ENCODE_TYPE) + "&");
    encodedStringBuffer.append("X-PAYPAL-SECURITY-PASSWORD=" + URLEncoder.encode(getAdaptivePaymentPassword(), PayPalConstants.ENCODE_TYPE) + "&");
    if (!isUseCert()) {
        encodedStringBuffer.append("X-PAYPAL-SECURITY-SIGNATURE=" + URLEncoder.encode(getAdaptivePaymentSignature(), PayPalConstants.ENCODE_TYPE) + "&");
    }
    // encodedStringBuffer.append("BUTTONSOURCE=" +
    // URLEncoder.encode(PayPalConstants.BUTTONSOURCE,
    // PayPalConstants.ENCODE_TYPE) + "&");
    encodedStringBuffer.append("X-PAYPAL-REQUEST-DATA-FORMAT=" + URLEncoder.encode("NV", PayPalConstants.ENCODE_TYPE) + "&");
    encodedStringBuffer.append("X-PAYPAL-RESPONSE-DATA-FORMAT=" + URLEncoder.encode("NV", PayPalConstants.ENCODE_TYPE) + "&");
    encodedStringBuffer.append("X-PAYPAL-APPLICATION-ID=" + URLEncoder.encode(getAdaptivePaymentAppId(), PayPalConstants.ENCODE_TYPE) + "&");

                final PostMethod httpPost = new PostMethod(this.adaptivePaymentRestURL.getPath());

    httpPost.setRequestEntity(new StringRequestEntity(encodedStringBuffer.toString(), "text/html", PayPalConstants.ENCODE_TYPE));
final int result = this.adaptivePaymentHttpClient.executeMethod(httpPost);
                    if (result == 200) {
            response = httpPost.getResponseBodyAsString();
}

响应值如下:

<?xml version='1.0' encoding='UTF-8'?>
<ns3:FaultMessage xmlns:ns3="http://svcs.paypal.com/types/common" xmlns:ns2="http://svcs.paypal.com/types/ap">
<responseEnvelope>
<timestamp>2013-08-21T00:20:51.291-07:00</timestamp>
<ack>Failure</ack>
<correlationId>e3325********</correlationId>
<build>694****</build>
</responseEnvelope>
<error>
**<errorId>520003</errorId>**
<domain>PLATFORM</domain>
<subdomain>Application</subdomain>
<severity>Error</severity>
<category>Application</category>
<message>Authentication failed. API credentials are incorrect.</message>
</error>
</ns3:FaultMessage>

所以谁能告诉我我做错了什么?输入字符串缓冲区是否是此 Web 服务的错​​误数据类型。请帮帮我..我对此完全感到困惑。

提前致谢。

4

1 回答 1

0

API 凭证作为 HTTP 标头(https://developer.paypal.com/webapps/developer/docs/classic/api/gs_PayPalAPIs/#headers)或https://developer.paypal.com/webapps/developer/docs /classic/api/gs_PayPalAPIs/#payload。您似乎混淆了两者 - X-PAYPA1-* 是 HTTP 标头名称。

于 2013-08-29T10:09:07.470 回答