我是codeigniter和paypal的新手 . 我正在研究gocart(一种基于codeIgniter构建的开源电子商务解决方案) . 我尝试使用集成在其中的paypal API,但其显示错误如下: [ACK] => Failure [L_ERRORCODE0] => 81002 [L_SHORTMESSAGE0] => Unspecified Method [L_LONGMESSAGE0] => Method Specified is not Supported [L_SEVERITYCODE0] => Error
以下是我的代码: paypal_expres.php
function __construct()
{
$this->API_USERNAME ='Username';
$this->API_PASSWORD = 'Password';
$this->API_SIGNATURE ='Signature';
$this->RETURN_URL = 'www.example.com';
$this->CANCEL_URL = 'www.example.com';
$this->currency = 'USD';
$this->host = "api-3t.sandbox.paypal.com";
$this->gate = 'https://www.sandbox.paypal.com/cgi-bin/webscr?';
}
public function doExpressCheckout($amount, $desc, $invoice='')
{
$data = array(
'PAYMENTACTION' =>'Sale', 'AMT' => '24', 'RETURNURL' => $this->getReturnTo(),
'CANCELURL' => $this->getReturnToCancel(), 'CURRENCYCODE'=> $this->currency, 'METHOD' => 'SetExpressCheckout');
$query = $this->buildQuery($data);
$result = $this->response($query);
$response = $result->getContent();
$return = $this->responseParse($response);
echo '';
print_r($return);
echo '';
if ($return['ACK'] == 'Success')
{
header('Location: '.$this->gate.'cmd=_express-checkout&useraction=commit&token='.$return['TOKEN'].'');
die(); }
return($return);}
public function doExpressCheckout($amount, $desc, $invoice='')
{
$data = array( 'PAYMENTACTION' =>'Sale', 'AMT' => '24', 'RETURNURL' => $this->getReturnTo(), 'CANCELURL' => $this->getReturnToCancel(), 'CURRENCYCODE'=> $this->currency, 'METHOD' => 'SetExpressCheckout');
$query = $this->buildQuery($data);
$result = $this->response($query);
$response = $result->getContent();
$return = $this->responseParse($response);
echo '';
print_r($return);
echo '';
if ($return['ACK'] == 'Success')
{
header('Location: '.$this->gate.'cmd=_express-checkout&useraction=commit&token='.$return['TOKEN'].'');
die(); }
return($return);
}
private function response($data)
{
$result = $this->CI->httprequest->connect($data);
if ($result<400)
return
$this->CI->httprequest;
return false;}
private function buildQuery($data = array())
{
$data['USER'] = $this->API_USERNAME;
$data['PWD'] = $this->API_PASSWORD;
$data['SIGNATURE'] = $this->API_SIGNATURE;
$data['VERSION'] = '56.0';
$query = http_build_query($data);
return $query;
}