Skip to content

omnibus/zto-express API reference

Floor
Provider · Omnibus
Version
2.x
Conformance suite
runs, no CI read
Verified for real
Not verified for real
Licence
MIT
composer require omnibus/zto-express:2.x-dev

Read from the package's own PHP files at the commit 06d458129418: its namespaces, classes, interfaces and enums, their public constants, properties and methods with their PHPDoc, and the options its factories take. Nothing of it is run.

Omnibus\ZtoExpress

  • Api class

    ZTO's open platform (japi.zto.com): one path per message type, the JSON body signed with x-dataDigest = base64(md5(body + key)) and the company id in x-companyId.

    3 methods · 3 properties · 2 constants

  • ZtoExpressGatewayFactory class

    options: company_id: '%env(ZTO_COMPANY_ID)%' # the open platform's company id key: '%env(ZTO_KEY)%' # its key partner_code: null # the 合作商编码 for electronic waybills sandbox: true rates: [...] # prices from configuration: ZTO quotes by contract

    8 options

Omnibus\ZtoExpress\Action

  • CancelAction class

    zto.open.cancelOrder, by the bill code.

    3 methods

  • ShippingAction class

    zto.open.createOrder: the order with an electronic waybill (partner code), its bill code; the label as ZTO's print data.

    3 methods

  • TrackingAction class

    zto.open.getTraceInfo: the bill's traces, oldest first.

    3 methods

Omnibus\ZtoExpress

Api class

final class Api Api.php:15

ZTO's open platform (japi.zto.com): one path per message type, the JSON body signed with x-dataDigest = base64(md5(body + key)) and the company id in x-companyId.

const LIVE = 'https://japi.zto.com'
const TEST = 'https://japi-test.zto.com'
public readonly string $companyId
public readonly ?string $partnerCode
public readonly bool $sandbox

Api::__construct()

public function __construct(readonly HttpClientInterface $http, public readonly string $companyId, readonly string $key, public readonly ?string $partnerCode = null, public readonly bool $sandbox = false, readonly int $timeout = 20)

Api::call()

public function call(string $msgType, array $data): array
Returns

the result

Api::digest()

public static function digest(string $body, string $key): string

ZtoExpressGatewayFactory class

final class ZtoExpressGatewayFactory extends GatewayFactory ZtoExpressGatewayFactory.php:22

options: company_id: '%env(ZTO_COMPANY_ID)%' # the open platform's company id key: '%env(ZTO_KEY)%' # its key partner_code: null # the 合作商编码 for electronic waybills sandbox: true rates: [...] # prices from configuration: ZTO quotes by contract

No pickup points. Unverified until an account's keys are at hand.

Options

OptionDefault
partner_codenull
sandboxfalse
omnibus.apifunction (Config $c) { $http = $this->http ?? HttpClient::create(); return new Api($http, (string) $c['company_id'], (string) $c['key'], $c['partner_…
omnibus.action.shippingnew ShippingAction()
omnibus.action.trackingnew TrackingAction()
omnibus.action.cancelnew CancelAction()
company_idrequired
keyrequired

Omnibus\ZtoExpress\Action

CancelAction class

final class CancelAction implements ActionInterface, ApiAwareInterface CancelAction.php:13

zto.open.cancelOrder, by the bill code.

CancelAction::__construct()

public function __construct()

CancelAction::supports()

public function supports(Request $request): bool

CancelAction::execute()

public function execute(Request $request): void

ShippingAction class

final class ShippingAction implements ActionInterface, ApiAwareInterface ShippingAction.php:16

zto.open.createOrder: the order with an electronic waybill (partner code), its bill code; the label as ZTO's print data.

ShippingAction::__construct()

public function __construct()

ShippingAction::supports()

public function supports(Request $request): bool

ShippingAction::execute()

public function execute(Request $request): void

TrackingAction class

final class TrackingAction implements ActionInterface, ApiAwareInterface TrackingAction.php:16

zto.open.getTraceInfo: the bill's traces, oldest first.

TrackingAction::__construct()

public function __construct()

TrackingAction::supports()

public function supports(Request $request): bool

TrackingAction::execute()

public function execute(Request $request): void