Skip to content

Commit 3674cb9

Browse files
author
Marco Dania
committed
allow xml namespace to be set
1 parent 1492952 commit 3674cb9

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/Client.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class Client {
9191
*/
9292
protected $logger;
9393

94+
/**
95+
* @var Generator
96+
*/
97+
protected $generator;
98+
9499
/**
95100
* @param string $username
96101
* @param string $password
@@ -546,8 +551,11 @@ public function getOptions($identifier, $args = null, $_ = null) {
546551
/**
547552
* @return Generator
548553
*/
549-
protected function getGenerator() {
550-
return new Generator();
554+
public function getGenerator() {
555+
if (!$this->generator) {
556+
$this->generator = new Generator();
557+
}
558+
return $this->generator;
551559
}
552560

553561
/**

src/Xml/Generator.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ class Generator {
3333
*/
3434
protected $document;
3535

36+
/**
37+
* @var string
38+
*/
39+
protected $namespaceRoot = 'http://gateway.ixopay.com';
40+
41+
/**
42+
* @param string $namespaceRoot
43+
*/
44+
public function setNamespaceRoot($namespaceRoot) {
45+
$this->namespaceRoot = $namespaceRoot;
46+
}
47+
3648
/**
3749
* @param string $method
3850
* @param AbstractTransaction $transaction
@@ -44,7 +56,7 @@ class Generator {
4456
public function generateTransaction($method, AbstractTransaction $transaction, $username, $password, $language=null) {
4557
$this->document = new \DOMDocument('1.0', 'utf-8');
4658
$this->document->formatOutput = true;
47-
$root = $this->document->createElementNS('http://gateway.ixopay.com/Schema/V2/Transaction', 'transaction');
59+
$root = $this->document->createElementNS($this->namespaceRoot . '/Schema/V2/Transaction', 'transaction');
4860

4961
$this->_appendTextNode($root, 'username', $username);
5062
$this->_appendTextNode($root, 'password', $password);
@@ -107,7 +119,7 @@ public function generateTransaction($method, AbstractTransaction $transaction, $
107119
public function generateOptions($username, $password, $identifier, $parameters=array()) {
108120
$this->document = new \DOMDocument('1.0', 'utf-8');
109121
$this->document->formatOutput = true;
110-
$root = $this->document->createElementNS('http://gateway.ixopay.com/Schema/V2/Options', 'options');
122+
$root = $this->document->createElementNS($this->namespaceRoot . '/Schema/V2/Options', 'options');
111123
$this->document->appendChild($root);
112124

113125
$this->_appendTextNode($root, 'username', $username);

0 commit comments

Comments
 (0)