Skip to content

Commit

Permalink
Merge branch 'master' into feature/set-endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Martijn Smit authored Oct 23, 2019
2 parents 580f7d1 + d870741 commit 26a0009
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Provider/Mollie.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ class Mollie extends AbstractProvider
*/
const MOLLIE_WEB_URL = 'https://www.mollie.com';

/**
* The prefix for the Client ID
*
* @const string
*/
const CLIENT_ID_PREFIX = 'app_';

/**
* Shortcuts to the available Mollie scopes.
*
Expand Down Expand Up @@ -56,6 +63,15 @@ class Mollie extends AbstractProvider
const SCOPE_ONBOARDING_READ = 'onboarding.read';
const SCOPE_ONBOARDING_WRITE = 'onboarding.write';

public function __construct(array $options = [], array $collaborators = [])
{
parent::__construct($options, $collaborators);

if (isset($options["clientId"]) && strpos($options["clientId"], self::CLIENT_ID_PREFIX) !== 0) {
throw new \DomainException("Mollie needs the client ID to be prefixed with " . self::CLIENT_ID_PREFIX . ".");
}
}

/**
* @var string
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/src/Provider/MollieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ public function tearDown()
parent::tearDown();
}

public function testClientIdShouldThrowExceptionWhenNotPrefixed()
{
$this->expectException(\DomainException::class);
$this->expectExceptionMessage("Mollie needs the client ID to be prefixed with " . Mollie::CLIENT_ID_PREFIX . ".");

$provider = new \Mollie\OAuth2\Client\Provider\Mollie([
'clientId' => 'not_pefixed_client_id',
'clientSecret' => 'mock_secret',
'redirectUri' => 'none',
]);
}

public function testGetBaseAccessTokenUrl()
{
$params = [];
Expand Down

0 comments on commit 26a0009

Please sign in to comment.