Skip to content

The Billable trait ​

Anikeen\Id\Billable on your user model gives each user access to their Anikeen ID data and billing. Methods act with the user's access token (anikeen_id_access_token); the app*() methods act with your app's own token for that user (trusted apps).

Nothing is requested until you call a method. Results are cached on the model instance, so calling $user->orders() twice sends one request.

The user ​

php
$user->getUserData();          // GET /api/v1/user, cached
$user->getUserData()->billing_address_id;

What it covers ​

AreaMethodsDocs
ProfileupdateProfile(), uploadAvatar(), removeAvatar(), profilePortalUrl()Users & profiles
Shared preferencesglobalPreferences(), globalPreference(), setGlobalPreference(), deleteGlobalPreference()Preferences
Addressesaddresses(), hasDefaultBillingAddress()Account data
Ordersorders() → create(), find(); on an order checkout(), revoke(), delete(), shipments(), orderItems(), confirmationUrl()Orders
Subscriptionssubscriptions() → create(), find(); on a subscription checkout(), pause(), resume(), revoke(), status(), isActive(), …Subscriptions
Checkout sessionscheckoutSessions(), appCheckoutSessions()Checkout sessions
App subscriptionsappSubscriptions() → create(), find(), all(); checkout(), change(), …App subscriptions
App ordersappOrders() → pending(), all(), find(), invoicePdf()App orders
Billing portalbillingPortalUrl(), appBillingPortalUrl()Billing portal
Payment methodspaymentMethods(), hasPaymentMethod(), defaultPaymentMethod(), hasDefaultPaymentMethod(), setDefaultPaymentMethod(), createSetupIntent()Account data
Invoicesinvoices()Account data
Transactionstransactions()Account data
Balancebalance(), charges(), billingOverview(), charge(), vatRate()Account data
SSH keyssshKeys()SSH keys
Countriescountries()

The full list of signatures is in the method reference.

App-level methods ​

Methods that don't belong to one signed-in user live on the client, app(\Anikeen\Id\AnikeenId::class):

MethodsDocs
findUserById(), findUserByEmail(), createUser()Users, User accounts
createOrderForUser(), createOrderPreview()Orders
appOrders(), appCheckoutSessions() (all users)App orders, Checkout sessions
createChargeForUser(), findChargeForUser(), voidChargeForUser()Charges
billingLimitForUser()Billing limit
createBillingPortalLinkForUser()Billing portal
preferencesByUserId(), preferenceByUserId(), setPreferenceByUserId(), deletePreferenceByUserId(), findUserIdByPreference()Preferences
sshKeysByUserId()SSH keys
refreshToken(), getAuthedUser()Login

Lists ​

List methods (invoices(), addresses(), …) return a collection: toArray() for the items, find($id) for one, paginate() for the raw Result with its pagination.

php
foreach ($user->invoices()->toArray() as $invoice) {
    echo $invoice->number;
}

Anikeen ID developer documentation