PHPackages                             elgibor-solution/laravel-delivery-gosend - 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. elgibor-solution/laravel-delivery-gosend

ActiveLibrary[API Development](/categories/api)

elgibor-solution/laravel-delivery-gosend
========================================

Integrasi dengan API GoSend untuk pengiriman barang

1.0.0(5mo ago)0101↓50%Apache-2.0PHPPHP ^8.2

Since Dec 9Pushed 5mo agoCompare

[ Source](https://github.com/elgiborsolution/laravel-delivery-gosend)[ Packagist](https://packagist.org/packages/elgibor-solution/laravel-delivery-gosend)[ Docs](https://github.com/elgibor-solution/laravel-delivery-gosend)[ RSS](/packages/elgibor-solution-laravel-delivery-gosend/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Laravel Delivery GoSend
=======================

[](#laravel-delivery-gosend)

[![PHP Version](https://camo.githubusercontent.com/b5d4f7901c58ad1ddfff679966f426cc25a9354bab763846b9a7276c2feab4e0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d626c7565)](#)[![Laravel Version](https://camo.githubusercontent.com/f089f380c99c780807bf6c818e89c479c7c0acef44f755a6a23eda03953a07cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d25354531302e302d6f72616e6765)](#)[![License](https://camo.githubusercontent.com/54a591a708d9e41adc220d00e0caa979b5a5c035327d4eebaab67748cc889e4a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4170616368652d2d322e302d677265656e)](#)

Integration package for **GoSend** delivery API (Instant &amp; Same Day) for Laravel 10+, designed to support **multi-tenant** usage via **runtime config injection**.

> **Note**: This library is not an official GoSend SDK. It is a community package built around the integration guide.

---

Features
--------

[](#features)

- Create GoSend bookings (Instant / Same Day / InstantCar).
- Retrieve booking status (by `orderNo` or `storeOrderId`).
- Cancel bookings.
- Price &amp; distance estimation.
- Webhook endpoint to receive driver / booking status updates.
- `GoSendDelivery` model to store bookings.
- Event `GoSendStatusUpdated` dispatched on every webhook update.
- Facade `GoSend` for quick usage.
- Config-driven &amp; extendable architecture.
- Multi-tenant ready by overriding config at runtime (`withConfig()`).

---

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

[](#requirements)

- PHP `^8.2`
- Laravel `^10.0`
- ext-json
- `guzzlehttp/guzzle` `^7.0|^8.0`

---

Installation
------------

[](#installation)

```
composer require elgibor-solution/laravel-delivery-gosend
```

The service provider and facade will be auto-discovered.

### Publish Config &amp; Migrations

[](#publish-config--migrations)

```
php artisan vendor:publish --provider="ESolution\GoSend\Providers\GoSendServiceProvider" --tag=gosend-config
php artisan vendor:publish --provider="ESolution\GoSend\Providers\GoSendServiceProvider" --tag=gosend-migrations
```

Run migrations:

```
php artisan migrate
```

---

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

[](#configuration)

Main config file: `config/gosend.php`.

### Environment &amp; Base URLs

[](#environment--base-urls)

```
'environment' => env('GOSEND_ENV', 'staging'),

'base_urls' => [
    'staging' => env('GOSEND_STAGING_URL', 'https://integration-kilat-api.gojekapi.com'),
    'production' => env('GOSEND_PRODUCTION_URL', 'https://kilat-api.gojekapi.com'),
],
```

Set in `.env`:

```
GOSEND_ENV=staging

GOSEND_STAGING_CLIENT_ID=your-staging-client-id
GOSEND_STAGING_PASS_KEY=your-staging-pass-key

GOSEND_PRODUCTION_CLIENT_ID=your-prod-client-id
GOSEND_PRODUCTION_PASS_KEY=your-prod-pass-key
```

### HTTP Options

[](#http-options)

```
'http' => [
    'timeout' => env('GOSEND_HTTP_TIMEOUT', 10),
    'retries' => env('GOSEND_HTTP_RETRIES', 2),
    'retry_sleep_ms' => env('GOSEND_HTTP_RETRY_SLEEP_MS', 250),
],
```

### Routes &amp; Webhook

[](#routes--webhook)

```
'routes' => [
    'enabled' => env('GOSEND_ROUTES_ENABLED', true),
    'prefix' => env('GOSEND_ROUTE_PREFIX', 'gosend'),
    'middleware' => ['api'],
],

'webhook' => [
    'token_header' => env('GOSEND_WEBHOOK_TOKEN_HEADER', 'X-Callback-Token'),
    'token' => env('GOSEND_WEBHOOK_TOKEN'),
    'route_name' => 'gosend.webhook',
],
```

In `.env`:

```
GOSEND_WEBHOOK_TOKEN=some-random-secret
```

You must register this token &amp; webhook URL with GoSend.

---

Multi-tenant Usage (Runtime Config)
-----------------------------------

[](#multi-tenant-usage-runtime-config)

The package is **config-driven**, but also allows runtime overrides via `withConfig()` on the client or facade.

Typical pattern:

1. Store GoSend configuration (environment, client ID, pass key, etc.) **per tenant** in your database.
2. When handling a request for a specific tenant, load that row.
3. Call `withConfig()` and then use the client as usual.

Example:

```
use GoSend;
use ESolution\GoSend\Contracts\GoSendClientInterface;

// Load from DB (pseudo code)
$tenantConfig = [
    'environment' => $store->gosend_environment, // "staging" or "production"
    'credentials' => [
        $store->gosend_environment => [
            'client_id' => $store->gosend_client_id,
            'pass_key'  => $store->gosend_pass_key,
        ],
    ],
];

// Either via facade:
$client = GoSend::withConfig($tenantConfig);

// Or via dependency injection:
$baseClient = app(GoSendClientInterface::class);
$client = $baseClient->withConfig($tenantConfig);

// Now use $client for this tenant.
```

---

Usage
-----

[](#usage)

### 1. Creating a Booking

[](#1-creating-a-booking)

Using **Facade**:

```
use GoSend;

$payload = [
    'paymentType' => 3,
    'shipment_method' => 'Instant',
    'routes' => [[
        'originName'             => 'Pak Andri',
        'originNote'             => 'Tunggu di lobby',
        'originContactName'      => 'The Kingdom Shop',
        'originContactPhone'     => '6285201311802',
        'originLatLong'          => '-6.1263348,106.7890888',
        'originAddress'          => 'Alamat lengkap asal',
        'destinationName'        => 'Pak Nando',
        'destinationNote'        => 'Tolong hati-hati',
        'destinationContactName' => 'Toko Jaya Agung',
        'destinationContactPhone'=> '6281254564161',
        'destinationLatLong'     => '-6.284508001748839,106.8295789',
        'destinationAddress'     => 'Alamat lengkap tujuan',
        'item'                   => 'Sepatu, Sendal, Kaos Kaki',
        'storeOrderId'           => 'AWB-123456',
        'insuranceDetails'       => [
            'applied'             => 'false',
            'fee'                 => '0',
            'product_description' => 'Sepatu, Sendal, Kaos Kaki',
            'product_price'       => '500.000',
        ],
    ]],
];

$delivery = GoSend::createBooking($payload);

// $delivery is ESolution\GoSend\Models\GoSendDelivery
```

Using **dependency injection** with multi-tenant config:

```
use ESolution\GoSend\Contracts\GoSendClientInterface;

public function createForTenant(GoSendClientInterface $baseClient)
{
    $store = // ... load store/tenant model

    $client = $baseClient->withConfig([
        'environment' => $store->gosend_environment,
        'credentials' => [
            $store->gosend_environment => [
                'client_id' => $store->gosend_client_id,
                'pass_key'  => $store->gosend_pass_key,
            ],
        ],
    ]);

    $delivery = $client->createBooking($payload);
}
```

### 2. Get Status

[](#2-get-status)

```
$status = GoSend::getStatusByOrderNo('GK-11-170563');

$delivery = \ESolution\GoSend\Models\GoSendDelivery::where('order_no', 'GK-11-170563')->first();
```

Or by `storeOrderId`:

```
$status = GoSend::getStatusByStoreOrderId('AWB-123456');
```

### 3. Cancel Booking

[](#3-cancel-booking)

```
GoSend::cancelBooking('GK-11-170563');
```

### 4. Estimate Price

[](#4-estimate-price)

```
$estimate = GoSend::estimatePrice(
    originLatLong: '-6.1263348,106.7890888',
    destinationLatLong: '-6.284508001748839,106.8295789',
    paymentType: 3
);

// $estimate['Instant']['price']['total_price'] ...
```

### 5. Webhook Flow (End-to-End)

[](#5-webhook-flow-end-to-end)

- Expose webhook URL (e.g. `https://your-app.com/gosend/webhook`).
- Register this URL &amp; token with GoSend.
- When booking status changes, GoSend will call this endpoint with a payload like:

```
{
  "@type": "booking_event",
  "entity_id": "GK-11-117385",
  "type": "DRIVER_NOT_FOUND",
  "event_date": 1648542933000,
  "event_id": "7444acc4-0f14-419d-806c-6e245607c274",
  "partner_id": "601",
  "destination_type": "market_place",
  "booking_id": "GK-11-117385",
  "status": "no_driver",
  "booking_status": "no_driver",
  "booking_type": "instant",
  "driver_name": "",
  "driver_phone": "",
  "total_distance_in_kms": 1.184000015258789,
  "price": 20000.0,
  "receiver_name": "",
  "live_tracking_url": "http://..."
}
```

- `ProcessWebhook` job updates the `GoSendDelivery` record.
- Event `GoSendStatusUpdated` is dispatched.

Example listener in your app:

```
namespace App\Listeners;

use ESolution\GoSend\Events\GoSendStatusUpdated;
use Illuminate\Support\Facades\Log;

class LogGoSendStatus
{
    public function handle(GoSendStatusUpdated $event): void
    {
        Log::info('GoSend status updated', [
            'order_no' => $event->delivery->order_no,
            'status'   => $event->delivery->status,
            'event'    => $event->payload['type'] ?? null,
        ]);
    }
}
```

Register in `EventServiceProvider`:

```
protected $listen = [
    \ESolution\GoSend\Events\GoSendStatusUpdated::class => [
        \App\Listeners\LogGoSendStatus::class,
    ],
];
```

---

Example Integration: Controller &amp; Job
-----------------------------------------

[](#example-integration-controller--job)

### Controller

[](#controller)

```
namespace App\Http\Controllers;

use ESolution\GoSend\Contracts\GoSendClientInterface;
use Illuminate\Http\Request;

class OrderDeliveryController extends Controller
{
    public function createForOrder(Request $request, GoSendClientInterface $baseClient)
    {
        $order = /* find your order */;

        $store = $order->store; // example relation

        $client = $baseClient->withConfig([
            'environment' => $store->gosend_environment,
            'credentials' => [
                $store->gosend_environment => [
                    'client_id' => $store->gosend_client_id,
                    'pass_key'  => $store->gosend_pass_key,
                ],
            ],
        ]);

        $payload = [
            'paymentType' => 3,
            'shipment_method' => 'Instant',
            'routes' => [[
                'originName'             => $order->seller_name,
                'originContactName'      => $order->seller_contact_name,
                'originContactPhone'     => $order->seller_phone,
                'originLatLong'          => $order->seller_latlong,
                'originAddress'          => $order->seller_address,
                'destinationName'        => $order->buyer_name,
                'destinationContactName' => $order->buyer_contact_name,
                'destinationContactPhone'=> $order->buyer_phone,
                'destinationLatLong'     => $order->buyer_latlong,
                'destinationAddress'     => $order->buyer_address,
                'item'                   => $order->item_summary,
                'storeOrderId'           => $order->awb_code,
            ]],
        ];

        $delivery = $client->createBooking($payload);

        $order->gosend_delivery_id = $delivery->id;
        $order->save();

        return response()->json([
            'message' => 'GoSend delivery created',
            'order_no' => $delivery->order_no,
        ]);
    }
}
```

### Job: Refresh Status

[](#job-refresh-status)

```
namespace App\Jobs;

use ESolution\GoSend\Contracts\GoSendClientInterface;
use ESolution\GoSend\Models\GoSendDelivery;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class RefreshGoSendStatus implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public GoSendDelivery $delivery;

    public function __construct(GoSendDelivery $delivery)
    {
        $this->delivery = $delivery;
    }

    public function handle(GoSendClientInterface $client): void
    {
        if (! $this->delivery->order_no) {
            return;
        }

        $client->getStatusByOrderNo($this->delivery->order_no);
    }
}
```

---

Testing
-------

[](#testing)

Install dev dependencies and run tests:

```
composer install
composer test
```

This will run the provided Pest tests using `orchestra/testbench`.

---

Changelog
---------

[](#changelog)

All notable changes to this project will be documented here.

- `v0.1.0` – Initial release (GoSend booking, status, cancel, estimate, webhook, event, runtime multi-tenant config support).

---

License
-------

[](#license)

This package is open-sourced software licensed under the **Apache-2.0** license.

---

Sponsor / Donation (Optional)
-----------------------------

[](#sponsor--donation-optional)

If this package saves you development time, you can support the maintainer:

- {{your-donation-link-here}}

Thank you! 🙏

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance73

Regular maintenance activity

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

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

155d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f5e7899407946e1ed48940ae3b5fea2477eacc7ec98e9f53122e2d97718b7087?d=identicon)[esolution](/maintainers/esolution)

---

Top Contributors

[![elgibor-solution](https://avatars.githubusercontent.com/u/783039?v=4)](https://github.com/elgibor-solution "elgibor-solution (8 commits)")

---

Tags

laravelmulti-tenantdeliverylogisticsgosend

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/elgibor-solution-laravel-delivery-gosend/health.svg)

```
[![Health](https://phpackages.com/badges/elgibor-solution-laravel-delivery-gosend/health.svg)](https://phpackages.com/packages/elgibor-solution-laravel-delivery-gosend)
```

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[flat3/lodata

OData v4.01 Producer for Laravel

96320.9k](/packages/flat3-lodata)[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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