Skip to content

Commit

Permalink
Merge pull request #24 from jeffreyzant/master
Browse files Browse the repository at this point in the history
Send (type redirect) REST request with items #14
  • Loading branch information
delatbabel committed May 28, 2017
2 parents 9c08690 + 0892f58 commit 6d7a6d6
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion src/Message/RestPurchaseRequest.php
Expand Up @@ -383,6 +383,26 @@ public function setGoogleAnalyticsCode($value)
return $this->setParameter('google_analytics', $value);
}

/**
* Get items HTML
*
* @return string
*/
public function setItemsHtml($itemsHtml)
{
$this->setParameter('itemsHtml', $itemsHtml);
}

/**
* Get items HTML
*
* @return string
*/
public function getItemsHtml()
{
return $this->getParameter('itemsHtml');
}

/**
* Get the payment options.
*
Expand Down Expand Up @@ -452,6 +472,29 @@ protected function getGatewayData()
return array_filter($data);
}

/**
* Get itembag data.
*
* @return array
*/
protected function getItemBagData()
{
$items = array();
$itemBag = $this->getItems();
if (! empty($itemBag)) {
foreach ($itemBag->all() as $item) {
$items[] = array(
'name' => $item->getName(),
'description' => $item->getDescription(),
'quantity' => $item->getQuantity(),
'unit_price' => $item->getPrice(),
);
}
}

return $items;
}

/**
* Get the raw data array for this message. The format of this varies from gateway to
* gateway, but will usually be either an associative array, or a SimpleXMLElement.
Expand Down Expand Up @@ -492,7 +535,7 @@ public function getData()
'description' => $this->getDescription(),
'gateway' => $this->getGateway(),
'google_analytics' => $this->getGoogleAnalyticsCode(),
'items' => $this->getItems(),
'items' => $this->getItemsHtml(),
'manual' => $this->getManual(),
'order_id' => $this->getTransactionId(),
'recurring_id' => $this->getRecurringId(),
Expand Down Expand Up @@ -520,6 +563,12 @@ public function getData()
$data['gateway_info'] = $gatewayData;
}

$getItemBagData = $this->getItemBagData();

if (! empty($getItemBagData)) {
$data['shopping_cart']['items'] = $getItemBagData;
}

return array_filter($data);
}

Expand Down

0 comments on commit 6d7a6d6

Please sign in to comment.