Paypal NVP API - 不断收到错误81002

And*_*ree 8 php paypal

我是PayPal API的新手,我在使用PHP中的CURL调用SetExpressCheckout时遇到了麻烦.就我而言,我已经正确设置了所有内容,但我一直收到81002错误"指定的方法不受支持".

代码片段如下.我从这里获得了CA Root证书文件.

<?php

$paypal_data = array(
    'USER' => urlencode('andree_1272823561_biz_api1.gmail.com'),
    'PWD' => urlencode('1272823576'),
    'SIGNATURE' => urlencode('Am1t0wiu2tv7VwZ5ebdeY9zv1GF6Ad0PFz-qTGFFf7vbWU6ee4bxy8KL'),
    'VERSION' => urlencode('52.0'),
    'PAYMENTACTION' => urlencode('Sale'),
    'METHOD' => urlencode('SetExpressCheckout'),
    'AMT' => urlencode('52.00'),
    'RETURNURL' => urlencode('get_express_checkout_details.php'),
    'CANCELURL' => urlencode('index.php')
);

$url = 'https://api-3t.sandbox.paypal.com/nvp?' . http_build_query($paypal_data);
$curl = curl_init();

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');

$result = curl_exec($curl);
curl_close($curl);
parse_str($result, $result);
?>

<pre>Data sent: <?php print_r($paypal_data); ?></pre>
<pre>Result: <?php print_r($result); ?></pre>
Run Code Online (Sandbox Code Playgroud)

当我运行代码时,输​​出如下:

Data sent: Array
(
    [USER] => andree_1272823561_biz_api1.gmail.com
    [PWD] => 1272823576
    [SIGNATURE] => Am1t0wiu2tv7VwZ5ebdeY9zv1GF6Ad0PFz-qTGFFf7vbWU6ee4bxy8KL
    [VERSION] => 52.0
    [PAYMENTACTION] => Sale
    [METHOD] => SetExpressCheckout
    [AMT] => 52.00
    [RETURNURL] => get_express_checkout_details.php
    [CANCELURL] => index.php
)

Result: Array
(
    [ACK] => Failure
    [L_ERRORCODE0] => 81002
    [L_SHORTMESSAGE0] => Unspecified Method
    [L_LONGMESSAGE0] => Method Specified is not Supported
    [L_SEVERITYCODE0] => Error
)
Run Code Online (Sandbox Code Playgroud)

谁知道可能是什么问题?

此致,Andree.

des*_*pot 2

我没有使用 PHP API,但使用回调 API (java) 时遇到了相同的 81002 错误,当某些参数丢失或格式错误时,我得到了这个错误。

I don't know if you solved the issue, but my advice would be checking which of the parameters are requred for the SetExpressCheckout (API Reference). And than if you have set those, check if the limitations part of the description of the parameter is satisfied.

Sadly but they sometimes throw inappropriate errors (or errors that the developer can't quite understand). On the other side I usually get most of my responses answered on their forum. If in "trouble" you can also write a private message to the paypal team member on shift (or to a person that has already solved your problem).

Hope that helped!
Despot