1818
1919namespace Paynl \Api \Transaction ;
2020
21- use Paynl \Helper ;
2221use Paynl \Config ;
23- use Paynl \Error \Required as ErrorRequired ;
2422use 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}
0 commit comments