Skip to content

Commit

Permalink
added deliveryDate and invoiceDate
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Pieters committed Feb 15, 2016
1 parent f7a8e3a commit c63fd60
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ $result = \Paynl\Transaction::start(array(
)
),
'language' => 'EN',
'ipaddress' => '127.0.0.1',
'invoiceDate' => new DateTime('2016-02-16'),
'deliveryDate' => new DateTime('2016-06-06'), // in case of tickets for an event, use the event date here
'enduser' => array(
'initials' => 'T',
'lastName' => 'Test',
Expand Down
5 changes: 4 additions & 1 deletion samples/transaction/start.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
try {
$result = \Paynl\Transaction::start(array(
// required
'amount' => 0.01,
'amount' => 10,
'returnUrl' => dirname(Paynl\Helper::getBaseUrl()) . '/return.php',

// optional
Expand All @@ -35,6 +35,9 @@
'extra1' => 'ext1',
'extra2' => 'ext2',
'extra3' => 'ext3',
'ipaddress' => '127.0.0.1',
'invoiceDate' => new DateTime('2016-02-16'),
'deliveryDate' => new DateTime('2016-06-06'),
'products' => array(
array(
'id' => 1,
Expand Down
31 changes: 31 additions & 0 deletions src/Api/Transaction/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,36 @@ class Start extends Transaction
*/
private $_ipaddress;

/**
* @var \DateTime
*/
private $_invoiceDate;
/**
* @var \DateTime
*/
private $_deliveryDate;

/**
* @var array the products for the order
*/
private $_products = array();

/**
* @param \DateTime $invoiceDate
*/
public function setInvoiceDate(\DateTime $invoiceDate)
{
$this->_invoiceDate = $invoiceDate;
}

/**
* @param \DateTime $deliveryDate
*/
public function setDeliveryDate(\DateTime $deliveryDate)
{
$this->_deliveryDate = $deliveryDate;
}

public function setIpAddress($ipAddress)
{
$this->_ipaddress = $ipAddress;
Expand Down Expand Up @@ -367,6 +392,12 @@ protected function getData()
if (!empty($this->_products)) {
$data['saleData']['orderData'] = $this->_products;
}
if(!empty($this->_deliveryDate)){
$data['saleData']['deliveryDate'] = $this->_deliveryDate->format('d-m-Y');
}
if(!empty($this->_invoiceDate)){
$data['saleData']['invoiceDate'] = $this->_invoiceDate->format('d-m-Y');
}

if (!empty($this->_enduser)) {
$data['enduser'] = $this->_enduser;
Expand Down
8 changes: 8 additions & 0 deletions src/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public static function start($options = array())
$api->setIpAddress($options['ipaddress']);
}

if(isset($options['invoiceDate'])){
$api->setInvoiceDate($options['invoiceDate']);
}

if(isset($options['deliveryDate'])){
$api->setDeliveryDate($options['deliveryDate']);
}

if (isset($options['products'])) {
foreach ($options['products'] as $product) {
$taxClass = Helper::calculateTaxClass($product['price'],
Expand Down

0 comments on commit c63fd60

Please sign in to comment.