Skip to content

Commit

Permalink
Add metadata parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
amacneil committed Apr 8, 2014
1 parent 9a433b4 commit 99c82dc
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Message/AbstractRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ public function setCardToken($value)
return $this->setParameter('token', $value);
}

public function getMetadata()
{
return $this->getParameter('metadata');
}

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

abstract public function getEndpoint();

public function getHttpMethod()
Expand Down
1 change: 1 addition & 0 deletions src/Message/AuthorizeRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function getData()
$data['amount'] = $this->getAmountInteger();
$data['currency'] = strtolower($this->getCurrency());
$data['description'] = $this->getDescription();
$data['metadata'] = $this->getMetadata();
$data['capture'] = 'false';

if ($this->getCardReference()) {
Expand Down
6 changes: 6 additions & 0 deletions tests/Message/AbstractRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,10 @@ public function testCardToken()
$this->assertSame('abc123', $this->request->getCardToken());
$this->assertSame('abc123', $this->request->getToken());
}

public function testMetadata()
{
$this->assertSame($this->request, $this->request->setMetadata(array('foo' => 'bar')));
$this->assertSame(array('foo' => 'bar'), $this->request->getMetadata());
}
}
11 changes: 10 additions & 1 deletion tests/Message/AuthorizeRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,23 @@ public function setUp()
'amount' => '12.00',
'currency' => 'USD',
'card' => $this->getValidCard(),
'description' => 'Order #42',
'metadata' => array(
'foo' => 'bar',
),
)
);
}

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

$this->assertSame(1200, $data['amount']);
$this->assertSame('usd', $data['currency']);
$this->assertSame('Order #42', $data['description']);
$this->assertSame('false', $data['capture']);
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
}

/**
Expand Down

0 comments on commit 99c82dc

Please sign in to comment.