Skip to content

Commit

Permalink
Merge pull request #8 from frederikbosch/master
Browse files Browse the repository at this point in the history
Allowance for webhookUrl parameter.
  • Loading branch information
greydnls committed Oct 15, 2014
2 parents 646a35b + e12dce9 commit ea3830b
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getApiKey()
}

/**
* @param string $value
* @param string $value
* @return $this
*/
public function setApiKey($value)
Expand Down
7 changes: 6 additions & 1 deletion src/Message/PurchaseRequest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

namespace Omnipay\Mollie\Message;

/**
Expand All @@ -9,6 +8,7 @@
*/
class PurchaseRequest extends AbstractRequest
{

public function getMetadata()
{
return $this->getParameter('metadata');
Expand All @@ -31,6 +31,11 @@ public function getData()
$data['metadata'] = $this->getMetadata();
$data['issuer'] = $this->getIssuer();

$webhookUrl = $this->getNotifyUrl();
if (null !== $webhookUrl) {
$data['webhookUrl'] = $webhookUrl;
}

return $data;
}

Expand Down
32 changes: 29 additions & 3 deletions tests/Message/PurchaseRequestTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php

namespace Omnipay\Mollie\Message;

use Omnipay\Tests\TestCase;

class PurchaseRequestTest extends TestCase
{

/**
*
* @var \Omnipay\Mollie\Message\PurchaseRequest
*/
protected $request;
Expand All @@ -21,7 +22,7 @@ public function setUp()
'description' => 'Description',
'returnUrl' => 'https://www.example.com/return',
'method' => 'ideal',
'metadata' => 'meta',
'metadata' => 'meta'
));
}

Expand All @@ -34,7 +35,7 @@ public function testGetData()
'returnUrl' => 'https://www.example.com/return',
'paymentMethod' => 'ideal',
'metadata' => 'meta',
'issuer' => 'my bank',
'issuer' => 'my bank'
));

$data = $this->request->getData();
Expand All @@ -48,6 +49,31 @@ public function testGetData()
$this->assertCount(6, $data);
}

public function testGetDataWithWebhook()
{
$this->request->initialize(array(
'apiKey' => 'mykey',
'amount' => '12.00',
'description' => 'Description',
'returnUrl' => 'https://www.example.com/return',
'paymentMethod' => 'ideal',
'metadata' => 'meta',
'issuer' => 'my bank',
'notifyUrl' => 'https://www.example.com/hook'
));

$data = $this->request->getData();

$this->assertSame("12.00", $data['amount']);
$this->assertSame('Description', $data['description']);
$this->assertSame('https://www.example.com/return', $data['redirectUrl']);
$this->assertSame('ideal', $data['method']);
$this->assertSame('meta', $data['metadata']);
$this->assertSame('my bank', $data['issuer']);
$this->assertSame('https://www.example.com/hook', $data['webhookUrl']);
$this->assertCount(7, $data);
}

public function testSendSuccess()
{
$this->setMockHttpResponse('PurchaseSuccess.txt');
Expand Down

0 comments on commit ea3830b

Please sign in to comment.