I was wondering how I would go about getting the balance of my paypal, total amount of transactions and total income.
I have the following to get the balance, but I cannot find anything else about getting the total amount of transactions and total income.
<?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']}
{$result['L_LONGMESSAGE0']}
";
exit;
}
$amount = $result['L_AMT0'];
?>
I cannot find the correct action to get the information I need, any help is appreciated.