|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* |
|
5
|
|
|
* NOTICE OF LICENSE |
|
6
|
|
|
* |
|
7
|
|
|
* This source file is subject to the GNU General Public License (GPL 3) |
|
8
|
|
|
* that is bundled with this package in the file LICENSE.txt |
|
9
|
|
|
* |
|
10
|
|
|
* DISCLAIMER |
|
11
|
|
|
* |
|
12
|
|
|
* Do not edit or add to this file if you wish to upgrade Payone to newer |
|
13
|
|
|
* versions in the future. If you wish to customize Payone for your |
|
14
|
|
|
* needs please refer to http://www.payone.de for more information. |
|
15
|
|
|
* |
|
16
|
|
|
* @category Payone |
|
17
|
|
|
* @package Payone_Api |
|
18
|
|
|
* @subpackage Response |
|
19
|
|
|
* @author Ronny Schröder |
|
20
|
|
|
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3) |
|
21
|
|
|
*/ |
|
22
|
|
|
class Payone_Api_Response_Genericpayment_Approved extends Payone_Api_Response_Genericpayment_Abstract { |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* add_paydata[workorderid] = workorderid from payone |
|
26
|
|
|
* add_paydata[...] = delivery data |
|
27
|
|
|
* @var Payone_Api_Response_Parameter_Paydata_Paydata |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $paydata = NULL; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @param array $params |
|
33
|
|
|
*/ |
|
34
|
|
|
function __construct(array $params = array()) { |
|
|
|
|
|
|
35
|
|
|
parent::__construct($params); |
|
36
|
|
|
$this->initPaydata($params); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
protected function initPaydata($param) { |
|
40
|
|
|
|
|
41
|
|
|
$payData = new Payone_Api_Response_Parameter_Paydata_Paydata($param); |
|
42
|
|
|
|
|
43
|
|
|
if ($payData->hasItems()) { |
|
44
|
|
|
$this->setPaydata($payData); |
|
45
|
|
|
} else { |
|
46
|
|
|
$this->setPaydata(NULL); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* usage: |
|
53
|
|
|
* $request = new Payone_Api_Request_Genericpayment(array_merge($this->getAccountData(), $requestData)); |
|
54
|
|
|
* $builder = $this->getPayoneBuilder(); |
|
55
|
|
|
* |
|
56
|
|
|
* $service = $builder->buildServicePaymentGenericpayment(); |
|
57
|
|
|
* $response = $service->request($request); |
|
58
|
|
|
* print_r($response->getPaydata()->toAssocArray()); |
|
59
|
|
|
* |
|
60
|
|
|
* you get an array like that: |
|
61
|
|
|
* |
|
62
|
|
|
* Array |
|
63
|
|
|
* ( |
|
64
|
|
|
* [shipping_zip] => 79111 |
|
65
|
|
|
* [shipping_country] => DE |
|
66
|
|
|
* [shipping_state] => Empty |
|
67
|
|
|
* [shipping_city] => Freiburg |
|
68
|
|
|
* [shipping_street] => ESpachstr. 1 |
|
69
|
|
|
* [shipping_firstname] => Max |
|
70
|
|
|
* [shipping_lastname] => Mustermann |
|
71
|
|
|
* ) |
|
72
|
|
|
* |
|
73
|
|
|
* @return Payone_Api_Response_Parameter_Paydata_Paydata |
|
74
|
|
|
*/ |
|
75
|
|
|
public function getPaydata() { |
|
76
|
|
|
return $this->paydata; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param Payone_Api_Response_Parameter_Paydata_Paydata $paydata |
|
81
|
|
|
*/ |
|
82
|
|
|
public function setPaydata($paydata) { |
|
83
|
|
|
$this->paydata = $paydata; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* |
|
88
|
|
|
* @return Payone_Api_Request_Parameter_Paydata_Paydata |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getPayDataArray() { |
|
91
|
|
|
$aPayData = array(); |
|
92
|
|
|
foreach($this->getPayData()->getItems() as $item) { |
|
93
|
|
|
$sCorrectedKey = strtolower($item->getKey()); |
|
94
|
|
|
$sCorrectedKey = str_replace('-', '_', $sCorrectedKey); |
|
95
|
|
|
$aPayData[$sCorrectedKey] = $item->getData(); |
|
96
|
|
|
} |
|
97
|
|
|
ksort($aPayData); |
|
98
|
|
|
return $aPayData; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function getInstallmentData() |
|
102
|
|
|
{ |
|
103
|
|
|
$aInstallmentData = array(); |
|
104
|
|
|
|
|
105
|
|
|
$aPayData = $this->getPayDataArray(); |
|
106
|
|
|
foreach ($aPayData as $sKey => $sValue) { |
|
107
|
|
|
$aSplit = explode('_', $sKey); |
|
108
|
|
|
for($i = count($aSplit); $i > 0; $i--) { |
|
109
|
|
|
if($i == count($aSplit)) { |
|
110
|
|
|
$aTmp = array($aSplit[$i-1] => $sValue); |
|
111
|
|
|
} else { |
|
112
|
|
|
$aTmp = array($aSplit[$i-1] => $aTmp); |
|
|
|
|
|
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
$aInstallmentData = array_replace_recursive($aInstallmentData, $aTmp); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
if(isset($aInstallmentData['paymentdetails']) && count($aInstallmentData['paymentdetails']) > 0) { |
|
119
|
|
|
return $aInstallmentData['paymentdetails']; |
|
120
|
|
|
} |
|
121
|
|
|
return false; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
|
|
125
|
|
|
} |
|
126
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.