我想知道如何获得我的paypal,交易总额和总收入的余额。
我有以下方法来获得余额,但我找不到任何有关获得交易总额和总收入的信息。
<?php
$environment = 'live'; // 'sandbox', 'beta-sandbox', or 'live'
$config = array(
'username' => 'removed',
'password' => 'removed',
'signature' => 'removed',
'version' => '51.0'
);
$action = 'GetBalance';
switch ($environment) {
case 'sandbox':
case 'beta-sandbox':
$url = "https://api-3t.$environment.paypal.com/nvp";
break;
default:
$url = "https://api-3t.paypal.com/nvp";
}
foreach ($config as &$value) {
$value = urlencode($value);
}
$request = http_build_query(array(
"METHOD" => $action,
"VERSION" => $config['version'],
"USER" => $config['username'],
"PWD" => $config['password'],
"SIGNATURE" => $config['signature'],
"RETURNALLCURRENCIES" => 1,
));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$response = curl_exec($ch);
if (!$response) {
echo 'Failed to retrieve paypal balance: ' . curl_error($ch) . ' (' . curl_errno($ch) . ')';
exit;
}
parse_str($response, $result);
foreach ($result as &$value) {
$value = urldecode($value);
}
if (!isset($result['ACK']) || $result['ACK'] != "Success") {
echo "{$result['L_SEVERITYCODE0']} {$result['L_ERRORCODE0']}: {$result['L_SHORTMESSAGE0']}\n{$result['L_LONGMESSAGE0']}\n";
exit;
}
$amount = $result['L_AMT0'];
?>
我找不到正确的行动来获取我需要的信息,感谢任何帮助。
答案 0 :(得分:0)
管理解决我的问题, 找到了一些信息,并通过获取交易清单找到了所有信息。
这是我专门为这些操作制作的课程
<?php
class PayPalAPI {
private $_config,
$_url,
$_result;
public function __construct($configuration) {
$this->_config = $configuration;
$this->_url = "https://api-3t.paypal.com/nvp";
}
public function method($method, $params) {
foreach ($this->_config as $value => $vo) {
$this->_config[$value] = urlencode($vo);
}
$holding = array(
"METHOD" => $method,
"VERSION" => $this->_config['version'],
"USER" => $this->_config['username'],
"PWD" => $this->_config['password'],
"SIGNATURE" => $this->_config['signature']
);
foreach($params as $param => $object) {
$holding[$param] = $object;
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->_url);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($holding));
$response = curl_exec($ch);
if(!$response)
$this->_result = false;
parse_str($response, $result);
foreach($result as $value => $vo){
$result[$value] = urldecode($vo);
}
if (!isset($result['ACK']) || $result['ACK'] != "Success")
$this->_result = false;
else
$this->_result = $result;
}
public function result(){
return $this->_result;
}
}
&GT;