Skip to content

Instantly share code, notes, and snippets.

@casperbakker
Created April 30, 2021 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save casperbakker/82e892e4f34909a5e46c8fcbf44a1615 to your computer and use it in GitHub Desktop.
Save casperbakker/82e892e4f34909a5e46c8fcbf44a1615 to your computer and use it in GitHub Desktop.
Picqer example external shipping provider server
<?php
/**
* Test server for Picqer external shipping provider
* Config endpoint: server-example.php?action=config-options
* Label endpoint: server-example.php?action=label
*/
if (! isset($_GET['action']) || ! in_array($_GET['action'], ['config-options', 'label'])) {
echo 'action not understood';
exit;
}
if ($_GET['action'] == 'config-options') {
$configResponse = [
'version' => '1.0',
'data' => [
'items' => [
[
'key' => 'shipping_method',
'label' => 'Shipping method',
'description' => null,
'type' => 'list',
'possible_values' => [
[
'value' => 29,
'label' => 'DHLForYou'
],
[
'value' => 928,
'label' => 'DPD Global'
]
],
'default_value' => 928,
'required' => true
],
[
'key' => 'sender_address',
'label' => 'Sender',
'description' => 'Used as sender address on label',
'type' => 'list',
'possible_values' => [
[
'value' => 92828,
'label' => 'Picqer B.V., Meander 601, Arnhem'
],
[
'value' => 273682,
'label' => 'Karwei, Delta 39, Arnhem'
]
],
'default_value' => 92828,
'required' => true
],
[
'key' => 'insured',
'label' => 'Insured',
'description' => null,
'type' => 'list',
'possible_values' => [
[
'value' => 0,
'label' => 'No'
],
[
'value' => 1,
'label' => 'Yes'
]
],
'default_value' => 1,
],
[
'key' => 'pickup_instructions',
'label' => 'Pickup instructions',
'description' => null,
'type' => 'text',
'default_value' => null,
],
]
]
];
header('Content-Type: application/json');
echo json_encode($configResponse);
exit;
}
if ($_GET['action'] == 'label') {
$labelResponse = [
'version' => '1.0',
'data' => [
'carrier_key' => 'postnl',
'carrier_name' => 'PostNL',
'tracking_code' => '3S9393838',
'tracking_url' => 'https://example.com/XX',
'label' => [
'format' => 'A6',
'documents' => [
'pdf' => 'PDF TEST DOCS'
]
]
]
];
header('Content-Type: application/json');
echo json_encode($labelResponse);
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment