Skip to content

Commit 0c8db3e

Browse files
committed
Remove legacy checks
1 parent f9fb5e9 commit 0c8db3e

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

src/Omnipay/Common/Message/AbstractRequest.php

+1-12
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function toFloat($value)
301301
}
302302

303303
/**
304-
* Validates and returns the formated amount.
304+
* Validates and returns the formatted amount.
305305
*
306306
* @throws InvalidRequestException on any validation failure.
307307
* @return string The amount formatted to the correct number of decimal places for the selected currency.
@@ -311,17 +311,6 @@ public function getAmount()
311311
$amount = $this->getParameter('amount');
312312

313313
if ($amount !== null) {
314-
// Don't allow integers for currencies that support decimals.
315-
// This is for legacy reasons - upgrades from v0.9
316-
if ($this->getCurrencyDecimalPlaces() > 0) {
317-
if (is_int($amount) || (is_string($amount) && false === strpos((string) $amount, '.'))) {
318-
throw new InvalidRequestException(
319-
'Please specify amount as a string or float, '
320-
. 'with decimal places (e.g. \'10.00\' to represent $10.00).'
321-
);
322-
};
323-
}
324-
325314
$amount = $this->toFloat($amount);
326315

327316
// Check for a negative amount.

tests/Omnipay/Common/Message/AbstractRequestTest.php

-21
Original file line numberDiff line numberDiff line change
@@ -179,27 +179,6 @@ public function testGetAmountNoDecimalsRounding()
179179
$this->request->getAmount();
180180
}
181181

182-
/**
183-
* @expectedException Omnipay\Common\Exception\InvalidRequestException
184-
*/
185-
public function testAmountWithIntThrowsException()
186-
{
187-
// ambiguous value, avoid errors upgrading from v0.9
188-
$this->assertSame($this->request, $this->request->setAmount(10));
189-
$this->request->getAmount();
190-
}
191-
192-
/**
193-
* @expectedException Omnipay\Common\Exception\InvalidRequestException
194-
*/
195-
public function testAmountWithIntStringThrowsException()
196-
{
197-
// ambiguous value, avoid errors upgrading from v0.9
198-
// Some currencies only take integers, so an integer (in a string) should be valid.
199-
$this->assertSame($this->request, $this->request->setAmount('10'));
200-
$this->request->getAmount();
201-
}
202-
203182
public function testGetAmountInteger()
204183
{
205184
$this->assertSame($this->request, $this->request->setAmount('13.66'));

0 commit comments

Comments
 (0)