diff --git a/src/Omnipay/Sofort/Gateway.php b/src/Omnipay/Sofort/Gateway.php index 750db6d..0c2ecd8 100644 --- a/src/Omnipay/Sofort/Gateway.php +++ b/src/Omnipay/Sofort/Gateway.php @@ -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); diff --git a/src/Omnipay/Sofort/Message/AbstractRequest.php b/src/Omnipay/Sofort/Message/AbstractRequest.php index 79562c0..a74455d 100644 --- a/src/Omnipay/Sofort/Message/AbstractRequest.php +++ b/src/Omnipay/Sofort/Message/AbstractRequest.php @@ -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 diff --git a/src/Omnipay/Sofort/Message/AuthorizeRequest.php b/src/Omnipay/Sofort/Message/AuthorizeRequest.php index 1e7eb71..f840e18 100644 --- a/src/Omnipay/Sofort/Message/AuthorizeRequest.php +++ b/src/Omnipay/Sofort/Message/AuthorizeRequest.php @@ -11,7 +11,6 @@ public function getData() $data = new SimpleXMLElement(''); $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('&', '&', $this->getReturnUrl())); @@ -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; } diff --git a/tests/Omnipay/Sofort/Message/AuthorizeRequestTest.php b/tests/Omnipay/Sofort/Message/AuthorizeRequestTest.php index a06db74..4b9380d 100644 --- a/tests/Omnipay/Sofort/Message/AuthorizeRequestTest.php +++ b/tests/Omnipay/Sofort/Message/AuthorizeRequestTest.php @@ -17,6 +17,7 @@ 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(); @@ -24,7 +25,7 @@ public function testGetData() $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); @@ -43,6 +44,7 @@ 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(); @@ -50,7 +52,7 @@ public function testGetDataWithMultilineDescription() $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);