Example #1
0
        // Create the account
        // The external key is not used in this example
        $accountData->externalKey = uniqid();
        $account = $accountData->create("web-user", "PHP_TEST", "Test for the demo", $tenantHeaders);
        if ($account != null && $account->accountId != null) {
            $_SESSION['accountId'] = $account->accountId;
            $account_created = TRUE;
        } else {
            $account = new Killbill_Account();
            $account_created = FALSE;
        }
    } else {
        // Update the account
        $accountData->accountId = $_SESSION['accountId'];
        // TODO API needs to be fixed
        $currentAccount = $accountData->get($tenantHeaders);
        $accountData->externalKey = $currentAccount->externalKey;
        $account = $accountData->update("web-user", "PHP_TEST", "Test for the demo", $tenantHeaders);
        if ($account != null) {
            $account_updated = TRUE;
        } else {
            $account = new Killbill_Account();
            $account_updated = FALSE;
        }
    }
} else {
    $account = new Killbill_Account();
    if (isset($_SESSION['accountId'])) {
        $account->accountId = $_SESSION['accountId'];
        $account = $account->get($tenantHeaders);
    }
Example #2
0
/**
 * Load the user account
 *
 * @return account object
 */
function loadAccount($tenantHeaders)
{
    $account = new Killbill_Account();
    $account->accountId = $_SESSION['accountId'];
    return $account->get($tenantHeaders);
}