Skip to content

Commit

Permalink
Added shipping and tax info
Browse files Browse the repository at this point in the history
  • Loading branch information
Mosnar committed Jul 16, 2020
1 parent b45fac5 commit 4909b1e
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 3 deletions.
93 changes: 92 additions & 1 deletion src/Message/AIMAbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,67 @@ public function setAuthCode($value)
return $this->setParameter('authCode', $value);
}

public function getTaxAmount()
{
return $this->getParameter('taxAmount');
}

public function setTaxAmount($value)
{
return $this->setParameter('taxAmount', $value);
}

public function getTaxName()
{
return $this->getParameter('taxName');
}

public function setTaxName($value)
{
return $this->setParameter('taxName', $value);
}

public function getTaxDescription()
{
return $this->getParameter('taxDescription');
}

public function setTaxDescription($value)
{
return $this->setParameter('taxDescription', $value);
}


public function getShippingAmount()
{
return $this->getParameter('shippingAmount');
}

public function setShippingAmount($value)
{
return $this->setParameter('shippingAmount', $value);
}

public function getShippingName()
{
return $this->getParameter('shippingName');
}

public function setShippingName($value)
{
return $this->setParameter('shippingName', $value);
}

public function getShippingDescription()
{
return $this->getParameter('shippingDescription');
}

public function setShippingDescription($value)
{
return $this->setParameter('shippingDescription', $value);
}

/**
* @return TransactionReference
*/
Expand Down Expand Up @@ -295,7 +356,8 @@ protected function addSolutionId(\SimpleXMLElement $data)
}
}

protected function addOrderData(\SimpleXMLElement $data) {
protected function addOrderData(\SimpleXMLElement $data)
{

/** @var mixed $req */
$req = $data->transactionRequest;
Expand Down Expand Up @@ -412,4 +474,33 @@ protected function addItemData(\SimpleXMLElement $data)

return $data;
}


protected function addTaxData(\SimpleXMLElement $data)
{
if ($this->getTaxAmount() !== null) {
$data->transactionRequest->tax->amount = $this->getTaxAmount();
}
if ($this->getTaxName() !== null) {
$data->transactionRequest->tax->name = $this->getTaxName();
}
if ($this->getTaxDescription() !== null) {
$data->transactionRequest->tax->description = $this->getTaxDescription();
}
return $data;
}

protected function addShippingData(\SimpleXMLElement $data)
{
if ($this->getShippingAmount() !== null) {
$data->transactionRequest->shipping->amount = $this->getTaxAmount();
}
if ($this->getShippingName() !== null) {
$data->transactionRequest->shipping->name = $this->getShippingName();
}
if ($this->getShippingDescription() !== null) {
$data->transactionRequest->shipping->description = $this->getShippingDescription();
}
return $data;
}
}
4 changes: 2 additions & 2 deletions src/Message/AIMAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public function getData()
$this->addSolutionId($data);
$this->addOrderData($data);
$this->addItemData($data);
// Tax would go here
$this->addTaxData($data);
// Duty would go here
// Shipping would go here
$this->addShippingData($data);
// poNumber would go here
// taxExempt would go here
$this->addBillingData($data); // Also includes shipping data
Expand Down

0 comments on commit 4909b1e

Please sign in to comment.