PHP code example of stellarsecurity / stellarsecurity-commerce-laravel

1. Go to this page and download the library: Download stellarsecurity/stellarsecurity-commerce-laravel library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

stellarsecurity / stellarsecurity-commerce-laravel example snippets


use StellarSecurity\CommerceLaravel\Contracts\CommerceClientContract;
use StellarSecurity\CommerceLaravel\DTO\CheckCouponCodeRequest;
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);

// Check a coupon code (exists + discount info)
$couponResult = $this->commerce->checkCouponCode(
  new CheckCouponCodeRequest(couponCode: 'TEST10')
);
bash
php artisan vendor:publish --tag=stellarsecurity-commerce-laravel-config