Account data
The user's addresses, payment methods, invoices, transactions and billing overview, read (and partly changed) with the user's token.
Billing overview
GET /api/v1/billing{
"data": {
"current_balance": 0,
"current_charges": 12.5,
"vat_rate": 19,
"has_billing_address": true,
"has_default_payment_method": true,
"open_orders": 0,
"billing_limit": null
}
}current_charges are the open charges of the current month, open_orders the orders waiting for payment, billing_limit the user's billing limit.
$user->billingOverview();
$user->balance(); // current_balance
$user->charges(); // current_charges
$user->vatRate();Scope: billing:read (or billing) for billingOverview(). balance(), charges() and vatRate() read the user and need user:read (or user).
Addresses
| Method | Path | |
|---|---|---|
GET | /api/v1/addresses | the user's addresses |
POST | /api/v1/addresses | add an address |
GET | /api/v1/addresses/{id} | one address |
PUT | /api/v1/addresses/{id} | change it (send only what changes) |
DELETE | /api/v1/addresses/{id} | delete it |
| Field | |
|---|---|
first_name, last_name | required |
address | required: the street |
house_number, address_2 | optional |
postal_code, city | required |
state | optional |
country_iso | required: an ISO code from GET /api/v1/countries |
company_name | optional |
vat_number | optional; validated, EU numbers are checked with VIES |
phone_number, email | optional |
primary | the user's primary address |
primary_billing_address | the user's billing address |
The billing address decides the VAT (a verified EU VAT number of another country means reverse charge). Its ID is billing_address_id on the user.
$user->addresses()->create([...]);
$user->hasDefaultBillingAddress();
$user->addresses()->defaultBillingAddress();Scopes: addresses:read or addresses.
Payment methods
| Method | Path | |
|---|---|---|
GET | /api/v1/payment-methods | the user's saved payment methods |
GET | /api/v1/payment-methods/default | the default payment method, or null |
GET | /api/v1/payment-methods/{id} | one payment method |
PUT | /api/v1/payment-methods/{id}/default | make it the default |
DELETE | /api/v1/payment-methods/{id} | remove it |
POST | /api/v1/payment-methods | start adding one: returns a Stripe SetupIntent |
Payment methods are Stripe payment method objects. To add one, POST returns a SetupIntent whose client_secret your frontend confirms with Stripe.js; optional options.payment_method_types and options.usage (off_session or on_session). Usually it is simpler to let the user add one on Anikeen ID (the confirmation page or the billing portal).
$user->hasDefaultPaymentMethod();
$user->defaultPaymentMethod();
$user->setDefaultPaymentMethod($id);
$user->paymentMethods()->toArray();Scopes: payment-methods:read or payment-methods.
Invoices
| Method | Path | |
|---|---|---|
GET | /api/v1/invoices | the user's invoices and credit notes, newest first; filter group |
GET | /api/v1/invoices/{id} | one invoice |
foreach ($user->invoices(['group' => $team->id])->toArray() as $invoice) {
// …
}
$user->invoices()->find($id)?->getInvoiceTemporaryUrl(); // a temporary download linkScopes: invoices:read or invoices; billing:read and billing read invoices too. Trusted apps read the invoices of their monthly bills with the app token, see App orders.
Transactions
| Method | Path | |
|---|---|---|
GET | /api/v1/transactions | the user's payments, newest first |
GET | /api/v1/transactions/{id} | one payment |
Scopes: transactions:read or transactions.
Deposits
POST /api/v1/billing/charge
{"amount": "25.00", "payment_method_id": "pm_…"}Charges an amount (0.50 to 10,000, at most 2 decimals) from one of the user's payment methods as a deposit to their balance. Answers 402 with the transaction when the payment failed and 409 when the same amount was charged a moment ago.
$transaction = $user->charge('25.00', $paymentMethodId);