Skip to content

Commit

Permalink
Merge pull request #4 from adequaat/feature/confirm-api
Browse files Browse the repository at this point in the history
Feature/confirm api
  • Loading branch information
sytheveenje committed May 11, 2023
2 parents c18cdd2 + 174a86a commit 74c9b0b
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions src/LaravelPostnlApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,57 @@ public function generateLabelForMultiCollo(
return $responseShipments;

}

/**
* @param $barcode string|null
* @param string $printertype
* @param array|null $address [AddressType, City, CompanyName, Countrycode, HouseNr, Zipcode, Street]
* @param array|null $contact [ContactType, Email, SMSNr]
* @param string $productCodeDelivery
* @param $reference string|null
* @param $remark string|null
* @param bool $fullLabel
* @return void
*
* This method uses the Confirming API
* https://developer.postnl.nl/browse-apis/send-and-track/confirming-webservice/
*
* BvdT needs this because we create the labels locally (custom labels)
* and confirm the parcels for PostNL later on.
*/
public function confirmShipment(
string $barcode = null,
array $address = null,
array $contact = null,
string $productCodeDelivery = '3085',
string $reference = null,
string $remark = null
)
{

$response = Http::withHeaders([
'apikey' => config('postnl-api.api.key'),
'Content-Type' => 'application/json'
])->post(env('POSTNL_API_BASE_URL').'shipment/v2_2/confirm',
[
'Customer' => $this->customer,
'Message' => [
'MessageTimeStamp' => Carbon::now()->format('dd-mm-yyyy hh:mm:ss'),
'Printertype' => $printertype,
],
'Shipments' => [
'Addresses' => $address,
'Contacts' => $contact,
'ProductCodeDelivery' => $productCodeDelivery,
'Barcode' => $barcode,
'Reference' => $reference,
'Remark' => $remark,
],
]);

if($response->successful()) {
return collect($response->object()->ResponseShipments)->first();
}

}
}

0 comments on commit 74c9b0b

Please sign in to comment.