php - PayPal Classic API TransactionSearch method not supported -
i'm trying use paypal's classic api transactionsearch. keep getting error 81002 unspecified method: method specified not supported. of course paypal's documentation "so" helpful. have ideas on might doing wrong?
here class i'm using... api credentials loaded $this->config...
<?php class paypal { private $base = array(); private $param = array(); public function __construct($registry) { $this->config = $registry->get('config'); $this->request = $registry->get('request'); // operate in sandbox or live mode? $sandbox = $this->config->get('paypal_sandbox'); $base = $this->base($sandbox); // set request parameters $param['request'] = array( 'startdate' => '2014-03-18t00:00:00-07:00z', // todo search parameter $this->request 'enddate' => '2014-03-19t14:22:23-07:00z' ); $transactions = $this->gettransactions($base,$param); print_r($transactions); } // set security // public function base($sandbox) { if($sandbox=='1') { $base = array( 'url' => 'https://api-3t.sandbox.paypal.com/nvp', 'username' => $this->config->get('paypal_username'), 'password' => $this->config->get('paypal_password'), 'signature' => $this->config->get('paypal_signature') ); } if($sandbox=='0') { $base = array( 'url' => 'https://api-3t.paypal.com/nvp', 'username' => $this->config->get('paypal_username'), 'password' => $this->config->get('paypal_password'), 'signature' => $this->config->get('paypal_signature') ); } return $base; } public function call($base,$post) { $post .= '&pwd='.$base['password']; $post .= '&user='.$base['username']; $post .= '&signature='.$base['signature']; $ch = curl_init($base['url']); curl_setopt($ch, curlopt_port, 443); curl_setopt($ch, curlopt_header, 0); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_forbid_reuse, 1); curl_setopt($ch, curlopt_fresh_connect, 1); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $post); $response = curl_exec($ch); if(empty($response)) { return 'no response received.'; } else { return $response; } curl_close($ch); } // transactions (classic api) // public function gettransactions($base,$param) { $post = 'method=transactionsearch'; $post .= 'version=58.0'; foreach ($param['request'] $key => $value) { $post .= '&' . strtoupper($key) . '=' . $value; } $transactions = $this->call($base,$post); return $transactions; }
} ?>
thanks @andrew. figured out missing & in front of version compiling method=transactionsearchversion.... instead of method=transactionsearch&version...
gonna leave in case else finds useful working paypal nvp. pain in brain!
Comments
Post a Comment