承接 tcgunel/omniship-fedex 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tcgunel/omniship-fedex

最新稳定版本:v0.0.2

Composer 安装命令:

composer require tcgunel/omniship-fedex

包简介

FedEx carrier for Omniship shipping library

README 文档

README

FedEx carrier driver for the Omniship shipping library.

Uses the FedEx REST API with OAuth 2.0 authentication.

Installation

composer require tcgunel/omniship-fedex

Usage

Initialize

use Omniship\Omniship;

$carrier = Omniship::create('FedEx');
$carrier->initialize([
    'clientId' => 'your-client-id',
    'clientSecret' => 'your-client-secret',
    'accountNumber' => 'your-account-number',
    'testMode' => true, // false for production
]);

Create Shipment

use Omniship\Common\Address;
use Omniship\Common\Package;

$response = $carrier->createShipment([
    'shipFrom' => new Address(
        name: 'Ahmet Yilmaz',
        company: 'Sender Company',
        street1: 'Ataturk Cad. No:42',
        city: 'Istanbul',
        district: 'Kadikoy',
        postalCode: '34710',
        country: 'TR',
        phone: '+905551234567',
    ),
    'shipTo' => new Address(
        name: 'John Smith',
        company: 'Receiver Inc',
        street1: '123 Main Street',
        city: 'New York',
        state: 'NY',
        postalCode: '10001',
        country: 'US',
        phone: '+12125551234',
    ),
    'packages' => [
        new Package(weight: 2.5, length: 30, width: 20, height: 15, description: 'Electronics'),
    ],
    'serviceType' => 'FEDEX_INTERNATIONAL_PRIORITY', // optional
])->send();

if ($response->isSuccessful()) {
    echo $response->getTrackingNumber(); // "794644790138"
    echo $response->getShipmentId();     // shipment identifier

    $label = $response->getLabel();
    if ($label !== null) {
        file_put_contents('label.pdf', base64_decode($label->content));
    }

    echo $response->getTotalCharge();    // 85.50
    echo $response->getCurrency();       // "USD"
} else {
    echo $response->getMessage(); // error description
    echo $response->getCode();    // error code
}

Track Shipment

$response = $carrier->getTrackingStatus([
    'trackingNumber' => '794644790138',
])->send();

if ($response->isSuccessful()) {
    $info = $response->getTrackingInfo();
    echo $info->trackingNumber;
    echo $info->status->value;    // "delivered", "in_transit", etc.
    echo $info->carrier;          // "FedEx"
    echo $info->serviceName;      // "FedEx International Priority"
    echo $info->signedBy;         // "J.SMITH"

    foreach ($info->events as $event) {
        echo $event->description; // "Delivered"
        echo $event->city;        // "NEW YORK"
        echo $event->country;     // "US"
        echo $event->occurredAt->format('Y-m-d H:i');
    }
}

Cancel Shipment

$response = $carrier->cancelShipment([
    'trackingNumber' => '794644790138',
])->send();

if ($response->isCancelled()) {
    echo 'Shipment cancelled';
}

Get Rates

$response = $carrier->getRates([
    'shipFrom' => new Address(
        city: 'Istanbul',
        postalCode: '34710',
        country: 'TR',
    ),
    'shipTo' => new Address(
        city: 'New York',
        postalCode: '10001',
        country: 'US',
    ),
    'packages' => [
        new Package(weight: 2.5, length: 30, width: 20, height: 15),
    ],
])->send();

if ($response->isSuccessful()) {
    foreach ($response->getRates() as $rate) {
        echo $rate->serviceCode;       // "FEDEX_INTERNATIONAL_PRIORITY"
        echo $rate->serviceName;       // "FedEx International Priority"
        echo $rate->totalPrice;        // 85.50
        echo $rate->currency;          // "USD"
        echo $rate->transitDays;       // 3
    }
}

Tracking Status Mapping

FedEx Code Description ShipmentStatus
PU Picked up PICKED_UP
OC Order created PRE_TRANSIT
IT In transit IN_TRANSIT
AR Arrived at facility IN_TRANSIT
DP Departed facility IN_TRANSIT
OD Out for delivery OUT_FOR_DELIVERY
DL Delivered DELIVERED
DE Delivery exception FAILURE
CA Cancelled CANCELLED
RS Return to shipper RETURNED

API Details

  • Transport: REST/JSON via PSR-18 HTTP client
  • Auth: OAuth 2.0 (client credentials grant)
  • Base URL: https://apis.fedex.com (prod), https://apis-sandbox.fedex.com (sandbox)
  • Create: POST /ship/v1/shipments
  • Track: POST /track/v1/trackingnumbers
  • Cancel: PUT /ship/v1/shipments/cancel
  • Rates: POST /rate/v1/rates/quotes

Testing

vendor/bin/pest

License

MIT

统计信息

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

GitHub 信息

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

其他信息

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