From c63fd601723c7cb1a357a5d6e00eb7b8cc4bdbec Mon Sep 17 00:00:00 2001 From: Andy Pieters Date: Mon, 15 Feb 2016 15:14:44 +0100 Subject: [PATCH] added deliveryDate and invoiceDate --- README.md | 3 +++ samples/transaction/start.php | 5 ++++- src/Api/Transaction/Start.php | 31 +++++++++++++++++++++++++++++++ src/Transaction.php | 8 ++++++++ 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0704dcc5..5726545c 100644 --- a/README.md +++ b/README.md @@ -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', diff --git a/samples/transaction/start.php b/samples/transaction/start.php index 99f40d03..895d0df8 100644 --- a/samples/transaction/start.php +++ b/samples/transaction/start.php @@ -22,7 +22,7 @@ try { $result = \Paynl\Transaction::start(array( // required - 'amount' => 0.01, + 'amount' => 10, 'returnUrl' => dirname(Paynl\Helper::getBaseUrl()) . '/return.php', // optional @@ -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, diff --git a/src/Api/Transaction/Start.php b/src/Api/Transaction/Start.php index 304a3794..c326a3e6 100644 --- a/src/Api/Transaction/Start.php +++ b/src/Api/Transaction/Start.php @@ -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; @@ -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; diff --git a/src/Transaction.php b/src/Transaction.php index c2c61ae9..13ebb5b4 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -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'],