PHPackages                             kingdarkness/goship - 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. kingdarkness/goship

ActiveLibrary

kingdarkness/goship
===================

v2.3(1y ago)0552PHP

Since Mar 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/KingDarkness/goship-php-sdk)[ Packagist](https://packagist.org/packages/kingdarkness/goship)[ RSS](/packages/kingdarkness-goship/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

Goship PHP SDK
==============

[](#goship-php-sdk)

Goship Goship document

Install
=======

[](#install)

Composer

```
$ composer require kingdarkness/goship
```

Usage
=====

[](#usage)

#### Create Goship instance

[](#create-goship-instance)

```
use Kingdarkness\Goship\Goship as GoshipSdk;

# public function __construct(string $clientId, string $clientSecret, string $accessToken = NULL, string $username = NULL,  $password = NULL, string $apiUrl = 'https://api.goship.io' )

$goship = new GoshipSdk($yourClientId, $yourClientSecret, $yourAccessToken);
```

#### Lấy danh sách tỉnh thành

[](#lấy-danh-sách-tỉnh-thành)

```
# public function getCities([array $query = [], array $headers = [] )

$cities = $goship->getCities();

# cities
#[
#	{
#		"id": "100000",
#		"name": "Hà Nội"
#	},
#	{
#		"id": "700000",
#		"name": "Hồ Chí Minh"
#	},
#	{
#		"id": "880000",
#		"name": "An Giang"
#	},
#	{
#		"id": "790000",
#		"name": "Bà Rịa - Vũng Tàu"
#	}
#    ....
#]
```

#### Lấy danh sách quận huyện

[](#lấy-danh-sách-quận-huyện)

```
# public function getDistricts(mixed $cityCode, array $query = [], array $headers = [] )
$districts = $goship->getDistricts(100000);
```

#### Lấy danh sách phường xã

[](#lấy-danh-sách-phường-xã)

```
# public function getWards(mixed $districtCode, array $query = [], array $headers = [] )
$wards $goship->getWards(100300);
```

#### Lấy danh sách vận đơn

[](#lấy-danh-sách-vận-đơn)

```
# public function getShipments(array $query = [], array $headers = [] )
$shipments = $goship->getShipments();
```

#### Lấy chi tiết vận đơn

[](#lấy-chi-tiết-vận-đơn)

```
# public function getShipment(mixed $code, [array $query = [], array $headers = [] )
$shipment = $goship->getShipment('GS0001');
```

#### Lấy link in vận đơn

[](#lấy-link-in-vận-đơn)

```
# public function getPrintUrl(mixed $code, [array $query = [], array $headers = [] )
$shipment = $goship->getPrintUrl('GS0001');
```

#### Hủy vận đơn

[](#hủy-vận-đơn)

```
# public function cancelShipment(mixed $code, [array $query = [], array $headers = [] )
$gsResponse = $goship->cancelShipment('GS0001');
```

#### Tạo vận đơn mới

[](#tạo-vận-đơn-mới)

```
# public function createShipment(array $data, array $query = [], array $headers = [] )
$data = [
    'rate'=> 'MTFfMjFfMTc2Mg==', #  (bắt buộc) mã bảng giá lấy từ api get bảng giá
	'from_city'=> 100000, # (bắt buộc) mã tỉnh thành gửi
	'from_district'=> 100300, # (bắt buộc) mã quận huyện gửi
	'from_ward'=> 20, # (bắt buộc) mã phường xã gửi
	'from_street'=> '62 định công', # (bắt buộc) địa chỉ gửi (lấy hàng)
	'sender_name'=> 'Nguyễn gửi', # (bắt buộc) tên ngưởi gửi
	'sender_phone'=> '0123321123', # (bắt buộc) điện thoại người gửi
	'to_city'=> 100000, # (bắt buộc) mã tỉnh thành nhận
	'to_district' => 100300, # (bắt buộc) mã phường xã nhận
	'to_ward'=> 20, # (bắt buộc) mã phường xã
	'to_street'=> '63 định công', # (bắt buộc) địa chỉ nhận
	'receiver_name'=> 'Nguyện nhận', # (bắt buộc) tên người nhận
	'receiver_phone'=> '0321111222', # (bắt buộc) điện thoại người nhận
	'cod'=> 0, # tiền thu hộ
	'amount'=> 0, # giá trị khai giá
	'weight'=> 500, # (bắt buộc) cân nặng (g)
	'payer'=> \Kingdarkness\Goship\V2\Shipment::CUSTOMER_PAY, # người trả phí CUSTOMER_PAY => 0 (người nhận trả), SHOP_PAY => 1 (người gửi trả)
	'package_name'=> 'test package', # tên gói hàng
	'metadata'=> 'ghi chú', # ghi chú
	'order_id'=> '8936487235428', # mã đơn hàng của bạn
        'note_code'=> 'KHONGCHOXEMHANG', # ghi chú bắt buộc nhận 1 trong các giá trị sau ('CHOTHUHANG' : 'Cho thử hàng', 'CHOXEMHANGKHONGTHU' : 'Cho xem hàng, không cho thử', 'KHONGCHOXEMHANG': 'Không cho xem hàng')
	'length'=> 10, # chiều dài
	'width'=> 10, # chiều rộng
	'height'=> 10 # chiều cao
];
try {
        $gsResponse = $goship->createShipment($data);
    } catch (\Kingdarkness\Goship\Exceptions\ValidateException $e) {
        var_dump($e->errors);
    }
```

#### Lấy danh sách giá

[](#lấy-danh-sách-giá)

```
# public function getRates(array $data, [array $query = [], array $headers = [] )
$data = [
	'from_city'=> 100000, # (bắt buộc) mã tỉnh thành gửi
	'from_district'=> 100300, # (bắt buộc) mã quận huyện gửi
	'to_city'=> 100000, # (bắt buộc) mã tỉnh thành nhận
	'to_district' => 100300, # (bắt buộc) mã phường xã nhận
	'cod'=> 0, # tiền thu hộ
	'amount'=> 0, # giá trị khai giá
	'weight'=> 500, # (bắt buộc) cân nặng (g)
	'payer'=> \Kingdarkness\Goship\V2\Shipment::CUSTOMER_PAY, # người trả phí CUSTOMER_PAY => 0 (người nhận trả), SHOP_PAY => 1 (người gửi trả)
        'length'=> 10, # chiều dài
	'width'=> 10, # chiều rộng
	'height'=> 10 # chiều cao

];
try {
        $rates = $goship->getRates($data);
    } catch (\Kingdarkness\Goship\Exceptions\ValidateException $e) {
        var_dump($e->errors);
    }
```

#### Lấy danh sách lịch sử giao dịch

[](#lấy-danh-sách-lịch-sử-giao-dịch)

```
# public function getTransactions(array $query = [], array $headers = [] )
$transactions = $goship->getTransactions();
```

#### Lấy danh sách phiên đối soát

[](#lấy-danh-sách-phiên-đối-soát)

```
# public function getInvoices(array $query = [], array $headers = [] )
$invoices = $goship->getInvoices();
```

#### Lấy danh sách vận đơn thuộc đối soát

[](#lấy-danh-sách-vận-đơn-thuộc-đối-soát)

```
# public function getShipmentInInvoice(mixed $invoiceCode, array $query = [], array $headers = [] )
$shipments = $goship->getShipmentInInvoice('INV0001');
```

#### Verify webhook

[](#verify-webhook)

```
# public function verifyWebhook()
try {
    $webhookData = $this->verifyWebhook();
	var_dump($webhookData);
    } catch (\Kingdarkness\Goship\Exceptions\UnverifiException $e) {
	echo 'fake data';
    }
```

DEV
===

[](#dev)

generate doc

```
$ php phpdox.phar
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance44

Moderate activity, may be stable

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Every ~354 days

Total

4

Last Release

445d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f0c3b4b5602ccc803b3cab15fbe10193b130f62123d92725ff50b8471cab322?d=identicon)[KingDarkness](/maintainers/KingDarkness)

---

Top Contributors

[![KingDarkness](https://avatars.githubusercontent.com/u/12492508?v=4)](https://github.com/KingDarkness "KingDarkness (18 commits)")

### Embed Badge

![Health badge](/badges/kingdarkness-goship/health.svg)

```
[![Health](https://phpackages.com/badges/kingdarkness-goship/health.svg)](https://phpackages.com/packages/kingdarkness-goship)
```

PHPackages © 2026

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