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
| Area | Methods | Docs |
|---|---|---|
| Profile | updateProfile(), uploadAvatar(), removeAvatar(), profilePortalUrl() | Users & profiles |
| Shared preferences | globalPreferences(), globalPreference(), setGlobalPreference(), deleteGlobalPreference() | Preferences |
| Addresses | addresses(), hasDefaultBillingAddress() | Account data |
| Orders | orders() → create(), find(); on an order checkout(), revoke(), delete(), shipments(), orderItems(), confirmationUrl() | Orders |
| Subscriptions | subscriptions() → create(), find(); on a subscription checkout(), pause(), resume(), revoke(), status(), isActive(), … | Subscriptions |
| Checkout sessions | checkoutSessions(), appCheckoutSessions() | Checkout sessions |
| App subscriptions | appSubscriptions() → create(), find(), all(); checkout(), change(), … | App subscriptions |
| App orders | appOrders() → pending(), all(), find(), invoicePdf() | App orders |
| Billing portal | billingPortalUrl(), appBillingPortalUrl() | Billing portal |
| Payment methods | paymentMethods(), hasPaymentMethod(), defaultPaymentMethod(), hasDefaultPaymentMethod(), setDefaultPaymentMethod(), createSetupIntent() | Account data |
| Invoices | invoices() | Account data |
| Transactions | transactions() | Account data |
| Balance | balance(), charges(), billingOverview(), charge(), vatRate() | Account data |
| SSH keys | sshKeys() | SSH keys |
| Countries | countries() |
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):
| Methods | Docs |
|---|---|
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;
}