tcgunel/omniship-aras 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tcgunel/omniship-aras

Composer 安装命令:

composer require tcgunel/omniship-aras

包简介

Aras Kargo carrier for Omniship shipping library

README 文档

README

Aras Kargo carrier driver for the Omniship shipping library.

Installation

composer require tcgunel/omniship-aras

Usage

Initialize

use Omniship\Omniship;

$carrier = Omniship::create('Aras');
$carrier->initialize([
    'username' => 'your-username',
    'password' => 'your-password',
    'testMode' => true, // false for production
    'senderAccountAddressId' => '', // optional
]);

Create Shipment

use Omniship\Common\Address;
use Omniship\Common\Package;
use Omniship\Common\Enum\PaymentType;

$response = $carrier->createShipment([
    'shipTo' => new Address(
        name: 'Ahmet Yilmaz',
        street1: 'Ataturk Cad. No:1',
        city: 'Istanbul',
        district: 'Kadikoy',
        phone: '05551234567',
    ),
    'packages' => [
        new Package(
            weight: 1.5,
            length: 30,
            width: 20,
            height: 15,
            description: 'Elektronik urun',
        ),
    ],
    'integrationCode' => 'ORD-001',       // required - your order reference
    'invoiceNumber' => 'INV-001',          // optional
    'tradingWaybillNumber' => 'TWB-001',   // required - irsaliye no
    'barcodes' => ['BARCODE-001'],         // one barcode per piece
    'paymentType' => PaymentType::SENDER,  // or PaymentType::RECEIVER
    'cashOnDelivery' => false,
    'codAmount' => 0.0,
])->send();

if ($response->isSuccessful()) {
    echo $response->getShipmentId();    // InvoiceKey
    echo $response->getBarcode();       // same as InvoiceKey
    echo $response->getTrackingNumber(); // integrationCode
} else {
    echo $response->getMessage();       // error description
    echo $response->getCode();          // Aras result code
}

Integration Code & Barcodes

Per Aras Kargo requirements:

  • integrationCode must be unique, minimum 6 characters, numeric only
  • barcodes are auto-generated from integrationCode + 2-digit piece suffix if not provided
  • Single piece: integrationCode=12345678 → barcode 1234567801
  • Multi piece: integrationCode=12345678 → barcodes 1234567801, 1234567802

You can also provide explicit barcodes (one per piece):

'barcodes' => ['1234567801', '1234567802'],

If a package has quantity: 3, you need 3 barcodes for that package's pieces.

Generate Labels

Aras Kargo does not provide labels — they must be designed by the integrator. The built-in label generator creates print-ready HTML labels with barcodes (via Google Fonts Libre Barcode 128).

// Generate labels using default template
$html = $carrier->generateLabels([
    'shipFrom' => $shipFrom,
    'shipTo' => $shipTo,
    'packages' => $packages,
    'integrationCode' => '12345678',
    'paymentType' => PaymentType::SENDER,
    'cashOnDelivery' => false,
]);

// Output or save the HTML
file_put_contents('labels.html', $html);

Each package piece gets its own label with:

  • Carrier name and date
  • Sender name
  • Receiver name, phone, address
  • Payment type or COD info
  • Integration code with barcode
  • Piece barcode with barcode
  • Piece number (e.g. Paket: 1/3)

Custom Label Template

You can provide your own HTML template with placeholders:

$customTemplate = '<div class="my-label">
    <h1>{{carrierName}}</h1>
    <p>{{receiverName}} - {{receiverPhone}}</p>
    <p>{{receiverAddress}}</p>
    <p>Entegrasyon: {{integrationCode}}</p>
    <p>Barkod: {{barcodeNumber}}</p>
    <p>Paket: {{pieceNumber}} / {{totalPieces}}</p>
</div>';

$html = $carrier->generateLabels($shipmentData, $customTemplate);

Available placeholders: {{carrierName}}, {{date}}, {{senderName}}, {{receiverName}}, {{receiverPhone}}, {{receiverAddress}}, {{paymentTypeText}}, {{codLine}}, {{codDisplay}}, {{paymentDisplay}}, {{integrationCode}}, {{barcodeNumber}}, {{pieceNumber}}, {{totalPieces}}.

Raw Label Data

For full control over rendering, get LabelData objects directly:

$labels = $carrier->getLabelData($shipmentData);

foreach ($labels as $label) {
    echo $label->integrationCode;
    echo $label->barcodeNumber;
    echo "{$label->pieceNumber}/{$label->totalPieces}";
}

### Track Shipment

Tracking uses the `GetOrderWithIntegrationCode` SOAP method to look up shipment by integration code.

```php
$response = $carrier->getTrackingStatus([
    'trackingNumber' => 'ORD-001', // your integration code
])->send();

if ($response->isSuccessful()) {
    $info = $response->getTrackingInfo();
    echo $info->trackingNumber;
    echo $info->status->value;  // PRE_TRANSIT, IN_TRANSIT, DELIVERED, etc.
    echo $info->carrier;        // "Aras Kargo"

    foreach ($info->events as $event) {
        echo $event->description;
        echo $event->occurredAt->format('Y-m-d H:i');
        echo $event->location;
    }
}

Cancel Shipment

$response = $carrier->cancelShipment([
    'integrationCode' => 'ORD-001',
])->send();

if ($response->isSuccessful()) {
    echo 'Shipment cancelled';
} else {
    echo $response->getMessage();
}

API Endpoints

Environment URL
Test https://customerservicestest.araskargo.com.tr/arascargoservice/arascargoservice.asmx
Production https://customerservices.araskargo.com.tr/arascargoservice/arascargoservice.asmx

SOAP Methods Used

Operation SOAP Action Purpose
SetOrder Create shipment Registers a new cargo order
GetOrderWithIntegrationCode Track shipment Looks up order by integration code
CancelDispatch Cancel shipment Cancels a pending shipment

Error Codes

Code Description
0 Success
935 ReceiverPhone1 must be numeric
937 Integration code is required
938 Receiver address is required
939 Receiver name is required
940 City name is required
941 District name is required
1000 Invalid username or password
1006 Sender dispatch address not found (invalid SenderAccountAddressId)
70022 Barcode info missing in piece details
70027 Barcode already used
70030 Piece barcodes must be unique

Testing

vendor/bin/pest

License

MIT

tcgunel/omniship-aras 适用场景与选型建议

tcgunel/omniship-aras 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 427 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tcgunel/omniship-aras 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tcgunel/omniship-aras 我们能提供哪些服务?
定制开发 / 二次开发

基于 tcgunel/omniship-aras 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 427
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-13