Skip to content

Commit db7ab02

Browse files
author
Andy Pieters
committed
Enduser birthdate was not sent
1 parent f0ed654 commit db7ab02

File tree

2 files changed

+26
-17
lines changed

2 files changed

+26
-17
lines changed

src/Api/Transaction/Start.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@
1818

1919
namespace Paynl\Api\Transaction;
2020

21-
use Paynl\Helper;
2221
use Paynl\Config;
23-
use Paynl\Error\Required as ErrorRequired;
2422
use Paynl\Error\Error as Error;
23+
use Paynl\Error\Required as ErrorRequired;
24+
use Paynl\Helper;
25+
2526
/**
2627
* Api class to start a new transaction
2728
*
@@ -196,11 +197,13 @@ public function setTransferData($transferData)
196197
$this->_transferData = $transferData;
197198
}
198199

199-
public function setTransferType($transferType){
200+
public function setTransferType($transferType)
201+
{
200202
$this->_transferType = $transferType;
201203
}
202204

203-
public function setTransferValue($transferValue){
205+
public function setTransferValue($transferValue)
206+
{
204207
$this->_transferValue = $transferValue;
205208
}
206209

@@ -216,7 +219,7 @@ public function setTransferValue($transferValue){
216219
* @param int $vatCode
217220
* @throws Error
218221
*/
219-
public function addProduct($id, $description, $productType , $price, $quantity,
222+
public function addProduct($id, $description, $productType, $price, $quantity,
220223
$vatCode, $vatPercentage)
221224
{
222225
if (!is_numeric($price)) {
@@ -371,9 +374,14 @@ public function setDescription($description)
371374
$this->_description = $description;
372375
}
373376

377+
public function doRequest($endpoint = null, $version = null)
378+
{
379+
return parent::doRequest('transaction/start');
380+
}
381+
374382
protected function getData()
375383
{
376-
// Checken of alle verplichte velden geset zijn
384+
// Checken of alle verplichte velden geset zijn
377385
Helper::requireServiceId();
378386

379387
$data['serviceId'] = Config::getServiceId();
@@ -410,7 +418,7 @@ protected function getData()
410418
$data['transaction']['currency'] = $this->_currency;
411419
}
412420

413-
if(isset($this->_expireDate)){
421+
if (isset($this->_expireDate)) {
414422
$data['transaction']['expireDate'] = $this->_expireDate->format('d-m-Y H:i:s');
415423
}
416424

@@ -428,14 +436,18 @@ protected function getData()
428436
if (!empty($this->_products)) {
429437
$data['saleData']['orderData'] = $this->_products;
430438
}
431-
if(!empty($this->_deliveryDate)){
439+
if (!empty($this->_deliveryDate)) {
432440
$data['saleData']['deliveryDate'] = $this->_deliveryDate->format('d-m-Y');
433441
}
434-
if(!empty($this->_invoiceDate)){
442+
if (!empty($this->_invoiceDate)) {
435443
$data['saleData']['invoiceDate'] = $this->_invoiceDate->format('d-m-Y');
436444
}
437445

438446
if (!empty($this->_enduser)) {
447+
if ($this->_enduser['birthDate']) {
448+
$this->_enduser['dob'] = $this->_enduser['birthDate']->format('d-m-Y');
449+
unset($this->_enduser['birthDate']);
450+
}
439451
$data['enduser'] = $this->_enduser;
440452
}
441453

@@ -467,20 +479,15 @@ protected function getData()
467479
$data['statsData']['transferData'] = $this->_transferData;
468480
}
469481

470-
if(!empty($this->_transferType)){
482+
if (!empty($this->_transferType)) {
471483
$data['transferType'] = $this->_transferType;
472484
}
473-
if(!empty($this->_transferValue)){
485+
if (!empty($this->_transferValue)) {
474486
$data['transferValue'] = $this->_transferValue;
475487
}
476488

477489
$this->data = array_merge($data, $this->data);
478490

479491
return parent::getData();
480492
}
481-
482-
public function doRequest($endpoint = null, $version = null)
483-
{
484-
return parent::doRequest('transaction/start');
485-
}
486493
}

src/Transaction.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public static function start($options = array())
113113
foreach ($options['products'] as $product) {
114114
if(isset($product['tax'])) {
115115
$taxClass = Helper::calculateTaxClass($product['price'], $product['tax']);
116+
} else {
117+
$taxClass = Helper::calculateTaxClass($product['price'], 0);
116118
}
117119

118120
$taxPercentage = null;
@@ -133,7 +135,7 @@ public static function start($options = array())
133135
}
134136
$enduser = array();
135137
if (isset($options['enduser'])) {
136-
if (isset($options['enduser']['birthDate'])) {
138+
if (isset($options['enduser']['birthDate']) && is_string($options['enduser']['birthDate'])) {
137139
$options['enduser']['birthDate'] = new \DateTime($options['enduser']['birthDate']);
138140
}
139141
$enduser = $options['enduser'];

0 commit comments

Comments
 (0)