diff --git a/samples/transaction/start.php b/samples/transaction/start.php index 7c9198ea..426c0c9f 100644 --- a/samples/transaction/start.php +++ b/samples/transaction/start.php @@ -28,14 +28,15 @@ // optional 'exchangeUrl' => dirname(Paynl\Helper::getBaseUrl()) . '/exchange.php', 'paymentMethod' => 10, - 'currency' => 'USD', - 'bank' => 1, - 'description' => 'demo betaling', - 'testmode' => 1, + 'currency' => 'EUR', + 'expireDate' => new DateTime('2016-04-01'), +// 'bank' => 1, + 'description' => '123456', + 'testmode' => 0, 'extra1' => 'ext1', 'extra2' => 'ext2', 'extra3' => 'ext3', - 'ipaddress' => '127.0.0.1', + 'ipaddress' => \Paynl\Helper::getIp(), 'invoiceDate' => new DateTime('now'), 'deliveryDate' => new DateTime('2016-06-06'), // in case of tickets for an event, use the event date here 'products' => array( diff --git a/src/Api/Transaction/Start.php b/src/Api/Transaction/Start.php index c326a3e6..cc5ceeba 100644 --- a/src/Api/Transaction/Start.php +++ b/src/Api/Transaction/Start.php @@ -124,6 +124,20 @@ class Start extends Transaction */ private $_products = array(); + /** + * @var \DateTime + */ + private $_expireDate; + + /** + * @param \DateTime $expireDate + */ + public function setExpireDate(\DateTime $expireDate) + { + $this->_expireDate = $expireDate; + } + + /** * @param \DateTime $invoiceDate */ @@ -378,6 +392,10 @@ protected function getData() $data['transaction']['currency'] = $this->_currency; } + if(isset($this->_expireDate)){ + $data['transaction']['expireDate'] = $this->_expireDate->format('d-m-Y H:i:s'); + } + if (!empty($this->_paymentOptionSubId)) { $data['paymentOptionSubId'] = $this->_paymentOptionSubId; } diff --git a/src/Transaction.php b/src/Transaction.php index 13ebb5b4..92d4fc53 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -47,6 +47,9 @@ public static function start($options = array()) if (isset($options['currency'])) { $api->setCurrency($options['currency']); } + if(isset($options['expireDate'])){ + $api->setExpireDate($options['expireDate']); + } if (isset($options['returnUrl'])) { $api->setFinishUrl($options['returnUrl']); diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index c617018a..21f4b8ce 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -26,16 +26,25 @@ public function testServiceId() public function testApiVersion() { - \Paynl\Config::setServiceId('api-version'); + \Paynl\Config::setApiVersion(4); - $this->assertEquals('api-version', \Paynl\Config::getServiceId()); + $this->assertEquals(4, \Paynl\Config::getApiVersion()); } public function testApiUrl() { + \Paynl\Config::setApiVersion(4); + $this->assertEquals( - 'https://rest-api.pay.nl/v5/transaction/json', - \Paynl\Config::getApiUrl('transaction', 5) + 'https://rest-api.pay.nl/v4/transaction/json', + \Paynl\Config::getApiUrl('transaction') ); } + public function testGetCurlDefault(){ + $this->assertInstanceOf('\Curl\Curl', \Paynl\Config::getCurl()); + } + public function testGetCurlCustom(){ + \Paynl\Config::setCurl(new DateTime()); + $this->assertInstanceOf('\DateTime', \Paynl\Config::getCurl()); + } }