承接 zeeshanali/laravel-shipstation 相关项目开发

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

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

zeeshanali/laravel-shipstation

Composer 安装命令:

composer require zeeshanali/laravel-shipstation

包简介

ShipStation API package Laravel 10.

README 文档

README

Latest Version on Packagist Software License Latest Version on Packagist Build Status

A simple PHP API wrapper for ShipStation built for Laravel 10.*.

Installation

composer require zeeshanali/laravel-shipstation

Second, add the LaravelShipStation service provider to your providers array located in config/app.php

Zeeshan\LaravelShipStation\ShipStationServiceProvider::class,

After installing via composer you will need to publish the configuration:

php artisan vendor:publish --tag=shipstation

This will create the configuration file for your API key and API secret key at config/shipstation.php. You will need to obtain your API & Secret key from ShipStation: How can I get access to ShipStation's API?

Dependencies

LaravelShipStation uses GuzzleHttp\Guzzle

Endpoints

Endpoints for the API are accessed via properties (e.g. $shipStation->orders->get($options) will make a GET request to /orders/{$options}). The default endpoint is /orders/. Valid endpoints include:

  • accounts
  • carriers
  • customers
  • fulfillments
  • orders
  • products
  • shipments
  • stores
  • users
  • warehouses
  • webhooks

Methods

GET

$shipStation->{$endpoint}->get($options = [], $endpoint = '');

Example of getting an order with the orderId of 1.

use rajarizwan2007\LaravelShipStation\ShipStation; 

$shipStation = new ShipStation();

// Fetch an order by orderId == 123, orderId is defined by ShipStation
$order = $shipStation->orders->get([], $endpoint = 123); // returns \stdClass

// Fetch an orderId by the orderNumber, which may be user defined
$order = $shipStation->orders->getOrderId('ORD-789'); // returns integer

POST

$shipStation->{$endpoint}->post($options = [], $endpoint = '');

The second parameter ($endpoint) is for any additional endpoints that need to be added. For example, to create an order the POST request would go to /orders/createorder. "createorder" is the additional endpoint since we specify the root endpoint as a property: $shipstation->orders->post($options, 'createorders')

There are models that contain all of the properties available via the API. These models will be converted to arrays when passed to the API.

An example on how to create a new order to be shipped:

    use rajarizwan2007\LaravelShipStation\ShipStation;
    $shipStation = new ShipStation();

    $address = new LaravelShipStation\Models\Address();

    $address->name = "Joe Campo";
    $address->street1 = "123 Main St";
    $address->city = "Cleveland";
    $address->state = "OH";
    $address->postalCode = "44127";
    $address->country = "US";
    $address->phone = "2165555555";

    $item = new LaravelShipStation\Models\OrderItem();

    $item->lineItemKey = '1';
    $item->sku = '580123456';
    $item->name = "Awesome sweater.";
    $item->quantity = '1';
    $item->unitPrice  = '29.99';
    $item->warehouseLocation = 'Warehouse A';

    $order = new LaravelShipStation\Models\Order();

    $order->orderNumber = '1';
    $order->orderDate = '2016-05-09';
    $order->orderStatus = 'awaiting_shipment';
    $order->amountPaid = '29.99';
    $order->taxAmount = '0.00';
    $order->shippingAmount = '0.00';
    $order->internalNotes = 'A note about my order.';
    $order->billTo = $address;
    $order->shipTo = $address;
    $order->items[] = $item;

    // This will var_dump the newly created order, and order should be wrapped in an array.
    var_dump($shipStation->orders->post([$order], 'createorder'));
    // or with the helper: $shipStation->orders->create([$order]); would be the same.

DELETE

$shipStation->{$endpoint}->delete($resourceEndPoint);

Example of deleting an order by it's order ID:

$shipStation->orders->delete($orderId);

UPDATE

$shipStation->{$endpoint}->update($query = [], $resourceEndPoint);

Simple Wrapper Helpers

Helpers are located in /src/Helpers and will be named after the endpoint. Currently there is only a helper for the /orders endpoint and /shipments endpint. I will be adding more; feel free to send a PR with any you use.

Check to see if an order already exists in ShipStation via an Order Number:

$orderExists = $shipStation->orders->existsByOrderNumber($orderNumber) // returns bool

Note: When using the orderNumber query parameter ShipStation will return any order that contains the search term. e.g. orderNumber = 1 will return any order that CONTAINS 1 in ascending order and not an exact match to the query. If you have two orders 123, and 1234 in your ShipStation and call $shipStation->orders->get(['orderNumber' => 123]); you will return both orders.

Check how many orders are in awaiting_fulfillment status:

$count = $shipStation->orders->awaitingShipmentCount(); // returns int

Create an order in ShipStation:

$newOrder = $shipStation->orders->create($order);

Get the shipments for a specific order number.

$shipments = $shipStation->shipments->forOrderNumber($orderNumber);

ShipStation API Rate Limit

ShipStation only allows for 40 API calls that resets every 60 seconds (or 1 call every 1.5 seconds). By default, LaravelShipStation will protect against any calls being rate limited by pausing when we are averaging more than 1 call every 1.5 seconds.

Tests

Tests can be ran using phpunit. Please note that tests will create an order, check the order, and delete the order in your production environment. By default, tests are disabled. If you would like to run the tests edit the phpunit.xml file to set the environment variable SHIPSTATION_TESTING to true and set your API Key & Secret Key.

Contribution

Pull requests are most certainly welcomed! This is a WIP.

License

The MIT License (MIT). Please see License File for more information.

zeeshanali/laravel-shipstation 适用场景与选型建议

zeeshanali/laravel-shipstation 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 108 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 30 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 zeeshanali/laravel-shipstation 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-04-30