Skip to content

Commit

Permalink
Add profile option. Closes #4
Browse files Browse the repository at this point in the history
  • Loading branch information
amacneil committed Feb 10, 2014
1 parent 40beb16 commit 2a26d6e
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Omnipay/SagePay/Message/ServerAuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,23 @@
*/
class ServerAuthorizeRequest extends DirectAuthorizeRequest
{
public function getProfile()
{
return $this->getParameter('profile');
}

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

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

$data = $this->getBaseAuthorizeData();
$data['NotificationURL'] = $this->getReturnUrl();
$data['Profile'] = $this->getProfile();

return $data;
}
Expand Down
36 changes: 36 additions & 0 deletions tests/Omnipay/SagePay/Message/ServerAuthorizeRequestTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

namespace Omnipay\SagePay\Message;

use Omnipay\Tests\TestCase;

class ServerAuthorizeRequestTest extends TestCase
{
public function setUp()
{
parent::setUp();

$this->request = new ServerAuthorizeRequest($this->getHttpClient(), $this->getHttpRequest());
$this->request->initialize(
array(
'amount' => '12.00',
'transactionId' => '123',
'card' => $this->getValidCard(),
)
);
}

public function testProfile()
{
$this->assertSame($this->request, $this->request->setProfile('NORMAL'));
$this->assertSame('NORMAL', $this->request->getProfile());
}

public function getData()
{
$data = $this->request->getData();

$this->assertSame('https://www.example.com/return', $data['NotificationURL']);
$this->assertSame('LOW', $data['Profile']);
}
}

0 comments on commit 2a26d6e

Please sign in to comment.