diff --git a/src/Message/AbstractRequest.php b/src/Message/AbstractRequest.php index 5a5b9e20..a9038ec8 100644 --- a/src/Message/AbstractRequest.php +++ b/src/Message/AbstractRequest.php @@ -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() diff --git a/src/Message/AuthorizeRequest.php b/src/Message/AuthorizeRequest.php index 21dc61e5..03154b19 100644 --- a/src/Message/AuthorizeRequest.php +++ b/src/Message/AuthorizeRequest.php @@ -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()) { diff --git a/tests/Message/AbstractRequestTest.php b/tests/Message/AbstractRequestTest.php index dae33b0e..d0315c20 100644 --- a/tests/Message/AbstractRequestTest.php +++ b/tests/Message/AbstractRequestTest.php @@ -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()); + } } diff --git a/tests/Message/AuthorizeRequestTest.php b/tests/Message/AuthorizeRequestTest.php index 9c65b994..1dfe7c0c 100644 --- a/tests/Message/AuthorizeRequestTest.php +++ b/tests/Message/AuthorizeRequestTest.php @@ -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']); } /**