shipmondo/shipmondo_php_sdk

Shipmondo's official PHP library


License
MIT

Documentation

Shipmondo's official PHP library

This SDK supports Shipmondo API v3.

Specification: https://app.shipmondo.com/api/public/v3/specification

Note: If you want to upgrade from pakkelabels-php-sdk please refer to this section

Getting started

Below is a simple PHP script which illustrate the minimum amount of code needed to getting started.

<?php
  try {
    $client = new Shipmondo('api_user', 'api_key');
  } catch (ShipmondoException $e) {
    echo $e->getMessage();
  }
?>

Once the $client object is created, you can begin to use the API.

Examples

Get current balance

<?php
  echo $client->getAccountBalance();
?>

Get outstanding payment requests

<?php
  $params = [
    'created_at_min' => '2019-08-22',
    'page' => 1
  ];
  echo $client->getAccountPaymentRequests($params);
?>

Get available products

<?php
  $params = [
    'country_code' => 'DK',
    'carrier_code' => 'gls',
    'page' => 1
  ];
  echo $client->getProducts($params);
?>

Pagination is supported

Get available / nearest pickup points

<?php
  $params = [
    'country_code' => 'DK',
    'carrier_code' => 'gls',
    'zipcode' => '5000'
  ];
  echo $client->getPickupPoints($params);
?>

Get shipments

<?php
  $params = [
    'page' => 1,
    'carrier_code' => 'dao'
  ];
  echo $client->getShipments($params);
?>

Pagination is supported

Get shipment by id:

<?php
  $id = 5545625;
  echo $client->getShipment($id);  
?>

Get label(s) for shipment

<?php
  $shipment_id = 5545625;
  $params = [
    'label_format' => '10x19_pdf'
  ];
  echo $client->getShipmentLabels($shipment_id, $params);  
?>

Create shipment

<?php
  $params = [
    "test_mode" => true,
    "own_agreement" => true,
    "label_format" => "a4_pdf",
    "product_code" => "GLSDK_HD",
    "service_codes" => "EMAIL_NT,SMS_NT",
    "order_id" => "10001",
    "reference" => "Webshop 10001",
    "sender" => [
      "name" => "Shipmondo ApS",
      "address1" => "Strandvejen 6B",
      "address2" => null,
      "country_code" => "DK",
      "zipcode" => "5240",
      "city" => "Odense NØ",
      "attention" => null,
      "email" => "firma@email.dk",
      "telephone" => "70400407",
      "mobile" => "70400407"       
    ],
    "receiver" => [
      "name" => "Lene Jensen",
      "address1" => "Vindegade 112",
      "address2" => null,
      "country_code" => "DK",
      "zipcode" => "5000",
      "city" => "Odense C",
      "attention" => null,
      "email" => "lene@email.dk",
      "telephone" => "50607080",
      "mobile" => "50607080",
      "instruction" => null
    ],
    "parcels" => [
      [
        "weight" => 1000
      ]
    ],
  ];
  echo $client->createShipment($params);
?>

Get print queue entries

<?php
  $params = [
    'page' => 1
  ];
  echo print_r($client->getPrintQueueEntries($params);
?>

Get return portals

<?php
  $params = [
    'page' => 1
  ];
  echo $client->getReturnPortals($params);  
?>

Get return portal by id

<?php
  $id = 4766;
  echo $client->getReturnPortal($id);  
?>

Get return shipments for return portal

<?php
  $return_portal_id = 4766;
  $params = [
    'page' => 1
  ];
  echo $client->getReturnPortalShipments($return_portal_id, $params);  
?>

Pagination is supported

Get imported shipments

<?php
  $params = [
    'page' => 1
  ];
  echo $client->getImportedShipments($params);
?>

Pagination is supported

Get imported shipment by id

<?php
  $id = 75545625;
  echo $client->getImportedShipment($id);
?>

Create imported shipment

<?php
  $params = [
    "carrier_code" => "gls",
    "product_code" => "GLSDK_HD",
    "service_codes" => "EMAIL_NT,SMS_NT",
    "order_id" => "10001",
    "reference" => "Webshop 10001",
    "sender" => [
      "name" => "Shipmondo ApS",
      "address1" => "Strandvejen 6B",
      "address2" => null,
      "country_code" => "DK",
      "zipcode" => "5240",
      "city" => "Odense NØ",
      "attention" => null,
      "email" => "firma@email.dk",
      "telephone" => "70400407",
      "mobile" => "70400407"       
    ],
    "receiver" => [
      "name" => "Lene Jensen",
      "address1" => "Vindegade 112",
      "address2" => null,
      "country_code" => "DK",
      "zipcode" => "5000",
      "city" => "Odense C",
      "attention" => null,
      "email" => "lene@email.dk",
      "telephone" => "50607080",
      "mobile" => "50607080",
      "instruction" => null
    ]
  ];
  echo $client->createImportedShipment($params);
?>

Update imported shipment by id

<?php
  $id = 75545625;
  $params = [
    "carrier_code" => "gls",
    "product_code" => "GLSDK_HD",
    "service_codes" => "EMAIL_NT,SMS_NT",
    "order_id" => "10001",
    "reference" => "Webshop 10001",
    "sender" => [
      "name" => "Shipmondo ApS",
      "address1" => "Strandvejen 6B",
      "address2" => null,
      "country_code" => "DK",
      "zipcode" => "5240",
      "city" => "Odense NØ",
      "attention" => null,
      "email" => "firma@email.dk",
      "telephone" => "70400407",
      "mobile" => "70400407"       
    ],
    "receiver" => [
      "name" => "Lene Jensen",
      "address1" => "Vindegade 112",
      "address2" => null,
      "country_code" => "DK",
      "zipcode" => "5000",
      "city" => "Odense C",
      "attention" => null,
      "email" => "lene@email.dk",
      "telephone" => "50607080",
      "mobile" => "50607080",
      "instruction" => null
    ]
  ];
  echo $client->updateImportedShipment($id, $params);
?>

Delete/archive an imported shipment by id

<?php
  $id = 75545625;
  echo $client->deleteImportedShipment($id);
?>

Migrating from pakkelabels-php-sdk

If you have used the pakkelabels-php-sdk library and you want to upgrade to shipmondo_php_sdk, you have to do as follows:

  • Change Pakkelabels.php to Shipmondo.php in any require you use
  • Change references to the Pakkelabels and PakkelabelsException class to Shipmondo and ShipmondoException
  • All function calls must be changes to camelCase i.e. create_shipment -> createShipment
  • All GET function calls must add get in front of, as well as camelCase i.e. account_balance -> getAccountBalance