mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-03 14:19:31 +00:00
Bring the package up to date with the Anikeen ID API
Fixed (called endpoints that don't exist):
- charge(): POST v1/billing/charge (Stripe options aren't passed through anymore)
- Invoice::getInvoiceTemporaryUrl(): GET instead of a non-existent PUT
- OrderItems::create(): POST v1/orders/{order}/items
- createUser() / isEmailExisting(): admin endpoints with the app token
- sshKeysByUserId(): app endpoint; no longer returns the first user's keys for every user
- createOrderPreview(): country_iso goes into billing_address as the API expects
- public endpoints (products, order preview) work without a token
- SshKeys::find() results can be deleted
Added:
- Billable: sshKeys() (create, update, delete), billingOverview(), PaymentMethod::delete()
- AnikeenId: products(), boxes(), shipping labels (list, show, pdf, issue, ship, price list),
createOrderForUser(), createTransactionForUser(), findOrCreateSocialiteUser()
Requirements: PHP 8.2+, Laravel 11-13 (Laravel 10 and PHP 8.1 are end of life).
Docs generator handles union types; README regenerated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8de737641e
commit
9613d31a8d
22 files changed
+720
-108
No files matched your search
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Anikeen\Id\Concerns;
|
||||
|
||||
use Anikeen\Id\Result;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* Orders and payments on behalf of a user. Trusted apps only, sent with the app's token.
|
||||
*/
|
||||
trait ManagesUserBilling
|
||||
{
|
||||
/**
|
||||
* Create an order for a user (VAT from the billing address). With `checkout`, it is paid right
|
||||
* away: with the given `transaction` (a payment captured elsewhere) or by charging the user's
|
||||
* default payment method (402 when declined; the order stays pending and is retried).
|
||||
*
|
||||
* @param string $userId The user's Anikeen ID.
|
||||
* @param array{
|
||||
* group?: string,
|
||||
* billing_address_id?: string,
|
||||
* billing_address?: array,
|
||||
* shipping_address_id?: string,
|
||||
* shipping_address?: array,
|
||||
* items: array<array{type: string, name: string, description?: string, price?: float|string, gross_price?: float|string, unit: string, units: int}>,
|
||||
* checkout?: bool,
|
||||
* transaction_id?: string,
|
||||
* transaction?: array,
|
||||
* invoice_date?: string,
|
||||
* currency_iso?: string
|
||||
* } $attributes
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function createOrderForUser(string $userId, array $attributes): Result
|
||||
{
|
||||
return $this->asApp()->request('POST', 'v1/admin/orders', [...$attributes, 'user_id' => $userId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Book a payment of a user that was captured elsewhere (e.g. PayPal, Ko-fi). The same
|
||||
* provider/payment_intent can only be booked once (409 with the existing transaction_id).
|
||||
*
|
||||
* @param string $userId The user's Anikeen ID.
|
||||
* @param array{
|
||||
* payment_provider?: string,
|
||||
* payment_intent?: string,
|
||||
* status: string,
|
||||
* type: string,
|
||||
* amount: float|string,
|
||||
* currency_iso: string,
|
||||
* created_at: string,
|
||||
* group?: string,
|
||||
* invoice_id?: string
|
||||
* } $attributes
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function createTransactionForUser(string $userId, array $attributes): Result
|
||||
{
|
||||
return $this->asApp()->request('POST', 'v1/admin/transactions', [...$attributes, 'user_id' => $userId]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user