diff --git a/src/Entity/PaymentInformation.php b/src/Entity/PaymentInformation.php index 7a074b4..a4f7b7a 100644 --- a/src/Entity/PaymentInformation.php +++ b/src/Entity/PaymentInformation.php @@ -21,6 +21,11 @@ class PaymentInformation */ private $billThirdParty; + /** + * @var BillThirdParty + */ + private $billThirdPartyConsignee; + /** * @var FreightCollect */ diff --git a/src/Entity/ShipmentCharge.php b/src/Entity/ShipmentCharge.php index 0155b27..774f4d3 100644 --- a/src/Entity/ShipmentCharge.php +++ b/src/Entity/ShipmentCharge.php @@ -33,6 +33,11 @@ class ShipmentCharge */ private $billThirdParty; + /** + * @var BillThirdParty + */ + private $billThirdPartyConsignee; + /** * @var bool */ @@ -105,6 +110,25 @@ public function setBillThirdParty(BillThirdParty $billThirdParty = null) return $this; } + /** + * @return BillThirdParty + */ + public function getBillThirdPartyConsignee() + { + return $this->billThirdPartyConsignee; + } + + /** + * @param BillThirdParty $billThirdPartyConsignee + * @return ShipmentCharge + */ + public function setBillThirdPartyConsignee(BillThirdParty $billThirdPartyConsignee = null) + { + $this->billThirdPartyConsignee = $billThirdPartyConsignee; + + return $this; + } + /** * @return bool */ diff --git a/src/Shipping.php b/src/Shipping.php index 92e3c49..c0b8da4 100644 --- a/src/Shipping.php +++ b/src/Shipping.php @@ -355,16 +355,30 @@ private function createConfirmRequest( $node = $node->appendChild($xml->createElement('BillThirdParty')); $btpNode = $node->appendChild($xml->createElement('BillThirdPartyShipper')); $btpNode->appendChild($xml->createElement('AccountNumber', $rec->getBillThirdParty()->getAccountNumber())); - + $tpNode = $btpNode->appendChild($xml->createElement('ThirdParty')); $addressNode = $tpNode->appendChild($xml->createElement('Address')); - + $thirdPartAddress = $rec->getBillThirdParty()->getThirdPartyAddress(); if (isset($thirdPartAddress) && $rec->getBillThirdParty()->getThirdPartyAddress()->getPostalCode()) { $addressNode->appendChild($xml->createElement('PostalCode', $rec->getBillThirdParty()->getThirdPartyAddress()->getPostalCode())); } - + $addressNode->appendChild($xml->createElement('CountryCode', $rec->getBillThirdParty()->getThirdPartyAddress()->getCountryCode())); + } elseif ($rec->getBillThirdPartyConsignee()) { + $node = $node->appendChild($xml->createElement('BillThirdParty')); + $btpNode = $node->appendChild($xml->createElement('BillThirdPartyConsignee')); + $btpNode->appendChild($xml->createElement('AccountNumber', $rec->getBillThirdPartyConsignee()->getAccountNumber())); + + $tpNode = $btpNode->appendChild($xml->createElement('ThirdParty')); + $addressNode = $tpNode->appendChild($xml->createElement('Address')); + + $thirdPartAddress = $rec->getBillThirdPartyConsignee()->getThirdPartyAddress(); + if (isset($thirdPartAddress) && $rec->getBillThirdPartyConsignee()->getThirdPartyAddress()->getPostalCode()) { + $addressNode->appendChild($xml->createElement('PostalCode', $rec->getBillThirdPartyConsignee()->getThirdPartyAddress()->getPostalCode())); + } + + $addressNode->appendChild($xml->createElement('CountryCode', $rec->getBillThirdPartyConsignee()->getThirdPartyAddress()->getCountryCode())); } elseif ($rec->getConsigneeBilled()) { $node->appendChild($xml->createElement('ConsigneeBilled')); }