PayPal\Service\PayPalAPIInterfaceServiceService::GetBalance PHP Method

GetBalance() public method

Service Call: GetBalance
public GetBalance ( GetBalanceReq $getBalanceReq, mixed $apiCredential = null ) : GetBalanceResponseType
$getBalanceReq PayPal\PayPalAPI\GetBalanceReq
$apiCredential mixed - Optional API credential - can either be a username configured in sdk_config.ini or a ICredential object created dynamically
return PayPal\PayPalAPI\GetBalanceResponseType
    public function GetBalance($getBalanceReq, $apiCredential = null)
    {
        $apiContext = new PPApiContext($this->config);
        $handlers = array(new PPMerchantServiceHandler($apiCredential, self::$SDK_NAME, self::$SDK_VERSION));
        $this->setStandardParams($getBalanceReq->GetBalanceRequest);
        $ret = new GetBalanceResponseType();
        $resp = $this->call('PayPalAPI', 'GetBalance', $getBalanceReq, $apiContext, $handlers);
        $ret->init(PPUtils::xmlToArray($resp));
        return $ret;
    }

Usage Example

Beispiel #1
0
 *  Indicates whether to return all currencies. It is one of the
following values:

* 0 – Return only the balance for the primary currency holding.
* 1 – Return the balance for each currency holding.
*/
$getBalanceRequest->ReturnAllCurrencies = $_REQUEST['returnAllCurrencies'];
$getBalanceReq = new GetBalanceReq();
$getBalanceReq->GetBalanceRequest = $getBalanceRequest;
/*
 * 	 ## Creating service wrapper object
Creating service wrapper object to make API call and loading
Configuration::getAcctAndConfig() returns array that contains credential and config parameters
*/
$paypalService = new PayPalAPIInterfaceServiceService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $getBalanceResponse = $paypalService->GetBalance($getBalanceReq);
} catch (Exception $ex) {
    include_once "../Error.php";
    exit;
}
if (isset($getBalanceResponse)) {
    echo "<table>";
    echo "<tr><td>Ack :</td><td><div id='Ack'>{$getBalanceResponse->Ack}</div> </td></tr>";
    echo "</table>";
    echo "<pre>";
    print_r($getBalanceResponse);
    echo "</pre>";
}
require_once '../Response.php';