Skip to content

Commit

Permalink
Merge pull request #9 from bamarni/country
Browse files Browse the repository at this point in the history
added country support
  • Loading branch information
iasci committed Nov 5, 2014
2 parents f5946e8 + 3acca63 commit b947185
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Omnipay/Sofort/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ public function setProjectId($value)
return $this->setParameter('projectId', $value);
}

public function getCountry()
{
return $this->getParameter('country');
}

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

public function authorize(array $parameters = array())
{
return $this->createRequest('\Omnipay\Sofort\Message\AuthorizeRequest', $parameters);
Expand Down
10 changes: 10 additions & 0 deletions src/Omnipay/Sofort/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public function setProjectId($value)
return $this->setParameter('projectId', $value);
}

public function getCountry()
{
return $this->getParameter('country');
}

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

public function sendData($data)
{
$httpResponse = $this->httpClient
Expand Down
4 changes: 3 additions & 1 deletion src/Omnipay/Sofort/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public function getData()
$data = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><multipay/>');

$data->addChild('project_id', $this->getProjectId());
$data->addChild('language_code', 'de');
$data->addChild('amount', $this->getAmount());
$data->addChild('currency_code', $this->getCurrency());
$data->addChild('success_url', str_replace('&', '&amp;', $this->getReturnUrl()));
Expand All @@ -34,6 +33,9 @@ public function getData()
$su = $data->addChild('su');
$su->addChild('customer_protection', 1);

$sender = $data->addChild('sender');
$sender->addChild('country_code', $this->getCountry());

return $data;
}

Expand Down
6 changes: 4 additions & 2 deletions tests/Omnipay/Sofort/Message/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ public function testGetData()
'returnUrl' => 'https://www.example.com/return',
'cancelUrl' => 'https://www.example.com/cancel',
'notifyUrl' => 'https://www.example.com/notify',
'country' => 'de',
));

$data = $request->getData();

$this->assertInstanceOf('SimpleXMLElement', $data);
$this->assertSame('10.00', (string) $data->amount);
$this->assertSame('EUR', (string) $data->currency_code);
$this->assertSame('de', (string) $data->language_code);
$this->assertSame('de', (string) $data->sender->country_code);
$this->assertSame('https://www.example.com/return', (string) $data->success_url);
$this->assertSame('https://www.example.com/cancel', (string) $data->abort_url);
$this->assertSame('https://www.example.com/notify', (string) $data->notification_urls[0]->notification_url);
Expand All @@ -43,14 +44,15 @@ public function testGetDataWithMultilineDescription()
'returnUrl' => 'https://www.example.com/return',
'cancelUrl' => 'https://www.example.com/cancel',
'notifyUrl' => 'https://www.example.com/notify',
'country' => 'de',
));

$data = $request->getData();

$this->assertInstanceOf('SimpleXMLElement', $data);
$this->assertSame('10.00', (string) $data->amount);
$this->assertSame('EUR', (string) $data->currency_code);
$this->assertSame('de', (string) $data->language_code);
$this->assertSame('de', (string) $data->sender->country_code);
$this->assertSame('https://www.example.com/return', (string) $data->success_url);
$this->assertSame('https://www.example.com/cancel', (string) $data->abort_url);
$this->assertSame('https://www.example.com/notify', (string) $data->notification_urls[0]->notification_url);
Expand Down

0 comments on commit b947185

Please sign in to comment.