Skip to content

Commit 9344b3e

Browse files
committed
Merge pull request thephpleague#7 from sachinsudheendra/XOL-2533
XOL-2533 Adding extraOptions payload to request XML
2 parents 16140f8 + 6bfdef7 commit 9344b3e

File tree

6 files changed

+39
-4
lines changed

6 files changed

+39
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
composer.lock
33
composer.phar
44
phpunit.xml
5+
.idea

src/Message/AIMAbstractRequest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,27 @@ public function setCustomerId($value)
5353
return $this->setParameter('customerId', $value);
5454
}
5555

56+
public function setDuplicateWindow($value)
57+
{
58+
$this->setParameter('duplicateWindow', $value);
59+
}
60+
61+
private function getDuplicateWindow()
62+
{
63+
return $this->getParameter('duplicateWindow'); // Maps x_duplicate_window
64+
}
65+
66+
protected function addExtraOptions(\SimpleXMLElement $data)
67+
{
68+
if (!is_null($this->getDuplicateWindow())) {
69+
$extraOptions = $data->addChild('extraOptions');
70+
$node = dom_import_simplexml($extraOptions);
71+
$nodeOwner = $node->ownerDocument;
72+
$node->appendChild($nodeOwner->createCDATASection(sprintf("x_duplicate_window=%s", $this->getDuplicateWindow())));
73+
}
74+
return $data;
75+
}
76+
5677
/**
5778
* @return mixed|\SimpleXMLElement
5879
* @throws \Omnipay\Common\Exception\InvalidRequestException

src/Message/AIMAuthorizeRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public function getData()
3131

3232
$this->addBillingData($data);
3333
$this->addTestModeSetting($data);
34+
$this->addExtraOptions($data);
3435

3536
return $data;
3637
}

src/Message/CIMAuthorizeRequest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@ class CIMAuthorizeRequest extends CIMAbstractRequest
1414
public function getData()
1515
{
1616
$this->validate('cardReference', 'amount');
17-
1817
$data = $this->getBaseData();
19-
2018
$this->addTransactionData($data);
19+
$this->addExtraOptions($data);
2120
return $data;
2221
}
2322

@@ -45,7 +44,6 @@ protected function addTransactionData(\SimpleXMLElement $data)
4544
if (!empty($desc)) {
4645
$action->order->description = $desc;
4746
}
48-
4947
return $data;
5048
}
5149

tests/Message/AIMAuthorizeRequestTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public function setUp()
1818
'amount' => '12.00',
1919
'customerId' => 'cust-id',
2020
'card' => $this->getValidCard(),
21+
'duplicateWindow' => 0
2122
)
2223
);
2324
}
@@ -45,4 +46,10 @@ public function testGetDataTestMode()
4546
$this->assertEquals('testRequest', $setting->settingName);
4647
$this->assertEquals('true', $setting->settingValue);
4748
}
49+
50+
public function testShouldReturnExtraOptionsToDisableDuplicateWindowPeriod()
51+
{
52+
$data = $this->request->getData();
53+
$this->assertEquals('x_duplicate_window=0', strip_tags($data->extraOptions));
54+
}
4855
}

tests/Message/CIMAuthorizeRequestTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ public function setUp()
1616
array(
1717
'cardReference' => '{"customerProfileId":"28972085","customerPaymentProfileId":"26317841","customerShippingAddressId":"27057151"}',
1818
'amount' => '12.00',
19-
'description' => 'Test authorize transaction'
19+
'description' => 'Test authorize transaction',
20+
'duplicateWindow' => '0'
2021
)
2122
);
2223
}
@@ -31,4 +32,10 @@ public function testGetData()
3132
$this->assertEquals('27057151', $data->transaction->profileTransAuthOnly->customerShippingAddressId);
3233
$this->assertEquals('Test authorize transaction', $data->transaction->profileTransAuthOnly->order->description);
3334
}
35+
36+
public function testShouldReturnExtraOptionsToDisableDuplicateWindowPeriod()
37+
{
38+
$data = $this->request->getData();
39+
$this->assertEquals('x_duplicate_window=0', strip_tags($data->extraOptions));
40+
}
3441
}

0 commit comments

Comments
 (0)