Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commercial Invoice #3

Open
ahmetinayet opened this issue Dec 5, 2022 · 1 comment
Open

Commercial Invoice #3

ahmetinayet opened this issue Dec 5, 2022 · 1 comment

Comments

@ahmetinayet
Copy link

ahmetinayet commented Dec 5, 2022

Hello, I get these errors when I try to create a commercial invoice, can you help me to solve it?

My Code
`
$credentials = new Credentials(true);
$credentials
->setUsername('xxx')
->setPassword('xxx');

$customerLogo = new CustomerLogo();
$customerLogo
	->setLogoImage(base64_encode(file_get_contents('https://xxx.com/xxx.png')))
	->setLogoImageFormat(CustomerLogo::IMAGE_FORMAT_PNG);

$labelOptions = new LabelOptions();
$labelOptions
	->setCustomerLogo($customerLogo)
	->setHideAccountInWaybillDocument("false")
	->setAllInOnePDF("true")
	->setRequestDHLCustomsInvoice("true");

$specialService = new SpecialService();
$specialService
	->setServiceType(SpecialService::INTERNATIONAL_DUTY_NEUTRAL_DELIVERY_SERVICE);

$shipmentInfo = new ShipmentInfo();
$shipmentInfo
	->setDropOffType(ShipmentInfo::DROP_OFF_TYPE_REGULAR_PICKUP)
	->setServiceType(ShipmentInfo::SERVICE_TYPE_EXPRESS_WORLDWIDE_NON_DOC)
	->setAccount('xxx')
	->setCurrency($ordersItemCurrency)
	->setUnitOfMeasurement(ShipmentInfo::UNIT_OF_MEASRUREMENTS_KG_CM)
	->setLabelType(ShipmentInfo::LABEL_TYPE_PDF)
	->setLabelTemplate(ShipmentInfo::LABEL_TEMPLATE_ECOM_TC_A4)
	->setCustomsInvoiceTemplate("COMMERCIAL_INVOICE_03")
	->setPaperlessTradeEnabled(true)
	->addSpecialService($specialService)
	->setLabelOptions($labelOptions);



$shipperContact = new Contact();
$shipperContact
	->setPersonName($data['dhlConfig']['dhlConfig_personalName'])
	->setCompanyName($data['dhlConfig']['dhlConfig_companyName'])
	->setPhoneNumber($data['dhlConfig']['dhlConfig_phone'])
	->setEmailAddress('[email protected]');

$shipperAddress = new Address();
$shipperAddress
	->setStreetLines($data['dhlConfig']['dhlConfig_address1'] . " " . $data['dhlConfig']['dhlConfig_address2'])
	->setCity($data['dhlConfig']['dhlConfig_city'])
	->setPostalCode($data['dhlConfig']['dhlConfig_postalCode'])
	->setCountryCode('TR');

$shipper = new Shipper();
$shipper
	->setContact($shipperContact)
	->setAddress($shipperAddress);

$recipientContact = new Contact();
$recipientContact
	->setPersonName($ordersFullName)
	->setCompanyName($ordersFullName)
	->setPhoneNumber($ordersPhone)
	->setEmailAddress($ordersEmail);

$recipientAddress = new Address();
$recipientAddress
	->setStreetLines($ordersAddress1 . " " . $ordersAddress2 . " " . $ordersAddress3)
	->setCity($ordersCity)
	->setPostalCode($ordersPostalCode)
	->setCountryCode($ordersCountry);

$recipient = new Recipient();
$recipient
	->setContact($recipientContact)
	->setAddress($recipientAddress);

$ship = new Ship();
$ship
	->setShipper($shipper)
	->setRecipient($recipient);

$package1 = new RequestedPackage();
$package1
	->setWeight($ordersWeight)
	->setDimensions($ordersWidth, $ordersHeight, $ordersLength)
	->setCustomerReferences('Box 1');

$packages = new Packages();
$packages
	->addRequestedPackage($package1);

$commodities = new Commodities();
$commodities
	->setDescription($data['ordersItems'][0]['ordersItem_name'])
	->setCustomsValue($totalItems);

$exportLineItems = new ExportLineItems();
$jj = 1;
foreach ($data['ordersItems'] as $orderItem) {
	$exportLineItem = new ExportLineItem();
	$exportLineItem
		->setItemNumber($jj)
		->setQuantity($orderItem['ordersItem_quantity'])
		->setItemDescription($orderItem['ordersItem_name'])
		->setUnitPrice($orderItem['ordersItem_unitPrice'])
		->setNetWeight(1)
		->setGrossWeight(1)
		->setManufacturingCountryCode("TR");

	$exportLineItems
		->addexportLineItem($exportLineItem);
	$jj++;
}

$exportDeclaration = new ExportDeclaration();
$exportDeclaration
	->setExportLineItems($exportLineItems)
	->setInvoiceNumber($ordersOrderNumber);
$exportDeclaration
	->setInvoiceDate(date('Y-m-d'));

// The InternationalDetail seems to be required even if its a domestic package
$internationalDetail = new InternationalDetail();
$internationalDetail
	->setCommodities($commodities)
	->setContent(InternationalDetail::CONTENT_NON_DOCUMENTS)
	->setExportDeclaration($exportDeclaration);

// $documentImage = new DocumentImage();
// $documentImage
// 	->setDocumentImageType(DocumentImage::DOCUMENT_IMAGE_TYPE_INVOICE)
// 	->setDocumentImage(DocumentImage::DOCUMENT_IMAGE_TYPE_COMMERCIAL_INVOICE)
// 	->setDocumentImageFormat(DocumentImage::DOCUMENT_IMAGE_FORMAT_PDF);

$timestamp = new DateTime("now", new DateTimeZone("Europe/Berlin"));
$timestamp->modify('+3 days');

if ($ordersSendMethod == 1) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_DELIVERY_DUTY_PAID)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "DDP ";
} elseif ($ordersSendMethod == 2) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_DELIVERED_AT_PLACE)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "DAP ";
} elseif ($ordersSendMethod == 3) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_EX_WORKS)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "EXW ";
} elseif ($ordersSendMethod == 4) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_CARRIAGE_AND_INSURANCE_PAID_TO)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "CIP ";
} elseif ($ordersSendMethod == 5) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_DELIVERY_DUTY_PAID)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$termsOfSale = "DAT";
	$atrValue .= "DAT ";
} elseif ($ordersSendMethod == 6) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_DELIVERY_DUTY_PAID)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$termsOfSale = "DPU";
	$atrValue .= "DPU ";
} elseif ($ordersSendMethod == 7) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_FREE_CARRIER)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "FCA ";
} elseif ($ordersSendMethod == 8) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_CARRIAGE_PAID_TO)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "CPT ";
} elseif ($ordersSendMethod == 9) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_FREE_ALONGSIDE_SHIP)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "FAS ";
} elseif ($ordersSendMethod == 10) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_FREE_ON_BOARD)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "FOB ";
} elseif ($ordersSendMethod == 11) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_COST_AND_FREIGHT)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "CFR ";
} elseif ($ordersSendMethod == 12) {
	$requestedShipment = new RequestedShipment();
	$requestedShipment
		->setShipmentInfo($shipmentInfo)
		->setShipTimestamp($timestamp)
		->setPaymentInfo(RequestedShipment::PAYMENT_INFO_COST_INSURANCE_AND_FREIGHT)
		->setShip($ship)
		->setPackages($packages)
		->setInternationalDetail($internationalDetail);
	$atrValue .= "CIF ";
}

$shipment = new ShipmentRequest($credentials);
$shipment->setRequestedShipment($requestedShipment);
$responses = $shipment->send();`

[ISC.0082.9460] No matching enumeration value ------------ shipreq:ShipmentRequest/RequestedShipment/ShipmentInfo/LabelOptions/HideAccountInWaybillDocument
Process failure occurred. Process ID associated for that transaction (521012451)

[ISC.0082.9460] No matching enumeration value ------------ shipreq:ShipmentRequest/RequestedShipment/ShipmentInfo/LabelOptions/RequestDHLCustomsInvoice

[ISC.0082.9460] No matching enumeration value ------------ /shipreq:ShipmentRequest/RequestedShipment/ShipmentInfo/LabelOptions/DetachOptions/AllInOnePDF

@alex-LE
Copy link
Owner

alex-LE commented Dec 5, 2022

Hmm, sorry, i'm not working on this stuff for a while now and it seems that DHL Express has updated the API to v2. Are you using v2? This SDK is still for v1. I couldn't find a documentation for v1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants