Skip to content

Commit 71333ac

Browse files
author
Andy Pieters
committed
Made ipaddress configurable
Put some more functions in the transaction info result
1 parent b4c80f2 commit 71333ac

File tree

4 files changed

+64
-6
lines changed

4 files changed

+64
-6
lines changed

src/Api/Transaction/Start.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,14 @@ class Start extends Api
4949
private $_object;
5050
private $_domainId;
5151
private $_transferData;
52+
private $_ipaddress;
53+
5254
private $_products = array();
5355

56+
public function setIpAddress($ipAddress){
57+
$this->_ipaddress = $ipAddress;
58+
}
59+
5460
public function setPromotorId($promotorId)
5561
{
5662
$this->_promotorId = $promotorId;
@@ -288,12 +294,14 @@ protected function getData()
288294
$data['paymentOptionSubId'] = $this->_paymentOptionSubId;
289295
}
290296

291-
//ip en browserdata setten browserdata set ik met dummydata
292-
$data['ipAddress'] = Helper::getIp();
297+
298+
if(isset($this->_ipaddress)){
299+
$data['ipAddress'] = $this->_ipaddress;
300+
} else {
301+
$data['ipAddress'] = Helper::getIp();
302+
}
293303

294304
if (!empty($this->_products)) {
295-
// $data['saleData']['invoiceDate'] = date('d-m-Y');
296-
// $data['saleData']['deliveryDate'] = date('d-m-Y', strtotime('+1 day'));
297305
$data['saleData']['orderData'] = $this->_products;
298306
}
299307

src/Helper.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,26 @@ public static function calculateTaxClass($amountInclTax, $taxAmount)
116116
return($taxClasses[$nearestTaxRate]);
117117
}
118118

119+
public static function splitAddress($strAddress)
120+
{
121+
$strAddress = trim($strAddress);
122+
123+
$a = preg_split('/([0-9]+)/', $strAddress, 2,
124+
PREG_SPLIT_DELIM_CAPTURE);
125+
$strStreetName = trim(array_shift($a));
126+
$strStreetNumber = trim(implode('', $a));
127+
128+
if (empty($strStreetName)) { // American address notation
129+
$a = preg_split('/([a-zA-Z]{2,})/', $strAddress, 2,
130+
PREG_SPLIT_DELIM_CAPTURE);
131+
132+
$strStreetNumber = trim(array_shift($a));
133+
$strStreetName = implode(' ', $a);
134+
}
135+
136+
return array($strStreetName, $strStreetNumber);
137+
}
138+
119139
public static function getBaseUrl()
120140
{
121141
$protocol = isset($_SERVER["HTTPS"]) ? 'https' : 'http';

src/Result/Transaction.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,32 @@ public function isPending(){
3737
public function isCanceled(){
3838
return $this->data['paymentDetails']['state'] < 0;
3939
}
40+
public function getPaidAmount(){
41+
return $this->data['paymentDetails']['paidAmount']/100;
42+
}
43+
public function getPaidCurrency(){
44+
return $this->data['paymentDetails']['paidCurrency'];
45+
}
46+
public function getAccountHolderName(){
47+
return $this->data['paymentDetails']['identifierName'];
48+
}
49+
public function getAccountNumber(){
50+
return $this->data['paymentDetails']['identifierPublic'];
51+
}
52+
public function getAccountHash(){
53+
return $this->data['paymentDetails']['identifierHash'];
54+
}
55+
public function getDescription(){
56+
return $this->data['paymentDetails']['description'];
57+
}
58+
public function getExtra1(){
59+
return $this->data['statsDetails']['extra1'];
60+
}
61+
public function getExtra2(){
62+
return $this->data['statsDetails']['extra2'];
63+
}
64+
public function getExtra3(){
65+
return $this->data['statsDetails']['extra3'];
66+
}
67+
4068
}

src/Transaction.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ public static function start($options = array())
7474
$api->setExtra3($options['extra3']);
7575
}
7676

77+
if(isset($options['ipaddress'])){
78+
$api->setIpAddress($options['ipaddress']);
79+
}
80+
7781
if (isset($options['products'])) {
7882
foreach ($options['products'] as $product) {
7983
$taxClass = Helper::calculateTaxClass($product['price'],
@@ -189,8 +193,6 @@ public static function getForExchange()
189193
$input = file_get_contents('php://input');
190194
$xml = simplexml_load_string($input);
191195

192-
193-
194196
$transactionId = $xml->order_id;
195197
}
196198

0 commit comments

Comments
 (0)