Skip to content

Commit a0f09ab

Browse files
committed
Merge pull request #2 from jasonvarga/master
Change items parameter to a string
2 parents 29f1b79 + 8b460fb commit a0f09ab

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/Message/PurchaseRequest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,17 @@ public function getData()
138138
$transaction->addChild('var1', $this->getExtraData1());
139139
$transaction->addChild('var2', $this->getExtraData2());
140140
$transaction->addChild('var3', $this->getExtraData3());
141-
$transaction->addChild('items', $this->getItems());
142141
$transaction->addChild('gateway', $this->getGateway());
143142

143+
if ($items = $this->getItems()) {
144+
$itemsHtml = '<ul>';
145+
foreach ($items as $item) {
146+
$itemsHtml .= "<li>{$item['quantity']} x {$item['name']}</li>";
147+
}
148+
$itemsHtml .= '</ul>';
149+
$transaction->addChild('items', $itemsHtml);
150+
}
151+
144152
if ('IDEAL' === $this->getGateway() && $this->getIssuer()) {
145153
$gatewayInfo = $data->addChild('gatewayinfo');
146154
$gatewayInfo->addChild('issuerid', $this->getIssuer());

tests/Message/PurchaseRequestTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ protected function setUp()
3232
'extraData2' => 'extra 2',
3333
'extraData3' => 'extra 3',
3434
'language' => 'a language',
35-
'items' => 'the items',
35+
'items' => array(
36+
array('name' => 'item 1', 'quantity' => 1),
37+
array('name' => 'item 2', 'quantity' => 2)
38+
),
3639
'clientIp' => '127.0.0.1',
3740
'googleAnalyticsCode' => 'analytics code',
3841
'card' => array(
@@ -165,8 +168,8 @@ public function allDataProvider()
165168
<var1>extra 1</var1>
166169
<var2>extra 2</var2>
167170
<var3>extra 3</var3>
168-
<items>the items</items>
169171
<gateway>IDEAL</gateway>
172+
<items>&lt;ul&gt;&lt;li&gt;1 x item 1&lt;/li&gt;&lt;li&gt;2 x item 2&lt;/li&gt;&lt;/ul&gt;</items>
170173
</transaction>
171174
<gatewayinfo>
172175
<issuerid>issuer</issuerid>
@@ -216,8 +219,8 @@ public function noIssuerDataProvider()
216219
<var1>extra 1</var1>
217220
<var2>extra 2</var2>
218221
<var3>extra 3</var3>
219-
<items>the items</items>
220222
<gateway>another</gateway>
223+
<items>&lt;ul&gt;&lt;li&gt;1 x item 1&lt;/li&gt;&lt;li&gt;2 x item 2&lt;/li&gt;&lt;/ul&gt;</items>
221224
</transaction>
222225
<signature>ad447bab87b8597853432c891e341db1</signature>
223226
</redirecttransaction>
@@ -264,8 +267,8 @@ public function specialCharsDataProvider()
264267
<var1>extra 1</var1>
265268
<var2>extra 2</var2>
266269
<var3>extra 3</var3>
267-
<items>the items</items>
268270
<gateway>IDEAL</gateway>
271+
<items>&lt;ul&gt;&lt;li&gt;1 x item 1&lt;/li&gt;&lt;li&gt;2 x item 2&lt;/li&gt;&lt;/ul&gt;</items>
269272
</transaction>
270273
<gatewayinfo>
271274
<issuerid>issuer</issuerid>

0 commit comments

Comments
 (0)