-
Notifications
You must be signed in to change notification settings - Fork 9
/
IBANBluemRequest.php
108 lines (96 loc) · 2.77 KB
/
IBANBluemRequest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
namespace Bluem\BluemPHP\Requests;
use Bluem\BluemPHP\Contexts\IBANCheckContext;
use Bluem\BluemPHP\Interfaces\BluemRequestInterface;
/**
* IBAN Name Check Request object
*/
class IBANBluemRequest extends BluemRequest implements BluemRequestInterface {
public $request_url_type = "icr";
public $typeIdentifier = "createTransaction";
public $transaction_code = "INX";
private $xmlInterfaceName = "IBANCheckInterface";
private $_inputIban;
private $_inputName;
private $_debtorReference;
/**
* Construct the request and prepare all properties
*
* @param [type] $config
* @param [type] $entranceCode
* @param string $_inputIban
* @param string $_inputName
* @param string $_debtorReference
*/
public function __construct(
$config,
$entranceCode,
string $_inputIban,
string $_inputName,
string $_debtorReference = ""
) {
parent::__construct( $config, $entranceCode );
$this->_inputIban = $this->_sanitizeIban( $_inputIban );
$this->_inputName = $this->_sanitizeName( $_inputName );
$this->_debtorReference = $_debtorReference;
$this->context = new IBANCheckContext();
}
// @todo: deprecated, remove
/**
* Sanitize input IBAN for proper XML handling
*
* @param string $iban Given IBAN to sanitize
*
* @return string
*/
private function _sanitizeIban( string $iban ): string {
return trim(
str_replace( ' ', '', htmlentities( $iban ) )
);
}
/**
* Sanitize input Name for proper XML handling
*
* @param string $name Given name to check
*
* @return string
*/
private function _sanitizeName( string $name ): string {
return trim(
htmlentities( $name )
);
}
/**
* Retrieve the Bluem Transaction Type Code for this request
*
* @return string
*/
public function TransactionType(): string {
return "INX";
}
/**
* Generate XML string that is used in the request
*
* @return string
*/
public function XmlString(): string {
return $this->XmlRequestInterfaceWrap(
$this->xmlInterfaceName,
'TransactionRequest',
$this->XmlRequestObjectWrap(
'IBANCheckTransactionRequest',
PHP_EOL .
'<IBAN>' .
$this->_inputIban .
'</IBAN>' . PHP_EOL .
'<AssumedName>' .
$this->_inputName .
'</AssumedName>' . PHP_EOL .
'<DebtorReference>' .
$this->_debtorReference .
'</DebtorReference>' . PHP_EOL,
[]
)
);
}
}