stellarsecurity / stellarsecurity-commerce-laravel
Laravel client for Stellar Commerce Core/Base API (Client -> UI API -> Base API).
Installs: 55
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/stellarsecurity/stellarsecurity-commerce-laravel
Requires
- php: ^8.2
- illuminate/http: ^12.0
- illuminate/support: ^12.0
README
Laravel client package used by UI APIs to call the Stellar Commerce Core/Base API.
Install
composer require stellarsecurity/stellarsecurity-commerce-laravel
Publish config
php artisan vendor:publish --tag=stellarsecurity-commerce-laravel-config
Env
STELLAR_COMMERCE_CORE_BASE_URL=http://127.0.0.1:8000 STELLAR_COMMERCE_CORE_API_PREFIX=/api/v1 STELLAR_COMMERCE_CORE_BASIC_AUTH_ENABLED=true STELLAR_COMMERCE_CORE_BASIC_AUTH_USER=stellar STELLAR_COMMERCE_CORE_BASIC_AUTH_PASS=CHANGE_THIS STELLAR_COMMERCE_CORE_TIMEOUT_SECONDS=10 STELLAR_COMMERCE_CORE_CONNECT_TIMEOUT_SECONDS=5 STELLAR_COMMERCE_CORE_RETRY_TIMES=2 STELLAR_COMMERCE_CORE_RETRY_SLEEP_MS=200
Important trust boundary
The UI API must not send money amounts like shipping/tax/discount. Those must be computed by the Commerce Core API.
Send:
- items
- shipping address (if physical)
- shipping_method (optional)
- coupon_code (optional)
Usage
use StellarSecurity\CommerceLaravel\Contracts\CommerceClientContract; use StellarSecurity\CommerceLaravel\DTO\CreateOrderRequest; use StellarSecurity\CommerceLaravel\DTO\OrderItem; public function __construct(private CommerceClientContract $commerce) {} $req = new CreateOrderRequest( idempotencyKey: (string) \Illuminate\Support\Str::uuid(), userId: null, buyerRef: (string) \Illuminate\Support\Str::uuid(), currency: 'EUR', items: [ new OrderItem($variantId, 1) ], shipping: null, shippingMethod: null, couponCode: null, meta: ['channel' => 'direct'] ); $result = $this->commerce->createOrder($req);