Skip to content

Commit

Permalink
Support security key
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Gilbert committed Dec 1, 2021
1 parent 88851ba commit 5675c8c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
22 changes: 18 additions & 4 deletions src/DirectPostGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public function getName()
*/
public function getDefaultParameters()
{
return array(
'username' => '',
'password' => ''
);
return array();
}

/**
Expand Down Expand Up @@ -64,6 +61,23 @@ public function setPassword($value)
return $this->setParameter('password', $value);
}

/**
* @return string
*/
public function getSecurityKey()
{
return $this->getParameter('security_key');
}

/**
* @param string $value
* @return $this
*/
public function setSecurityKey($value)
{
return $this->setParameter('security_key', $value);
}

/**
* @return string
*/
Expand Down
20 changes: 17 additions & 3 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public function setPassword($value)
return $this->setParameter('password', $value);
}

public function getSecurityKey()
{
return $this->getParameter('security_key');
}

public function setSecurityKey($value)
{
return $this->setParameter('security_key', $value);
}

public function getProcessorId()
{
return $this->getParameter('processor_id');
Expand Down Expand Up @@ -209,9 +219,13 @@ protected function getBaseData()
if (isset($this->customer_vault)) {
$data['customer_vault'] = $this->customer_vault;
}

$data['username'] = $this->getUsername();
$data['password'] = $this->getPassword();

if (isset($this->getSecurityKey())) {
$data['security_key'] = $this->getSecurityKey();
} else {
$data['username'] = $this->getUsername();
$data['password'] = $this->getPassword();
}

if ($this->getProcessorId()) {
$data['processor_id'] = $this->getProcessorId();
Expand Down

0 comments on commit 5675c8c

Please sign in to comment.