Skip to content

Commit 99c82dc

Browse files
committed
Add metadata parameter
1 parent 9a433b4 commit 99c82dc

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/Message/AbstractRequest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ public function setCardToken($value)
3737
return $this->setParameter('token', $value);
3838
}
3939

40+
public function getMetadata()
41+
{
42+
return $this->getParameter('metadata');
43+
}
44+
45+
public function setMetadata($value)
46+
{
47+
return $this->setParameter('metadata', $value);
48+
}
49+
4050
abstract public function getEndpoint();
4151

4252
public function getHttpMethod()

src/Message/AuthorizeRequest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public function getData()
1515
$data['amount'] = $this->getAmountInteger();
1616
$data['currency'] = strtolower($this->getCurrency());
1717
$data['description'] = $this->getDescription();
18+
$data['metadata'] = $this->getMetadata();
1819
$data['capture'] = 'false';
1920

2021
if ($this->getCardReference()) {

tests/Message/AbstractRequestTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@ public function testCardToken()
1919
$this->assertSame('abc123', $this->request->getCardToken());
2020
$this->assertSame('abc123', $this->request->getToken());
2121
}
22+
23+
public function testMetadata()
24+
{
25+
$this->assertSame($this->request, $this->request->setMetadata(array('foo' => 'bar')));
26+
$this->assertSame(array('foo' => 'bar'), $this->request->getMetadata());
27+
}
2228
}

tests/Message/AuthorizeRequestTest.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,23 @@ public function setUp()
1414
'amount' => '12.00',
1515
'currency' => 'USD',
1616
'card' => $this->getValidCard(),
17+
'description' => 'Order #42',
18+
'metadata' => array(
19+
'foo' => 'bar',
20+
),
1721
)
1822
);
1923
}
2024

21-
public function testCaptureIsFalse()
25+
public function testGetData()
2226
{
2327
$data = $this->request->getData();
28+
29+
$this->assertSame(1200, $data['amount']);
30+
$this->assertSame('usd', $data['currency']);
31+
$this->assertSame('Order #42', $data['description']);
2432
$this->assertSame('false', $data['capture']);
33+
$this->assertSame(array('foo' => 'bar'), $data['metadata']);
2534
}
2635

2736
/**

0 commit comments

Comments
 (0)