PHP code example of dropday-io / laravel

1. Go to this page and download the library: Download dropday-io/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/ */

    

dropday-io / laravel example snippets


use Dropday\Dropday\Facades\Dropday;

$order = Dropday::createOrder([
    'external_id' => 'your-internal-order-id',
    'shipping_address' => [
        'first_name' => 'Jane',
        'last_name'  => 'Doe',
        'address1'   => '123 Main St',
        'city'       => 'Amsterdam',
        'country'    => 'NL',
        'postcode'   => '1234AB',
    ],
    'products' => [
        ['sku' => 'PROD-001', 'quantity' => 1],
    ],
]);

use Dropday\Dropday\Dropday;

class OrderController extends Controller
{
    public function __construct(protected Dropday $dropday) {}

    public function store(Request $request): JsonResponse
    {
        $result = $this->dropday->createOrder($request->validated());

        return response()->json($result);
    }
}

// Submit a new order for fulfillment
Dropday::createOrder(array $data): array

// List orders, optionally filtered
Dropday::getOrders(array $filters = []): array

// Retrieve a single order by its Dropday reference ID
Dropday::getOrder(string $reference): array

Dropday::createOrder([
    'external_id' => 'test-order-001',
    'test'        => true,
    // ...
]);

use Dropday\Dropday\Exceptions\DropdayException;
use Illuminate\Http\Client\RequestException;

try {
    $order = Dropday::createOrder($data);
} catch (DropdayException $e) {
    // HTTP 422 — validation error
} catch (RequestException $e) {
    // Network or server error
}

use Illuminate\Support\Facades\Http;

Http::fake([
    '*/orders' => Http::response(['id' => 'ORD-1', 'status' => 'pending'], 200),
]);

$result = Dropday::createOrder(['external_id' => 'test-1', 'test' => true]);

expect($result['status'])->toBe('pending');
bash
php artisan vendor:publish --provider="Dropday\Dropday\DropdayServiceProvider"