Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Omnipay 3 and Three Step Redirect support #4

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
"psr-4": { "Omnipay\\NMI\\" : "src/" }
},
"require": {
"omnipay/common": "~2.0"
"omnipay/common": "^3"
},
"require-dev": {
"omnipay/tests": "~2.0"
"omnipay/tests": "^3"
},
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
"dev-master": "3.0.x-dev"
}
}
}
6 changes: 3 additions & 3 deletions src/DirectPostGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function credit(array $parameters = array())

/**
* @param array $parameters
* @return \Omnipay\NMI\Message\CreateCardRequest
* @return \Omnipay\NMI\Message\DirectPostCreateCardRequest
*/
public function createCard(array $parameters = array())
{
Expand All @@ -372,7 +372,7 @@ public function createCard(array $parameters = array())

/**
* @param array $parameters
* @return \Omnipay\NMI\Message\UpdateCardRequest
* @return \Omnipay\NMI\Message\DirectPostUpdateCardRequest
*/
public function updateCard(array $parameters = array())
{
Expand All @@ -381,7 +381,7 @@ public function updateCard(array $parameters = array())

/**
* @param array $parameters
* @return \Omnipay\NMI\Message\DeleteCardRequest
* @return \Omnipay\NMI\Message\DirectPostDeleteCardRequest
*/
public function deleteCard(array $parameters = array())
{
Expand Down
11 changes: 8 additions & 3 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,14 @@ protected function getShippingData()

public function sendData($data)
{
$httpResponse = $this->httpClient->post($this->getEndpoint(), null, $data)->send();
$httpResponse = $this->httpClient->request(
'POST',
$this->getEndpoint(),
['Content-Type' => 'application/x-www-form-urlencoded'],
http_build_query($data, '', '&')
);

return $this->response = new DirectPostResponse($this, $httpResponse->getBody());
return $this->response = new DirectPostResponse($this, $httpResponse->getBody()->getContents());
}

public function setEndpoint($value)
Expand All @@ -338,6 +343,6 @@ public function setEndpoint($value)

public function getEndpoint()
{
return $this->endpoint;
return $this->getParameter('endpoint') ?: $this->endpoint;
}
}
92 changes: 92 additions & 0 deletions src/Message/DirectPostAuthRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,105 @@ class DirectPostAuthRequest extends AbstractRequest
{
protected $type = 'auth';

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

/**
* Sets the first merchant defined field.
*
* @param string
* @return AbstractRequest Provides a fluent interface
*/
public function setMerchantDefinedField_1($value)
{
return $this->setParameter('merchant_defined_field_1', $value);
}

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

/**
* Sets the second merchant defined field.
*
* @param string
* @return AbstractRequest Provides a fluent interface
*/
public function setMerchantDefinedField_2($value)
{
return $this->setParameter('merchant_defined_field_2', $value);
}

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

/**
* Sets the third merchant defined field.
*
* @param string
* @return AbstractRequest Provides a fluent interface
*/
public function setMerchantDefinedField_3($value)
{
return $this->setParameter('merchant_defined_field_3', $value);
}

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

/**
* Sets the fourth merchant defined field.
*
* @param string
* @return AbstractRequest Provides a fluent interface
*/
public function setMerchantDefinedField_4($value)
{
return $this->setParameter('merchant_defined_field_4', $value);
}

public function getData()
{
$this->validate('amount');

$data = $this->getBaseData();
$data['amount'] = $this->getAmount();

if ($this->getMerchantDefinedField_1()) {
$data['merchant_defined_field_1'] = $this->getMerchantDefinedField_1();
}

if ($this->getMerchantDefinedField_2()) {
$data['merchant_defined_field_2'] = $this->getMerchantDefinedField_2();
}

if ($this->getMerchantDefinedField_3()) {
$data['merchant_defined_field_3'] = $this->getMerchantDefinedField_3();
}

if ($this->getMerchantDefinedField_4()) {
$data['merchant_defined_field_4'] = $this->getMerchantDefinedField_4();
}

if ($this->getCardReference()) {
$data['customer_vault_id'] = $this->getCardReference();

Expand Down
Loading