PHP code example of akika / laravel-weevo

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

    

akika / laravel-weevo example snippets


use Akika\LaravelWeevo\Facades\Weevo;

Weevo::default();

$credentials = [
    'username' => 'CUSTOM_USERNAME',
    'api_key' => 'CUSTOM_API_KEY',
    'api_secret' => 'CUSTOM_API_SECRET',
];
$response = Weevo::using($credentials)
    ->createDelivery($sampleDeliveryData);

use Akika\LaravelWeevo\Support\WeevoCredentials;

$response = Weevo::using(
    new WeevoCredentials(
        username: 'CUSTOM_USERNAME',
        apiKey: 'CUSTOM_API_KEY',
        apiSecret: 'CUSTOM_API_SECRET',
    )
)->createDelivery($sampleDeliveryData);

$sampleDeliveryData = [
    "externalId" => "1234562",
    "externalShipmentId" => "1234562",
    "branch" => 'WB-00001',
    "rider" => null, //"WR-00007", // If not set, the system will assign the rider
    "dropoff" => [
        "name" => "Jane Smith",
        "phone" => "+254700000001",
        "email" => "[email protected]",
        "address" => "456 Elm St, Nairobi",
        "latitude" => -1.2921,
        "longitude" => 36.8219
    ],
    'orderValue' => 300, // Optional
    "package" => [
        "weight" => 1.5,
        "dimensions" => [
            "length" => 30,
            "width" => 20,
            "height" => 10
        ]
    ],
    'items' => [ // Optional
        [
            "name" => "Item 1",
            "sku" => "123234234",
            "quantity" => 1,
            "unitPrice" => 100
        ],
        [
            "name" => "Item 2",
            "sku" => "123234235",
            "quantity" => 2,
            "unitPrice" => 200
        ]
    ],
    'vehicleType' => 'motor_bike', // Optional: bike, motor_bike, car, van, truck
    'amountCharged' => 300, // Optional
    'instructions' => 'Deliver on time', // As requested by the customer
    'slotStartAt' => '2024-06-01 10:00:00', // Optional
    'slotEndAt' => '2024-06-01 12:00:00', // Optional
    'invoicedAt' => '2024-06-01 09:00:00', // Optional
    'deliveryMode' => 'standard', // Optional
    'paymentReceivedAt' => '2024-06-01 08:00:00', // Optional
];
$response = Weevo::default()->createDelivery($sampleDeliveryData);

$response = Weevo::default()->getDelivery("TRIP-260630-003101-7054");

$result = Weevo::default()->updatePaymentStatus(
    "TRIP-260630-003101-7054",
    [
        'paymentStatus' => 'paid', // Example update data
        'paymentReceivedAt' => '2024-06-01 08:00:00' // Example update data
    ]
);

case Pending = 'pending';
case Assigned = 'assigned';
case Picked = 'picked';
case InTransit = 'in_transit';
case DeliveryInitiated = 'delivery_initiated';
case PaymentRequested = 'payment_requested';
case Delivered = 'delivered';
case Failed = 'failed';
case Cancelled = 'cancelled';
case Returning = 'returning';
case Returned = 'returned';

[
    'success' => true,
    'message' => 'Delivery created successfully.',
    'tripId' => 'TRIP-260630-003101-7054',
]

$response = Weevo::default()->createDelivery($data);

if ($response === null) {
    // Request failed
}
bash
php artisan weevo:install
bash
php artisan vendor:publish --tag=weevo-config
text
config/weevo.php