PHPackages                             pralhadstha/nepalcan-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. pralhadstha/nepalcan-laravel

ActiveLibrary[API Development](/categories/api)

pralhadstha/nepalcan-laravel
============================

Laravel integration for Nepal Can Move (NCM) courier API — shipments, tracking, rates, webhooks, COD, and delivery management for Nepal

v1.0.0(3mo ago)06↓90%MITPHPPHP ^8.1

Since Apr 1Pushed 3mo agoCompare

[ Source](https://github.com/pralhadstha/nepalcan-laravel)[ Packagist](https://packagist.org/packages/pralhadstha/nepalcan-laravel)[ Docs](https://github.com/pralhadstha/nepalcan-laravel)[ RSS](/packages/pralhadstha-nepalcan-laravel/feed)WikiDiscussions main Synced 4w ago

READMEChangelogDependencies (9)Versions (2)Used By (0)

Nepal Can Move (NCM) Laravel Package
====================================

[](#nepal-can-move-ncm-laravel-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d5473a4d17a0aec1b9812fd5eab34fe44e13a00d4f68a27770b1c8cc2c78ca41/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7072616c686164737468612f6e6570616c63616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pralhadstha/nepalcan-laravel)[![Tests](https://github.com/pralhadstha/nepalcan-laravel/actions/workflows/tests.yml/badge.svg)](https://github.com/pralhadstha/nepalcan-laravel/actions)[![License](https://camo.githubusercontent.com/2fbeb1b2b45b9a5a0312eac1119f784ac1ed93df00197fb9114648f7271c4c28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7072616c686164737468612f6e6570616c63616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pralhadstha/nepalcan-laravel)[![PHP Version](https://camo.githubusercontent.com/4d52489a1c5f8cc59d4dbd6ac5050d185902c3bd7296b4c893ac1c734a85c561/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7072616c686164737468612f6e6570616c63616e2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pralhadstha/nepalcan-laravel)

Laravel integration for the [Nepal Can Move (NCM)](https://nepalcanmove.com) courier and shipping API. Manage shipments, track deliveries, calculate rates, handle COD payments, and process webhooks — all with idiomatic Laravel patterns.

Built on top of [Nepal Can PHP SDK](https://github.com/pralhadstha/nepal-can-php-sdk).

Features
--------

[](#features)

- **Service Provider** with auto-discovery — zero configuration to get started
- **Facade** (`NepalCan`) for clean, expressive syntax
- **Dependency Injection** — type-hint `OmniCargo\NepalCan\Client` in any class
- **Publishable Config** — environment-based API token and base URL management
- **Webhook Integration** — automatic route registration with Laravel event dispatching
- **Webhook Middleware** — user-agent validation out of the box
- **Laravel Events** — listen for delivery status changes with native event listeners

Requirements
------------

[](#requirements)

DependencyVersionPHP^8.1Laravel10.x, 11.x, or 12.xInstallation
------------

[](#installation)

```
composer require pralhadstha/nepalcan-laravel
```

The service provider and facade are auto-discovered. No manual registration needed.

### Publish Configuration

[](#publish-configuration)

```
php artisan vendor:publish --tag=nepalcan-config
```

This creates `config/nepalcan.php` in your application.

Configuration
-------------

[](#configuration)

Add these variables to your `.env` file:

```
NEPALCAN_API_TOKEN=your-api-token-here
NEPALCAN_ENVIRONMENT=sandbox
```

### Environment Variables

[](#environment-variables)

VariableDescriptionDefault`NEPALCAN_API_TOKEN`Your NCM API token from the dashboard`""``NEPALCAN_ENVIRONMENT``sandbox` or `production``sandbox``NEPALCAN_BASE_URL`Override the API base URL entirely`null``NEPALCAN_WEBHOOK_VALIDATE_UA`Validate webhook User-Agent header`true``NEPALCAN_WEBHOOK_PATH`Webhook endpoint path`/nepalcan/webhook`Set `NEPALCAN_ENVIRONMENT=production` when you're ready to go live. This switches the base URL from `demo.nepalcanmove.com` to `nepalcanmove.com`.

Usage
-----

[](#usage)

### Using the Facade

[](#using-the-facade)

```
use OmniCargo\NepalCan\Laravel\Facades\NepalCan;
```

#### Create a Shipment

[](#create-a-shipment)

```
$order = NepalCan::shipments()->create([
    'receiver_name' => 'Ram Shrestha',
    'receiver_phone' => '9801234567',
    'receiver_address' => 'Kathmandu',
    'product_name' => 'Electronics',
    'cod_charge' => '1500',
    'quantity' => 1,
]);

echo $order->orderId;
```

#### Track an Order

[](#track-an-order)

```
// By order ID
$statuses = NepalCan::tracking()->getStatusHistory(12345);

// By tracking ID
$detail = NepalCan::tracking()->track('NCM-123456');
echo $detail->lastDeliveryStatus;

// Bulk status check
$bulk = NepalCan::tracking()->getBulkStatuses([12345, 67890]);
```

#### Calculate Shipping Rates

[](#calculate-shipping-rates)

```
use OmniCargo\NepalCan\Services\RateService;

$rate = NepalCan::rates()->calculate('Kathmandu', 'Pokhara');
echo $rate->charge;

// Specify delivery type
$rate = NepalCan::rates()->calculate(
    'Kathmandu',
    'Pokhara',
    RateService::TYPE_D2B, // Door to Branch
);
```

Available delivery types: `TYPE_PICKUP_COLLECT` (Door2Door), `TYPE_SEND` (Branch2Door), `TYPE_D2B` (Door2Branch), `TYPE_B2B` (Branch2Branch).

#### List Branches

[](#list-branches)

```
$branches = NepalCan::branches()->list();

foreach ($branches as $branch) {
    echo "{$branch->name} - {$branch->district}";
}
```

#### Support Tickets

[](#support-tickets)

```
use OmniCargo\NepalCan\Services\TicketService;

// Create a ticket
$ticket = NepalCan::tickets()->create(
    TicketService::TYPE_GENERAL,
    'Need help with order #12345',
);

// Request COD transfer
$ticket = NepalCan::tickets()->createCodTransfer(
    bankName: 'Nepal Bank',
    accountName: 'Ram Shrestha',
    accountNumber: '1234567890',
);

// Close a ticket
NepalCan::tickets()->close($ticket->ticketId);
```

#### Staff Management

[](#staff-management)

```
$result = NepalCan::staff()->list(search: 'ram', page: 1, pageSize: 10);

foreach ($result['results'] as $staff) {
    echo "{$staff->name} - {$staff->email}";
}
```

### Using Dependency Injection

[](#using-dependency-injection)

You can type-hint the SDK client directly in your controllers, jobs, or any service:

```
use OmniCargo\NepalCan\Client;

class ShippingController extends Controller
{
    public function __construct(private readonly Client $client)
    {
    }

    public function show(int $orderId)
    {
        $order = $this->client->shipments->find($orderId);
        $history = $this->client->tracking->getStatusHistory($orderId);

        return view('shipping.show', compact('order', 'history'));
    }
}
```

Webhook Handling
----------------

[](#webhook-handling)

### Automatic Route Registration

[](#automatic-route-registration)

By default, the package registers a POST route at `/nepalcan/webhook`. Incoming webhook payloads are parsed and dispatched as Laravel events.

Make sure to exclude this path from CSRF verification. In Laravel 10:

```
// app/Http/Middleware/VerifyCsrfToken.php
protected $except = [
    'nepalcan/webhook',
];
```

In Laravel 11+:

```
// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->validateCsrfTokens(except: [
        'nepalcan/webhook',
    ]);
})
```

To disable the automatic route, set `NEPALCAN_WEBHOOK_PATH` to an empty value or set `webhook.path` to `null` in the config.

### User-Agent Validation

[](#user-agent-validation)

The package validates that incoming webhook requests have a `User-Agent` header starting with `NCM-Webhook/`. This prevents unauthorized requests from reaching your event listeners. Disable this with:

```
NEPALCAN_WEBHOOK_VALIDATE_UA=false
```

### Listening for Events

[](#listening-for-events)

Register listeners in your `EventServiceProvider` or use `Event::listen()`:

```
use OmniCargo\NepalCan\Laravel\Events\DeliveryCompleted;
use OmniCargo\NepalCan\Laravel\Events\NepalCanWebhookReceived;

// Listen for a specific event
Event::listen(DeliveryCompleted::class, function (DeliveryCompleted $event) {
    $orderId = $event->webhook->orderId;
    // Update your order status, notify customer, etc.
});

// Listen for ALL webhook events
Event::listen(NepalCanWebhookReceived::class, function (NepalCanWebhookReceived $event) {
    Log::info("NCM webhook: {$event->webhook->event}", [
        'order_id' => $event->webhook->orderId,
        'status' => $event->webhook->status,
    ]);
});
```

### Available Events

[](#available-events)

Every webhook dispatches the generic `NepalCanWebhookReceived` event. Additionally, a specific event is dispatched based on the webhook type:

Webhook EventLaravel Event Class`pickup_completed``OmniCargo\NepalCan\Laravel\Events\PickupCompleted``sent_for_delivery``OmniCargo\NepalCan\Laravel\Events\SentForDelivery``order_dispatched``OmniCargo\NepalCan\Laravel\Events\OrderDispatched``order_arrived``OmniCargo\NepalCan\Laravel\Events\OrderArrived``delivery_completed``OmniCargo\NepalCan\Laravel\Events\DeliveryCompleted`All event classes carry a `public readonly Webhook $webhook` property with the parsed payload data.

Testing
-------

[](#testing)

```
composer test
```

Or run individual suites:

```
vendor/bin/phpunit --testsuite=Unit
vendor/bin/phpunit --testsuite=Feature
```

Credits
-------

[](#credits)

- [Pralhad Kumar Shrestha](https://github.com/pralhadstha)

License
-------

[](#license)

The MIT License (MIT). See [LICENSE](LICENSE) for details.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance82

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

91d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d46fb8b473d604d2f5eb4e27451ef88b44e10a430c0a0ce89b4e501fcfe95b2?d=identicon)[pralhad](/maintainers/pralhad)

---

Top Contributors

[![pralhadstha](https://avatars.githubusercontent.com/u/6309194?v=4)](https://github.com/pralhadstha "pralhadstha (3 commits)")

---

Tags

laravellogisticsncmnepal-can-moveorder-trackingphp-sdkshippinglaravellaravel-packagetrackingservice providerfacadewebhookecommerceapi clientshippingdeliverycourierlogisticsnepalnepal can movecodncmcash-on-delivery

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pralhadstha-nepalcan-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/pralhadstha-nepalcan-laravel/health.svg)](https://phpackages.com/packages/pralhadstha-nepalcan-laravel)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M341](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M135](/packages/laravel-mcp)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[illuminate/auth

The Illuminate Auth package.

10528.2M1.2k](/packages/illuminate-auth)[illuminate/routing

The Illuminate Routing package.

1419.2M2.9k](/packages/illuminate-routing)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
