mirror of
https://github.com/anikeen-com/id.git
synced 2026-11-02 05:39:35 +00:00
Document shipping address fields and item images on orders
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6e6684d00
commit
fd96e559af
4 files changed
+41
-18
No files matched your search
@@ -180,6 +180,22 @@ instead of trusting the query string. Subscriptions work the same way
|
|||||||
(`$user->subscriptions()->create([...])->confirmationUrl(...)`, `&subscription=…`).
|
(`$user->subscriptions()->create([...])->confirmationUrl(...)`, `&subscription=…`).
|
||||||
Unconfirmed bookings are cancelled after 24 hours.
|
Unconfirmed bookings are cancelled after 24 hours.
|
||||||
|
|
||||||
|
Physical goods need a shipping address (`first_name`, `last_name`, `address`, `postal_code`,
|
||||||
|
`city`, `country_iso`). The user can change both addresses on the confirmation page, so read the
|
||||||
|
shipping address from the order (or the `order.completed` webhook) before you ship. An item's
|
||||||
|
`image_url` is copied to Anikeen ID and stays visible on the order and invoice:
|
||||||
|
|
||||||
|
```php
|
||||||
|
$order = $user->orders()->create([
|
||||||
|
'billing_address_id' => $addressId,
|
||||||
|
'shipping_address' => ['first_name' => 'Ada', 'last_name' => 'Lovelace', 'address' => 'Main St', 'house_number' => '1', 'postal_code' => '10115', 'city' => 'Berlin', 'country_iso' => 'DE'],
|
||||||
|
'items' => [
|
||||||
|
['type' => 'physical', 'name' => 'T-shirt', 'unit' => 'piece', 'units' => 1, 'gross_price' => '24.90', 'image_url' => 'https://shop.test/img/shirt.png'],
|
||||||
|
['type' => 'physical-reduced', 'name' => 'Artbook', 'unit' => 'piece', 'units' => 1, 'gross_price' => '19.95'],
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
```
|
||||||
|
|
||||||
`checkout()` on such a draft throws `ConfirmationRequiredException`; its `confirmationUrl`
|
`checkout()` on such a draft throws `ConfirmationRequiredException`; its `confirmationUrl`
|
||||||
points to the same page. Trusted apps keep checking out directly.
|
points to the same page. Trusted apps keep checking out directly.
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ trait ManagesUserBilling
|
|||||||
* billing_address?: array,
|
* billing_address?: array,
|
||||||
* shipping_address_id?: string,
|
* shipping_address_id?: string,
|
||||||
* shipping_address?: array,
|
* shipping_address?: array,
|
||||||
* items: array<array{type: string, name: string, description?: string, price?: float|string, gross_price?: float|string, unit: string, units: int}>,
|
* items: array<array{type: string, name: string, description?: string, image_url?: string, price?: float|string, gross_price?: float|string, unit: string, units: int}>,
|
||||||
* checkout?: bool,
|
* checkout?: bool,
|
||||||
* transaction_id?: string,
|
* transaction_id?: string,
|
||||||
* transaction?: array,
|
* transaction?: array,
|
||||||
|
|||||||
@@ -42,13 +42,13 @@ class Order extends BaseResource
|
|||||||
* },
|
* },
|
||||||
* shipping_address: null|array{
|
* shipping_address: null|array{
|
||||||
* company_name: null|string,
|
* company_name: null|string,
|
||||||
* first_name: string,
|
* first_name: string,
|
||||||
* last_name: string,
|
* last_name: string,
|
||||||
* address: null|string,
|
* address: string,
|
||||||
* address_2: string,
|
* address_2: null|string,
|
||||||
* house_number: null|string,
|
* house_number: null|string,
|
||||||
* city: string,
|
* city: string,
|
||||||
* state: string,
|
* state: null|string,
|
||||||
* postal_code: string,
|
* postal_code: string,
|
||||||
* country_iso: string,
|
* country_iso: string,
|
||||||
* phone_number: null|string,
|
* phone_number: null|string,
|
||||||
@@ -56,7 +56,7 @@ class Order extends BaseResource
|
|||||||
* }
|
* }
|
||||||
* } $attributes The order data:
|
* } $attributes The order data:
|
||||||
* - billing_address: Billing address (ISO 3166-1 alpha-2 country code)
|
* - billing_address: Billing address (ISO 3166-1 alpha-2 country code)
|
||||||
* - shipping_address: Shipping address (first name, last name, ISO 3166-1 alpha-2 country code)
|
* - shipping_address: Shipping address for physical items (first name, last name, address, postal code, city, ISO 3166-1 alpha-2 country code)
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function update(array $attributes = []): self
|
public function update(array $attributes = []): self
|
||||||
|
|||||||
+19
-12
@@ -36,30 +36,37 @@ class Orders extends BaseCollection
|
|||||||
* },
|
* },
|
||||||
* shipping_address: null|array{
|
* shipping_address: null|array{
|
||||||
* company_name: null|string,
|
* company_name: null|string,
|
||||||
* first_name: string,
|
* first_name: string,
|
||||||
* last_name: string,
|
* last_name: string,
|
||||||
* address: null|string,
|
* address: string,
|
||||||
* address_2: string,
|
* address_2: null|string,
|
||||||
* house_number: null|string,
|
* house_number: null|string,
|
||||||
* city: string,
|
* city: string,
|
||||||
* state: string,
|
* state: null|string,
|
||||||
* postal_code: string,
|
* postal_code: string,
|
||||||
* country_iso: string,
|
* country_iso: string,
|
||||||
* phone_number: null|string,
|
* phone_number: null|string,
|
||||||
* email: null|string
|
* email: null|string
|
||||||
* },
|
* },
|
||||||
* items: array<array{
|
* items: array<array{
|
||||||
* type: string,
|
* type: string,
|
||||||
* name: string,
|
* name: string,
|
||||||
* description: string,
|
* description?: null|string,
|
||||||
* price: float|int,
|
* image_url?: null|string,
|
||||||
* unit: string,
|
* price?: float|int|string,
|
||||||
* units: int
|
* gross_price?: float|int|string,
|
||||||
|
* unit: string,
|
||||||
|
* units: int
|
||||||
* }>
|
* }>
|
||||||
* } $attributes The order data:
|
* } $attributes The order data:
|
||||||
* - billing_address: Billing address (ISO 3166-1 alpha-2 country code)
|
* - billing_address: Billing address (ISO 3166-1 alpha-2 country code)
|
||||||
* - shipping_address: Shipping address (first name, last name, ISO 3166-1 alpha-2 country code)
|
* - shipping_address: Shipping address for physical items (first name, last name, address, postal code, city, ISO 3166-1 alpha-2 country code)
|
||||||
* - items: Array of order items (each with type, name, price, unit, units, and quantity)
|
* - items: Array of order items:
|
||||||
|
* - type: digital, physical or physical-reduced (VAT category)
|
||||||
|
* - price/gross_price: net or gross unit price, one of both
|
||||||
|
* - unit: hour, day, week, month, year, onetime or piece
|
||||||
|
* - image_url: http(s) URL of a product image; Anikeen ID copies it, so it stays
|
||||||
|
* visible on the order and invoice when the shop removes it later
|
||||||
* @throws Throwable
|
* @throws Throwable
|
||||||
*/
|
*/
|
||||||
public function create(array $attributes = []): Order
|
public function create(array $attributes = []): Order
|
||||||
|
|||||||
Reference in new issue
Block a user