Skip to content

Commit 040555d

Browse files
authored
Merge pull request #106 from nickyr/master
Fix bug where validating currency field passes after setting the currency to null
2 parents 3c112d4 + 2e9fcd1 commit 040555d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Omnipay/Common/Message/AbstractRequest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@ public function getCurrency()
383383
*/
384384
public function setCurrency($value)
385385
{
386-
return $this->setParameter('currency', strtoupper($value));
386+
if ($value !== null) {
387+
$value = strtoupper($value);
388+
}
389+
return $this->setParameter('currency', $value);
387390
}
388391

389392
/**

tests/Omnipay/Common/Message/AbstractRequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ public function testCurrencyLowercase()
270270
$this->assertSame('USD', $this->request->getCurrency());
271271
}
272272

273+
public function testCurrencyNull()
274+
{
275+
$this->assertSame($this->request, $this->request->setCurrency(null));
276+
$this->assertNull($this->request->getCurrency());
277+
}
278+
273279
public function testCurrencyNumeric()
274280
{
275281
$this->assertSame($this->request, $this->request->setCurrency('USD'));

0 commit comments

Comments
 (0)