Skip to content

Commit 87a39f0

Browse files
XOL-2533 Parameterizing x_duplicate_window value and using it across AIM and CIM
Application needs to pass parameter "duplicateWindow=x" which when not null will be sent as extra options with the request.
1 parent 70e6c9c commit 87a39f0

File tree

6 files changed

+32
-10
lines changed

6 files changed

+32
-10
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("x_duplicate_window=0"));
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: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@ public function getData()
2020
return $data;
2121
}
2222

23-
private function addExtraOptions(\SimpleXMLElement $data)
24-
{
25-
$extraOptions = $data->addChild('extraOptions');
26-
$node = dom_import_simplexml($extraOptions);
27-
$nodeOwner = $node->ownerDocument;
28-
$node->appendChild($nodeOwner->createCDATASection("x_duplicate_window=0"));
29-
return $data;
30-
}
31-
3223
/**
3324
* Adds transaction data
3425
*

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: 2 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
}

0 commit comments

Comments
 (0)