1. Go to this page and download the library: Download laraditz/courier-jt-express 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/ */
use Laraditz\Courier\Facades\Courier;
use Laraditz\Courier\DTOs\Shared\Address;
use Laraditz\Courier\DTOs\Shared\Parcel;
use Laraditz\Courier\DTOs\Payloads\ShipmentPayload;
$result = Courier::driver('jtexpress')->createShipment(new ShipmentPayload(
sender: new Address(
name: 'J&T sender',
phone: '+60123456789',
email: null,
line1: 'No 32, Jalan Kempas 4',
line2: null,
line3: null,
city: 'Bandar Penawar',
state: 'Johor',
postcode: '81930',
country: 'MY',
),
recipient: new Address(/* ... */),
parcel: new Parcel(
weight: 1.5,
length: 20.0,
width: 15.0,
height: 10.0,
declaredValue: 100.0,
description: 'Goods',
quantity: 1,
),
serviceCode: 'EZ', // EX | EZ | FD | DO | JS
reference: 'ORDER-001', // optional — a UUID is generated if omitted
));
$result->waybillNumber; // '630000491494' (J&T billCode)
$result->reference; // 'ORDER-001' — persist this for cancelShipment()/getLabel() later
// Track
$tracking = Courier::driver('jtexpress')->track($result->waybillNumber);
// Cancel —
public string $billCode;
public ?string $txlogisticId;
public string $scanTypeCode; // raw J&T code
public string $mappedStatus; // normalised status (see table below)
public array $raw; // the raw scan detail
use Laraditz\Courier\JtExpress\Events\TrackingUpdated;
Event::listen(TrackingUpdated::class, function (TrackingUpdated $event) {
// ...
});