Created
April 30, 2021 15:00
-
-
Save casperbakker/82e892e4f34909a5e46c8fcbf44a1615 to your computer and use it in GitHub Desktop.
Picqer example external shipping provider server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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