Paypal NVP API - Hata 81.002 alıyorum tutun

3 Cevap php

I am new to PayPal API, and I'm having trouble calling SetExpressCheckout using CURL in PHP. I have set everything correctly, as far as I'm concerned, but I kept getting an 81002 error "Method Specified is not Supported".

Kod parçacığını aşağıda. I here adlı CA Kök sertifika dosyası var.

<?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>

Ben kodu çalıştırdığınızda, çıktı şudur:

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
)

Herkes ne sorun olabilir bilir?

Saygılar, Andree.

3 Cevap

Eğer urlencode + http_build_query kullandığınızda sorunudur. Çift kodlama ile sona erecek ve PayPal bilgi bazı reddeder.

Ben PHP API kullanarak değilim, ama ben geri arama API (Java) kullanarak aynı 81002 hata koştu ve bazı parametrelerin eksik veya kötü format vardı ya ben aldım.

Eğer sorunu çözecekse ben bilmiyorum, ama benim tavsiyem SetExpressCheckout için requred olan parametrelerin hangilerinin kontrol olacaktır (API Reference). Bu set varsa parametresinin açıklaması limitations bir parçasıdır memnun olduğunu ve eğer, kontrol dışında.

Ne yazık ki, ama bazen uygunsuz hataları (veya geliştirici oldukça anlayamıyorum bu hataları) atmak. Diğer tarafta ben genellikle benim tepkilerin çoğu kendi forumunda cevap olsun. "Sorun" sen de vardiya (veya zaten sorunu çözmüş bir kişi) hakkında paypal ekip üyesi için bir özel mesaj yazabilirsiniz.

Hope that helped!
Despot

I had this problem and in the end discovered that it was a problem with getting the parameters transmitted at all. I was using the following kind of code to pass the parameters (as shown in various examples on the net for PayPal):

   http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')

: Ben bu değişti

   http.form_data = {"q" => "ruby", "lang" => "en"}

bana bilinmeyen bir yöntem hatası vererek durdu (ve :-) diğer hatalar üzerine taşındı

The Ruby code below worked for me (I have removed the return URLs though). The username etc are standard sandbox ones.

# http://www.ensta-paristech.fr/~diam/ruby/online/ruby-doc-stdlib/libdoc/net/http/rdoc/classes/Net/HTTP.html
# https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECGettingStarted

require 'net/https'
require 'uri'

uri = URI('https://api-3t.sandbox.paypal.com/nvp')

request_object = Net::HTTP::Post.new(uri.path)

request_object.form_data = {
'USER'=>'sdk-three_api1.sdk.com', # Sandbox value. See e_howto_api_ECGettingStarted
'PWD'=>'QFZCWN5HZM8VBG7Q',  # Sandbox value. See e_howto_api_ECGettingStarted
'SIGNATURE'=>'A-IzJhZZjhg29XQ2qnhapuwxIDzyAZQ92FRP5dqBzVesOkzbdUONzmOU',  # Sandbox value. See e_howto_api_ECGettingStarted
'METHOD'=>'SetExpressCheckout',
'VERSION'=>'88.0',
'PAYMENTREQUEST_0_PAYMENTACTION'=>'Sale',
'PAYMENTREQUEST_0_AMT'=>'23.00',  # Must have exactly two decimals for cents. See e_howto_api_ECGettingStarted above.
'PAYMENTREQUEST_0_CURRENCYCODE'=>'USD',
'cancelUrl'=>'http://www.add your own URL here',
'returnUrl'=>'http://www.add your own URL here'
}

http = Net::HTTP.new(uri.host,uri.port)
# HACK: The following two lines turn off secure certificate checking!!
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = http.request(request_object)