Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions lib/Ogone/AbstractPaymentRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ abstract class AbstractPaymentRequest extends AbstractRequest
const MODE_TEST = 'test';
const MODE_PRODUCTION = 'production';

const TEST = '';
const PRODUCTION = '';

/**
* Set Mode
*
Expand All @@ -27,9 +30,9 @@ abstract class AbstractPaymentRequest extends AbstractRequest
public function setMode($mode)
{
if ($mode === self::MODE_TEST) {
return $this->setOgoneUri(self::TEST);
return $this->setOgoneUri(static::TEST);
} elseif ($mode === self::MODE_PRODUCTION) {
return $this->setOgoneUri(self::PRODUCTION);
return $this->setOgoneUri(static::PRODUCTION);
}

throw new InvalidArgumentException('Invalid mode parameter');
Expand Down Expand Up @@ -215,6 +218,10 @@ public function setBrand($brand)
{
$this->parameters['brand'] = $brand;

if (strtolower($brand) !== 'ideal') {
$this->setIssuer(null);
}

return $this;
}

Expand All @@ -227,6 +234,24 @@ public function setPm($pm)
{
$this->parameters['pm'] = $pm;

if (!str_starts_with(strtolower($pm), 'ideal')) {
$this->setIssuer(null);
}

return $this;
}

public function setIssuer(?string $issuerId)
{
if ($issuerId === null) {
unset($this->parameters['issuerid']);
} else {
$this->setBrand("IDEAL")
->setPm("IDEAL");

$this->parameters["issuerid"] = $issuerId;
}

return $this;
}

Expand Down