-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestShipment.php
109 lines (86 loc) · 2.73 KB
/
testShipment.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
require_once 'vendor/autoload.php';
use kruegge82\DPDAuthorisation;
use kruegge82\DPDShipment;
try{
// Second parameter to disable the wsdl cache defaults to true
$authorisation = new DPDAuthorisation([
'staging' => true,
'delisId' => '...',
'password' => '...',
'messageLanguage' => 'de_DE', // en_EN
'customerNumber' => '...'
]);
// Second parameter to disable the wsdl cache defaults to true
// $authorisation = new DPDAuthorisation($dpd, false);
// Init the shipment with authorisation
$shipment = new DPDShipment($authorisation);
// Second parameter to disable the wsdl cache defaults to true
// $shipment = new DPDShipment($authorisation, false);
// Set the language for the track&trace link
$shipment->setTrackingLanguage('de_DE');
// Enable saturday delivery
$shipment->setSaturdayDelivery(false);
// Enable DPD B2C delivery method
$shipment->setPredict([
'channel' => 'email',
'value' => '[email protected]',
'language' => 'EN'
]);
// Set the general shipmentdata
$shipment->setGeneralShipmentData([
'product' => 'CL',
'mpsCustomerReferenceNumber1' => 'Test shipment'
]);
// Set the printer options
$shipment->setPrintOptions([
'printerLanguage' => 'PDF', // ZPL
'paperFormat' => 'A6',
]);
// Set the sender's address
$shipment->setSender([
'name1' => 'Your Company',
'street' => 'Street 12',
'country' => 'DE',
'zipCode' => '12345',
'city' => 'Berlin',
'email' => '[email protected]',
'phone' => '1234567645'
]);
// Set the receiver's address
$shipment->setReceiver([
'name1' => 'Joh Doe',
'name2' => null,
'street' => 'Street',
'houseNo' => '12',
'zipCode' => '98765',
'city' => 'München',
'country' => 'DE',
'contact' => null,
'phone' => null,
'email' => null,
'comment' => null
]);
// Add as many parcels as you want
$shipment->addParcel([
'weight' => 3000, // In gram
'height' => 10, // In centimeters
'width' => 10,
'length' => 10
]);
$shipment->addParcel([
'weight' => 5000,
'height' => 20,
'width' => 30,
'length' => 20
]);
// Submit the shipment
$shipment->submit();
// Get the trackingdata
$trackinglinks = $shipment->getParcelResponses();
// Show the pdf label
header('Content-Type: application/pdf');
echo $shipment->getLabels();
}catch(Exception $e){
dump($e->getMessage());
}