Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow BillThirdPartyConsignee to be set in ItemizedPaymentInformation #343

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Entity/PaymentInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class PaymentInformation
*/
private $billThirdParty;

/**
* @var BillThirdParty
*/
private $billThirdPartyConsignee;

/**
* @var FreightCollect
*/
Expand Down
24 changes: 24 additions & 0 deletions src/Entity/ShipmentCharge.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class ShipmentCharge
*/
private $billThirdParty;

/**
* @var BillThirdParty
*/
private $billThirdPartyConsignee;

/**
* @var bool
*/
Expand Down Expand Up @@ -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
*/
Expand Down
20 changes: 17 additions & 3 deletions src/Shipping.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
Expand Down