diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3824e48..d3ac711 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -1,22 +1,25 @@
name: tests
+
on:
push:
pull_request:
schedule:
- - cron: '0 0 * * *'
+ - cron: "0 0 * * *"
jobs:
tests:
-
runs-on: ubuntu-latest
+
strategy:
fail-fast: true
matrix:
- php: ['8.0', '8.1', '8.2', '8.3']
- laravel: ['9.0', '10.0']
+ php: ["8.1", "8.2", "8.3"]
+ laravel: ["10.0", "11.0"]
exclude:
- - laravel: '10.0'
- php: '8.0'
+ - laravel: "11.0"
+ php: "8.0"
+ - laravel: "11.0"
+ php: "8.1"
name: P${{ matrix.php }} - L${{ matrix.laravel }}
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 6d1f587..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,8 +0,0 @@
-Copyright (c) 2016, Mollie B.V.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
-Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..bf76669
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2024 Mollie
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/README.md b/README.md
index 8194fca..ef50e02 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
Mollie for Laravel
-
+![create new payment](https://github.com/mollie/laravel-mollie/assets/10154100/205b536f-51a3-4d1b-b2c9-69f02ba019fa)
Laravel-Mollie incorporates the [Mollie API](https://www.mollie.com/en/docs/overview) and [Mollie Connect](https://www.mollie.com/en/connect) into your [Laravel](https://laravel.com/) or [Lumen](https://lumen.laravel.com/) project.
@@ -16,20 +16,18 @@ Accepting [iDEAL](https://www.mollie.com/en/payments/ideal/), [Apple Pay](https:
[![Latest Stable Version](https://poser.pugx.org/mollie/laravel-mollie/v/stable)](https://packagist.org/packages/mollie/laravel-mollie)
[![Total Downloads](https://poser.pugx.org/mollie/laravel-mollie/downloads)](https://packagist.org/packages/mollie/laravel-mollie)
-## Requirements
+## **Requirements**
* Get yourself a free [Mollie account](https://www.mollie.com/signup). No sign up costs.
* Now you're ready to use the Mollie API client in test mode.
* Follow [a few steps](https://www.mollie.com/dashboard/?modal=onboarding) to enable payment methods in live mode, and let us handle the rest.
* Up-to-date OpenSSL (or other SSL/TLS toolkit)
-* PHP >= 7.0
-* [Laravel](https://www.laravel.com) (or [Lumen](https://lumen.laravel.com)) >= 5.5
-* [Laravel Socialite](https://github.com/laravel/socialite) >= 3.0 (if you intend on using [Mollie Connect](https://docs.mollie.com/oauth/overview))
+* PHP >= 8.1
+* [Laravel](https://www.laravel.com) >= 10.0
+* [Laravel Socialite](https://github.com/laravel/socialite) >= 5.0 (if you intend on using [Mollie Connect](https://docs.mollie.com/oauth/overview))
-## Upgrading from v1.x?
-To support the enhanced Mollie API, some breaking changes were introduced. Make sure to follow the instructions in the [package migration guide](docs/migration_instructions_v1_to_v2.md).
-
-Not ready to upgrade? The Laravel-Mollie client v1 will remain supported for now.
+## Upgrading from v2.x?
+To support the enhanced Mollie API, some breaking changes were introduced. Make sure to follow the instructions in the [upgrade guide](UPGRADE.md).
Fresh install? Continue with the installation guide below.
@@ -45,19 +43,12 @@ Or add it to `composer.json` manually:
```json
"require": {
- "mollie/laravel-mollie": "^2.0"
+ "mollie/laravel-mollie": "^3.0"
}
```
Laravel-Mollie's service providers will be automatically registered using Laravel's auto-discovery feature.
-Note: For Lumen you have to add the Mollie facade and service provider manually to: `bootstrap/app.php` :
-```php
-$app->withFacades(true, ['Mollie\Laravel\Facades\Mollie' => 'Mollie']);
-
-$app->register(Mollie\Laravel\MollieServiceProvider::class);
-```
-
## Configuration
You'll only need to add the `MOLLIE_KEY` variable to your `.env` file.
@@ -112,17 +103,6 @@ public function handleWebhookNotification(Request $request) {
}
```
-### Global helper method
-For your convencience we've added the global `mollie()` helper function. It's an easy shortcut to the `Mollie::api()` facade accessor.
-
-```php
-// Using facade accessor
-$payment = \Mollie\Laravel\Facades\Mollie::api()->payments->get($payment_id);
-
-// Using global helper function
-$payment = mollie()->payments->get($payment_id);
-```
-
## Other examples
- [Process realtime status updates with a webhook](docs/webhook.md)
@@ -136,17 +116,17 @@ You can find the latest development roadmap for this package [here](docs/roadmap
## Want to help us make our Laravel module even better?
Want to help us make our Laravel module even better? We take [pull requests](https://github.com/mollie/laravel-mollie/pulls?utf8=%E2%9C%93&q=is%3Apr), sure.
-But how would you like to contribute to a [technology oriented organization](https://www.mollie.com/nl/blog/post/werken-bij-mollie-als-developer/)? Mollie is hiring developers and system engineers.
-[Check out our vacancies](https://www.mollie.com/nl/jobs) or [get in touch](mailto:personeel@mollie.com).
+But how would you like to contribute to a technology oriented organization? Mollie is hiring developers and system engineers.
+[Check out our vacancies](https://jobs.mollie.com/) or [get in touch](mailto:personeel@mollie.com).
## License
-[BSD (Berkeley Software Distribution) License](http://www.opensource.org/licenses/bsd-license.php). Copyright (c) 2016, Mollie B.V.
+[The MIT License](LICENSE.md). Copyright (c) 2024, Mollie B.V.
## Support
-Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com — +31 20-612 88 55
+Contact: [www.mollie.com](https://www.mollie.com) — info@mollie.com
-* [More information about Mollie Connect](https://www.mollie.com/en/connect)
-* [Documentation for the Mollie API](https://www.mollie.com/en/docs/overview)
-* [Documentation for Mollie OAuth](https://www.mollie.com/en/docs/oauth/overview)
+* [More information about Mollie Connect](https://www.mollie.com/products/connect)
+* [Documentation for the Mollie API](https://docs.mollie.com/)
+* [Documentation for Mollie OAuth](https://docs.mollie.com/connect/getting-started)
diff --git a/UPGRADE.md b/UPGRADE.md
new file mode 100644
index 0000000..d2bb85d
--- /dev/null
+++ b/UPGRADE.md
@@ -0,0 +1,70 @@
+![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png)
+
+# Migrating from Laravel-Mollie v2.x to v3
+
+## Update composer dependencies
+
+Update `composer.json` to match this:
+
+```json
+"require": {
+ "mollie/laravel-mollie": "^3.0"
+}
+```
+
+Then run `composer update mollie/laravel-mollie`.
+
+## Review Changes
+### Updating Dependencies
+Laravel-Mollie now requires PHP 8.1.0 or greater.
+
+If you are using the mollie connect feature, make sure to checkout the upgrade instructions for [Laravel-Socialite](https://github.com/laravel/socialite/blob/5.x/UPGRADE.md)
+
+#### Lumen support dropped
+The Laravel team has added a note a while ago on the [Lumen Repository](https://github.com/laravel/lumen?tab=readme-ov-file) as well as the official [Lumen documentation](https://lumen.laravel.com/docs/master#installation) that they discourage starting a new project with Lumen. Therefore we dropped the Lumen support for this package.
+
+### Removed Classes
+In order to enhance maintainability the following classes were removed:
+
+- `MollieApiWrapper`
+- `MollieManager`
+
+Instead the `MollieApiClient` is now directly resolved and provided through the container without any abstractions. This change means you can directly access the newest API features that are added to the underlying [mollie/mollie-api-php](https://github.com/mollie/mollie-api-php) client without having to wait on this repository being updated.
+
+### Change in calling API endpoints
+Earlier versions of Laravel-Mollie provided access to endpoints via both methods and properties. Moving forward, access to endpoints will be exclusively through properties, aligning with the practices of the mollie-api-php SDK.****
+
+```php
+// before
+Mollie::api()->payments()->create();
+
+// now
+Mollie::api()->payments->create();
+```
+
+### No more global helper function
+The `mollie()` helper function was deleted. If you rely on the helper function, either consider switching to
+- injecting or resolving the `MollieApiClient` from the container, or
+- use the `Mollie` facade
+
+If none of these are an option for you, you can create your own `helpers.php` file and insert the code for the `mollie()` function yourself.
+
+```php
+// app/helpers.php
+permissions()`
-- `Mollie::api()->organizations()`
-- `Mollie::api()->issuers()`
-
-These methods were renamed:
-
-- `Mollie::api()->customerMandates()` into `Mollie::api()->mandates()`
-- `Mollie::api()->customersPayments()` into `Mollie::api()->customerPayments()`
-- `Mollie::api()->customerSubscriptions()` into `Mollie::api()->subscriptions()`
-- `Mollie::api()->paymentsRefunds()` into `Mollie::api()->refunds()`
-
-Also, this method was added:
-
-- `Mollie::api()->invoices()`
-
-### Step 4: Other changes
-
-More breaking changes were introduced with the new Mollie API. Read about it here in the [official migration docs](https://docs.mollie.com/migrating-v1-to-v2).
-
-## Stuck?
-Feel free to open an [issue](https://github.com/mollie/laravel-mollie/issues).
diff --git a/docs/mollie_connect.md b/docs/mollie_connect.md
index f5cd6ba..89e2e01 100644
--- a/docs/mollie_connect.md
+++ b/docs/mollie_connect.md
@@ -49,4 +49,3 @@ Route::get('login_callback', function () {
return Mollie::api()->profiles()->page(); // Retrieve payment profiles available on the obtained Mollie account
});
```
-
diff --git a/docs/recurring_and_direct_charge.md b/docs/recurring_and_direct_charge.md
index 0499865..dfbb35c 100644
--- a/docs/recurring_and_direct_charge.md
+++ b/docs/recurring_and_direct_charge.md
@@ -9,7 +9,7 @@ Here you can see an example of how easy it is to use [Mollie recurring](https://
First of all you need to [create a new customer](https://docs.mollie.com/payments/recurring#payments-recurring-first-payment) (step 1), this is pretty straight forward
```php
-$customer = Mollie::api()->customers()->create([
+$customer = Mollie::api()->customers->create([
'name' => 'John Doe',
'email' => 'john@doe.com',
]);
@@ -20,7 +20,7 @@ $customer = Mollie::api()->customers()->create([
After creating the user, you can [start a payment](https://docs.mollie.com/payments/recurring#payments-recurring-first-payment) (step 3), it's important to set `sequenceType` to `first`, this will generate a mandate on Mollie's end that can be used to do direct charges. Without setting the `method` the payment screen of Mollie will display your methods that support recurring payments.
```php
-$payment = Mollie::api()->payments()->create([
+$payment = Mollie::api()->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => '25.00', // You must send the correct number of decimals, thus we enforce the use of strings
@@ -41,14 +41,14 @@ return redirect($payment->getCheckoutUrl(), 303);
After doing the initial payment, you may [charge the users card/account directly](https://docs.mollie.com/payments/recurring#payments-recurring-charging-on-demand). Make sure there's a valid mandate connected to the customer. In case there are multiple mandates at least one should have `status` set to `valid`. Checking mandates is easy:
```php
-$mandates = Mollie::api()->mandates()->listFor($customer);
+$mandates = Mollie::api()->mandates->listFor($customer);
```
If any of the mandates is valid, charging the user is a piece of cake. Make sure `sequenceType` is set to `recurring`.
```php
- $payment = Mollie::api()->payments()->create([
+ $payment = Mollie::api()->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => '25.00', // You must send the correct number of decimals, thus we enforce the use of strings
diff --git a/docs/roadmap.md b/docs/roadmap.md
index fccaea2..7f8d5d4 100644
--- a/docs/roadmap.md
+++ b/docs/roadmap.md
@@ -9,29 +9,9 @@ Please submit an [issue](https://github.com/mollie/laravel-mollie/issues) if you
## Planned for next major release
### Provide default webhook
-The Laravel-Mollie package makes it easy to set up a new Mollie payment in your Laravel application. But right now, you'll need to implement the webhook yourself. We plan on providing a default webhook, which will trigger an Event when a payment status has been updated. This way, you'll only need to listen for the PaymentUpdatedEvent.
+The Laravel-Mollie package makes it easy to set up a new Mollie payment in your Laravel application. But right now, you'll need to implement the webhook yourself. We plan on providing a default webhook, which will trigger an Event when a payment status has been updated. This way, you'll only need to listen for the PaymentUpdatedEvent.
Another solution may be to provide a default overridable controller, like Cashier has. Or to implement both events and the controller.
### Switch to MIT license
Currently, the Laravel Mollie client has a *BSD 2-Clause "Simplified" License*. We're discussing switching to a *MIT* license, which is most common in Laravel packages.
-
-## Other Laravel packages by Mollie
-Besides the Laravel-Mollie package, we're looking for other options to support you integrating Mollie in your Laravel applications.
-
-### Explore Laravel Cashier support ("Laravel/Cashier-Mollie")
-Laravel Cashier is a very popular package for easily adding recurring payments to your Laravel application. We are exploring whether it's possible for Laravel Cashier to support Mollie. You can join the discussion [here](https://github.com/mollie/laravel-mollie/issues/41).
-
-### Explore Laravel Spark support
-[Laravel Spark](https://spark.laravel.com/) is a commercial SAAS starter kit. By adding Cashier-Mollie support, new SAAS projects can be built rapidly on top of Mollie's subscription services.
-
-Laravel Spark leverages Laravel Cashier for subscription billing.
-
-When/If Cashier-Mollie is implemented, support for Laravel Spark would be a logical next topic for exploration.
-
-### Explore Laravel Nova plugin options
-[Laravel Nova](https://nova.laravel.com/) is a powerful Laravel and Vue based CMS (commercial license). Launch of this new CMS is scheduled August 2018.
-
-Adoption rate is expected to be high; [Sander](https://github.com/sandervanhooft) expects Nova is going to blow a hole in other Laravel and PHP CMSes' market shares.
-
-A Laravel Nova plugin for Mollie could for example list and manage payments, and include a few dashboard cards.
diff --git a/docs/webhook.md b/docs/webhook.md
index dff9f03..f23546b 100644
--- a/docs/webhook.md
+++ b/docs/webhook.md
@@ -6,7 +6,7 @@ A webhook is a URL Mollie will call when an object’s status changes, for examp
To implement the webhook in your Laravel application you need to provide a `webhookUrl` parameter when creating a payment (or subscription):
```php
-$payment = Mollie::api()->payments()->create([
+$payment = Mollie::api()->payments->create([
'amount' => [
'currency' => 'EUR',
'value' => '10.00', // You must send the correct number of decimals, thus we enforce the use of strings
@@ -34,7 +34,7 @@ class MollieWebhookController extends Controller {
return;
}
- $payment = Mollie::api()->payments()->get($request->id);
+ $payment = Mollie::api()->payments->get($request->id);
if ($payment->isPaid()) {
// do your thing...
diff --git a/src/Facades/Mollie.php b/src/Facades/Mollie.php
index 8ce97af..ed8c992 100644
--- a/src/Facades/Mollie.php
+++ b/src/Facades/Mollie.php
@@ -1,45 +1,15 @@
- * @copyright Mollie B.V.
- *
- * @link https://www.mollie.com
- */
namespace Mollie\Laravel\Facades;
use Illuminate\Support\Facades\Facade;
-use Mollie\Laravel\Wrappers\MollieApiWrapper;
+use Mollie\Api\MollieApiClient;
+use Mollie\Laravel\MollieManager;
/**
* (Facade) Class Mollie.
*
- * @method static MollieApiWrapper api()
+ * @method static MollieApiClient api()
*/
class Mollie extends Facade
{
@@ -50,6 +20,6 @@ class Mollie extends Facade
*/
protected static function getFacadeAccessor()
{
- return 'mollie';
+ return MollieManager::class;
}
}
diff --git a/src/MollieConnectProvider.php b/src/MollieConnectProvider.php
index dd35e3a..5196b37 100644
--- a/src/MollieConnectProvider.php
+++ b/src/MollieConnectProvider.php
@@ -1,39 +1,7 @@
- * @copyright Mollie B.V.
- *
- * @link https://www.mollie.com
- */
namespace Mollie\Laravel;
-use Illuminate\Support\Arr;
use Laravel\Socialite\Two\AbstractProvider;
use Laravel\Socialite\Two\ProviderInterface;
use Laravel\Socialite\Two\User;
@@ -92,65 +60,6 @@ protected function getTokenUrl()
return static::MOLLIE_API_URL.'/oauth2/tokens';
}
- /**
- * Get the access token for the given code.
- *
- * @param string $code
- * @return string
- */
- public function getAccessToken($code)
- {
- $response = $this->getHttpClient()->post($this->getTokenUrl(), [
- 'headers' => ['Authorization' => 'Basic '.base64_encode($this->clientId.':'.$this->clientSecret)],
- 'form_params' => $this->getTokenFields($code),
- ]);
-
- return $this->parseAccessToken($response->getBody());
- }
-
- /**
- * Get the access token with a refresh token.
- *
- * @param string $refresh_token
- * @return array
- */
- public function getRefreshTokenResponse($refresh_token)
- {
- $response = $this->getHttpClient()->post($this->getTokenUrl(), [
- 'headers' => ['Accept' => 'application/json'],
- 'form_params' => $this->getRefreshTokenFields($refresh_token),
- ]);
-
- return json_decode($response->getBody(), true);
- }
-
- /**
- * Get the refresh tokenfields with a refresh token.
- *
- * @param string $refresh_token
- * @return array
- */
- protected function getRefreshTokenFields($refresh_token)
- {
- return [
- 'client_id' => $this->clientId,
- 'client_secret' => $this->clientSecret,
- 'grant_type' => 'refresh_token',
- 'refresh_token' => $refresh_token,
- ];
- }
-
- /**
- * Get the POST fields for the token request.
- *
- * @param string $code
- * @return array
- */
- public function getTokenFields($code)
- {
- return Arr::add(parent::getTokenFields($code), 'grant_type', 'authorization_code');
- }
-
/**
* Get the raw user for the given access token.
*
diff --git a/src/MollieLaravelHttpClientAdapter.php b/src/MollieLaravelHttpClientAdapter.php
index cbd87ef..296c8bf 100644
--- a/src/MollieLaravelHttpClientAdapter.php
+++ b/src/MollieLaravelHttpClientAdapter.php
@@ -9,8 +9,6 @@
class MollieLaravelHttpClientAdapter implements MollieHttpAdapterInterface
{
- private const HTTP_NO_CONTENT = 204;
-
public function send($httpMethod, $url, $headers, $httpBody): ?object
{
$contentType = $headers['Content-Type'] ?? 'application/json';
@@ -20,19 +18,17 @@ public function send($httpMethod, $url, $headers, $httpBody): ?object
->withHeaders($headers)
->send($httpMethod, $url);
- return $this->parseResponseBody($response);
+ return match (true) {
+ $response->noContent() => null,
+ $response->failed() => throw ApiException::createFromResponse($response->toPsrResponse(), null),
+ empty($response->body()) => throw new ApiException('Mollie response body is empty.'),
+ default => $this->parseResponseBody($response),
+ };
}
private function parseResponseBody(Response $response): ?object
{
$body = $response->body();
- if (empty($body)) {
- if ($response->status() === self::HTTP_NO_CONTENT) {
- return null;
- }
-
- throw new ApiException('No response body found.');
- }
$object = @json_decode($body);
@@ -40,10 +36,6 @@ private function parseResponseBody(Response $response): ?object
throw new ApiException("Unable to decode Mollie response: '{$body}'.");
}
- if ($response->status() >= 400) {
- throw ApiException::createFromResponse($response->toPsrResponse(), null);
- }
-
return $object;
}
diff --git a/src/MollieManager.php b/src/MollieManager.php
index 12f76ca..3ce3402 100644
--- a/src/MollieManager.php
+++ b/src/MollieManager.php
@@ -1,65 +1,18 @@
- * @copyright Mollie B.V.
- *
- * @link https://www.mollie.com
- */
namespace Mollie\Laravel;
use Illuminate\Contracts\Container\Container;
+use Mollie\Api\MollieApiClient;
-/**
- * Class MollieManager.
- */
class MollieManager
{
- /**
- * @var Container
- */
- protected $app;
-
- /**
- * MollieManager constructor.
- *
- * @return void
- */
- public function __construct(Container $app)
+ public function __construct(private Container $app)
{
- $this->app = $app;
}
- /**
- * @return mixed
- */
- public function api()
+ public function api(): MollieApiClient
{
- return $this->app['mollie.api'];
+ return $this->app->make(MollieApiClient::class);
}
}
diff --git a/src/MollieServiceProvider.php b/src/MollieServiceProvider.php
index 58ac478..0a17be3 100644
--- a/src/MollieServiceProvider.php
+++ b/src/MollieServiceProvider.php
@@ -1,51 +1,14 @@
- * @copyright Mollie B.V.
- *
- * @link https://www.mollie.com
- */
namespace Mollie\Laravel;
use Illuminate\Contracts\Container\Container;
-use Illuminate\Foundation\Application as LaravelApplication;
use Illuminate\Support\ServiceProvider;
-use Laravel\Lumen\Application as LumenApplication;
use Mollie\Api\MollieApiClient;
-use Mollie\Laravel\Wrappers\MollieApiWrapper;
-/**
- * Class MollieServiceProvider.
- */
class MollieServiceProvider extends ServiceProvider
{
- const PACKAGE_VERSION = '2.25.0';
+ const PACKAGE_VERSION = '3.0.0';
/**
* Boot the service provider.
@@ -54,27 +17,11 @@ class MollieServiceProvider extends ServiceProvider
*/
public function boot()
{
- $this->setupConfig();
- $this->extendSocialite();
- }
-
- /**
- * Setup the config.
- *
- * @return void
- */
- protected function setupConfig()
- {
- $source = realpath(__DIR__.'/../config/mollie.php');
-
- // Check if the application is a Laravel OR Lumen instance to properly merge the configuration file.
- if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
- $this->publishes([$source => config_path('mollie.php')]);
- } elseif ($this->app instanceof LumenApplication) {
- $this->app->configure('mollie');
+ if ($this->app->runningInConsole()) {
+ $this->publishes([__DIR__.'/../config/mollie.php' => config_path('mollie.php')]);
}
- $this->mergeConfigFrom($source, 'mollie');
+ $this->extendSocialite();
}
/**
@@ -84,8 +31,8 @@ protected function setupConfig()
*/
protected function extendSocialite()
{
- if (interface_exists('Laravel\Socialite\Contracts\Factory')) {
- $socialite = $this->app->make('Laravel\Socialite\Contracts\Factory');
+ if (interface_exists($socialiteFactoryClass = \Laravel\Socialite\Contracts\Factory::class)) {
+ $socialite = $this->app->make($socialiteFactoryClass);
$socialite->extend('mollie', function (Container $app) use ($socialite) {
$config = $app['config']['services.mollie'];
@@ -102,67 +49,22 @@ protected function extendSocialite()
*/
public function register()
{
- $this->registerApiClient();
- $this->registerApiAdapter();
- $this->registerManager();
- }
+ $this->mergeConfigFrom(__DIR__.'/../config/mollie.php', 'mollie');
- /**
- * Register the Mollie API adapter class.
- *
- * @return void
- */
- protected function registerApiAdapter()
- {
- $this->app->singleton('mollie.api', function (Container $app) {
- $config = $app['config'];
+ $this->app->singleton(
+ MollieApiClient::class,
+ function (Container $app) {
+ $client = (new MollieApiClient(new MollieLaravelHttpClientAdapter))
+ ->addVersionString('MollieLaravel/'.self::PACKAGE_VERSION);
- return new MollieApiWrapper($config, $app['mollie.api.client']);
- });
+ if (! empty($apiKey = $app['config']['mollie.key'])) {
+ $client->setApiKey($apiKey);
+ }
- $this->app->alias('mollie.api', MollieApiWrapper::class);
- }
+ return $client;
+ }
+ );
- /**
- * Register the Mollie API Client.
- *
- * @return void
- */
- protected function registerApiClient()
- {
- $this->app->singleton('mollie.api.client', function () {
- return (new MollieApiClient(new MollieLaravelHttpClientAdapter))
- ->addVersionString('MollieLaravel/'.self::PACKAGE_VERSION);
- });
-
- $this->app->alias('mollie.api.client', MollieApiClient::class);
- }
-
- /**
- * Register the manager class.
- *
- * @return void
- */
- public function registerManager()
- {
- $this->app->singleton('mollie', function (Container $app) {
- return new MollieManager($app);
- });
-
- $this->app->alias('mollie', MollieManager::class);
- }
-
- /**
- * Get the services provided by the provider.
- *
- * @return array
- */
- public function provides()
- {
- return [
- 'mollie',
- 'mollie.api',
- 'mollie.api.client',
- ];
+ $this->app->singleton(MollieManager::class);
}
}
diff --git a/src/Wrappers/MollieApiWrapper.php b/src/Wrappers/MollieApiWrapper.php
deleted file mode 100644
index 6351465..0000000
--- a/src/Wrappers/MollieApiWrapper.php
+++ /dev/null
@@ -1,459 +0,0 @@
-
- * @copyright Mollie B.V.
- *
- * @link https://www.mollie.com
- */
-
-namespace Mollie\Laravel\Wrappers;
-
-use Illuminate\Contracts\Config\Repository;
-use Mollie\Api\Exceptions\ApiException;
-use Mollie\Api\MollieApiClient;
-
-/**
- * Class MollieApiWrapper.
- */
-class MollieApiWrapper
-{
- /**
- * @var Repository
- */
- protected $config;
-
- /**
- * @var MollieApiClient
- */
- protected $client;
-
- /**
- * MollieApiWrapper constructor.
- *
- * @return void
- *
- * @throws \Mollie\Api\Exceptions\ApiException
- */
- public function __construct(Repository $config, MollieApiClient $client)
- {
- $this->config = $config;
- $this->client = $client;
-
- $key = $this->config->get('mollie.key');
-
- if (! empty($key)) {
- $this->setApiKey($key);
- }
- }
-
- /**
- * @param string $url
- */
- public function setApiEndpoint($url)
- {
- $this->client->setApiEndpoint($url);
- }
-
- /**
- * @return string
- */
- public function getApiEndpoint()
- {
- return $this->client->getApiEndpoint();
- }
-
- /**
- * @param string $api_key The Mollie API key, starting with 'test_' or 'live_'
- *
- * @throws ApiException
- */
- public function setApiKey($api_key)
- {
- $this->client->setApiKey($api_key);
- }
-
- /**
- * @param string $access_token OAuth access token, starting with 'access_'
- *
- * @throws ApiException
- */
- public function setAccessToken($access_token)
- {
- $this->client->setAccessToken($access_token);
- }
-
- /**
- * @return bool
- */
- public function usesOAuth()
- {
- return $this->client->usesOAuth();
- }
-
- /**
- * @return \Mollie\Laravel\Wrappers\MollieApiWrapper
- */
- public function addVersionString($version_string)
- {
- $this->client->addVersionString($version_string);
-
- return $this;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PaymentEndpoint
- */
- public function payments()
- {
- return $this->client->payments;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PaymentRefundEndpoint
- */
- public function paymentRefunds()
- {
- return $this->client->paymentRefunds;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PaymentRouteEndpoint
- */
- public function paymentRoutes()
- {
- return $this->client->paymentRoutes;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PaymentCaptureEndpoint
- */
- public function paymentCaptures()
- {
- return $this->client->paymentCaptures;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PaymentLinkEndpoint
- */
- public function paymentLinks()
- {
- return $this->client->paymentLinks;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\TerminalEndpoint
- */
- public function terminals()
- {
- return $this->client->terminals;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\MethodEndpoint
- */
- public function methods()
- {
- return $this->client->methods;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\ProfileMethodEndpoint
- */
- public function profileMethods()
- {
- return $this->client->profileMethods;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\CustomerEndpoint
- */
- public function customers()
- {
- return $this->client->customers;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\BalanceEndpoint
- */
- public function balances()
- {
- return $this->client->balances;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\BalanceTransactionEndpoint
- */
- public function balanceTransactions()
- {
- return $this->client->balanceTransactions;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\BalanceReportEndpoint
- */
- public function balanceReports()
- {
- return $this->client->balanceReports;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\SettlementsEndpoint
- */
- public function settlements()
- {
- return $this->client->settlements;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\SettlementPaymentEndpoint
- */
- public function settlementPayments()
- {
- return $this->client->settlementPayments;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\SubscriptionEndpoint
- */
- public function subscriptions()
- {
- return $this->client->subscriptions;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\CustomerPaymentsEndpoint
- */
- public function customerPayments()
- {
- return $this->client->customerPayments;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\MandateEndpoint
- */
- public function mandates()
- {
- return $this->client->mandates;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OrganizationEndpoint
- */
- public function organizations()
- {
- return $this->client->organizations;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PermissionEndpoint
- */
- public function permissions()
- {
- return $this->client->permissions;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\InvoiceEndpoint
- */
- public function invoices()
- {
- return $this->client->invoices;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\ProfileEndpoint
- */
- public function profiles()
- {
- return $this->client->profiles;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\ShipmentEndpoint
- */
- public function shipments()
- {
- return $this->client->shipments;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\RefundEndpoint
- */
- public function refunds()
- {
- return $this->client->refunds;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\ChargebackEndpoint
- */
- public function chargebacks()
- {
- return $this->client->chargebacks;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\PaymentChargebackEndpoint
- */
- public function paymentChargebacks()
- {
- return $this->client->paymentChargebacks;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OrderEndpoint
- */
- public function orders()
- {
- return $this->client->orders;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OrderLineEndpoint
- */
- public function orderLines()
- {
- return $this->client->orderLines;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OrderPaymentEndpoint
- */
- public function orderPayments()
- {
- return $this->client->orderPayments;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OrderRefundEndpoint
- */
- public function orderRefunds()
- {
- return $this->client->orderRefunds;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OnboardingEndpoint
- */
- public function onboarding()
- {
- return $this->client->onboarding;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\WalletEndpoint
- */
- public function wallets()
- {
- return $this->client->wallets;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\ClientEndpoint
- */
- public function clients()
- {
- return $this->client->clients;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\ClientLinkEndpoint
- */
- public function clientLinks()
- {
- return $this->client->clientLinks;
- }
-
- /**
- * @return \Mollie\Api\Endpoints\OrganizationPartnerEndpoint
- */
- public function organizationPartners()
- {
- return $this->client->organizationPartners;
- }
-
- /**
- * @return void
- *
- * @throws \Mollie\Api\Exceptions\HttpAdapterDoesNotSupportDebuggingException
- */
- public function enableDebugging()
- {
- $this->client->enableDebugging();
- }
-
- /**
- * @return void
- *
- * @throws \Mollie\Api\Exceptions\HttpAdapterDoesNotSupportDebuggingException
- */
- public function disableDebugging()
- {
- $this->client->disableDebugging();
- }
-
- public function setIdempotencyKey(string $key)
- {
- return $this->client->setIdempotencyKey($key);
- }
-
- public function resetIdempotencyKey()
- {
- return $this->client->resetIdempotencyKey();
- }
-
- public function setIdempotencyKeyGenerator($generator)
- {
- return $this->client->setIdempotencyKeyGenerator($generator);
- }
-
- public function clearIdempotencyKeyGenerator()
- {
- return $this->client->clearIdempotencyKeyGenerator();
- }
-
- /**
- * Handle dynamic property calls.
- *
- * @param string $property
- * @return mixed
- */
- public function __get($property)
- {
- if (method_exists($this, $property)) {
- return call_user_func([$this, $property]);
- }
-
- $message = '%s has no property or method "%s".';
-
- throw new \Error(
- sprintf($message, static::class, $property)
- );
- }
-}
diff --git a/src/helpers.php b/src/helpers.php
deleted file mode 100644
index c972e59..0000000
--- a/src/helpers.php
+++ /dev/null
@@ -1,11 +0,0 @@
-assertTrue(function_exists('mollie'));
-
- $this->assertInstanceOf('\Mollie\Laravel\Wrappers\MollieApiWrapper', mollie());
- }
-}
diff --git a/tests/MollieApiClientTest.php b/tests/MollieApiClientTest.php
new file mode 100644
index 0000000..ab26be6
--- /dev/null
+++ b/tests/MollieApiClientTest.php
@@ -0,0 +1,49 @@
+assertInstanceOf(
+ MollieLaravelHttpClientAdapter::class,
+ $this->getUnaccessiblePropertyValue('httpClient')
+ );
+ }
+
+ public function testApiKeyIsSetOnResolvingApiClient()
+ {
+ config(['mollie.key' => 'test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxyz']);
+
+ $this->assertEquals(
+ 'test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxyz',
+ $this->getUnaccessiblePropertyValue('apiKey')
+ );
+ }
+
+ public function testDoesNotSetApiKeyIfKeyIsEmpty()
+ {
+ config(['mollie.key' => '']);
+
+ $this->assertEquals(
+ null,
+ $this->getUnaccessiblePropertyValue('apiKey')
+ );
+ }
+
+ private function getUnaccessiblePropertyValue(string $propertyName): mixed
+ {
+ $resolvedInstance = resolve(MollieApiClient::class);
+
+ $reflection = new ReflectionClass($resolvedInstance);
+ $property = $reflection->getProperty($propertyName);
+ $property->setAccessible(true);
+
+ return $property->getValue($resolvedInstance);
+ }
+}
diff --git a/tests/MollieConnectProviderTest.php b/tests/MollieConnectProviderTest.php
deleted file mode 100644
index b1a3cf7..0000000
--- a/tests/MollieConnectProviderTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-markTestSkipped('Laravel Socialite must be present.');
- }
- }
-
- public function testRedirectGeneratesTheProperSymfonyRedirectResponse()
- {
- $request = Request::create('foo');
- $request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
- $session->shouldReceive('put')->once();
- $provider = new MollieConnectProvider($request, 'client_id', 'client_secret', 'redirect');
- $response = $provider->redirect();
- $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
- $this->assertStringStartsWith(
- 'https://www.mollie.com/oauth2/authorize?client_id=client_id&redirect_uri=redirect&scope=organizations.read&response_type=code&state=',
- $response->getTargetUrl()
- );
- }
-
- public function testExceptionIsThrownIfStateIsInvalid()
- {
- $this->expectException(\Laravel\Socialite\Two\InvalidStateException::class);
- $request = Request::create('foo', 'GET', ['state' => str_repeat('B', 40), 'code' => 'code']);
- $request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
- $session->shouldReceive('pull')->once()->with('state')->andReturn(str_repeat('A', 40));
- $provider = new MollieConnectProvider($request, 'client_id', 'client_secret', 'redirect');
- $user = $provider->user();
- }
-
- public function testExceptionIsThrownIfStateIsNotSet()
- {
- $this->expectException(\Laravel\Socialite\Two\InvalidStateException::class);
- $request = Request::create('foo', 'GET', ['state' => 'state', 'code' => 'code']);
- $request->setSession($session = m::mock('Symfony\Component\HttpFoundation\Session\SessionInterface'));
- $session->shouldReceive('pull')->once()->with('state');
- $provider = new MollieConnectProvider($request, 'client_id', 'client_secret', 'redirect');
- $user = $provider->user();
- }
-
- public function testGetTokenFields()
- {
- $request = Request::create('foo');
- $provider = new MollieConnectProvider($request, 'client_id', 'client_secret', 'redirect');
- $this->assertEquals(
- [
- 'client_id' => 'client_id',
- 'client_secret' => 'client_secret',
- 'code' => 'dummy_code',
- 'redirect_uri' => 'redirect',
- 'grant_type' => 'authorization_code',
- ],
- $provider->getTokenFields('dummy_code')
- );
- }
-}
diff --git a/tests/Wrappers/MollieApiLaravelClientTest.php b/tests/MollieLaravelHttpClientAdapterTest.php
similarity index 87%
rename from tests/Wrappers/MollieApiLaravelClientTest.php
rename to tests/MollieLaravelHttpClientAdapterTest.php
index 60b730f..ee75d84 100644
--- a/tests/Wrappers/MollieApiLaravelClientTest.php
+++ b/tests/MollieLaravelHttpClientAdapterTest.php
@@ -1,16 +1,15 @@
Http::response(json_encode($payment)),
]);
- $client->setApiKey('test_nawruSyCR7UE84EhtVmMmDGdRswBqj');
$returnedPayment = $client->payments->create([
'redirectUrl' => 'https://google.com/redirect',
'description' => 'test',
@@ -53,7 +51,6 @@ public function testGetRequest()
'https://api.mollie.com/v2/payments/'.$payment->id => Http::response(json_encode($payment)),
]);
- $client->setApiKey('test_nawruSyCR7UE84EhtVmMmDGdRswBqj');
$returnedPayment = $client->payments->get($payment->id);
$this->assertEquals($payment->id, $returnedPayment->id);
diff --git a/tests/MollieManagerTest.php b/tests/MollieManagerTest.php
deleted file mode 100644
index b1ab634..0000000
--- a/tests/MollieManagerTest.php
+++ /dev/null
@@ -1,37 +0,0 @@
-setUpManagerInstance();
- $this->assertInstanceOf(MollieManager::class, $this->manager);
- }
-
- public function testApiMethod()
- {
- $this->setUpManagerInstance();
- $this->assertInstanceOf(MollieApiWrapper::class, $this->manager->api());
- $this->assertSame($this->app['mollie.api'], $this->manager->api());
- }
-
- public function setUpManagerInstance()
- {
- $this->manager = new MollieManager($this->app);
- }
-}
diff --git a/tests/MollieServiceProviderTest.php b/tests/MollieServiceProviderTest.php
deleted file mode 100644
index 2fdffa0..0000000
--- a/tests/MollieServiceProviderTest.php
+++ /dev/null
@@ -1,31 +0,0 @@
-assertIsInjectable(MollieManager::class);
- }
-
- public function testMollieApiWrapperIsInjectable()
- {
- $this->assertIsInjectable(MollieApiWrapper::class);
- }
-
- public function testMollieApiClientIsInjectable()
- {
- $this->assertIsInjectable(MollieApiClient::class);
- }
-}
diff --git a/tests/TempHelpers/FacadeTrait.php b/tests/TempHelpers/FacadeTrait.php
deleted file mode 100644
index 5eb6466..0000000
--- a/tests/TempHelpers/FacadeTrait.php
+++ /dev/null
@@ -1,91 +0,0 @@
-getFacadeClass();
- $reflection = new ReflectionClass($class);
- $facade = new ReflectionClass(Facade::class);
-
- $msg = "Expected class '$class' to be a facade.";
-
- $this->assertTrue($reflection->isSubclassOf($facade), $msg);
- }
-
- public function testFacadeAccessor()
- {
- $accessor = $this->getFacadeAccessor();
- $class = $this->getFacadeClass();
- $reflection = new ReflectionClass($class);
- $method = $reflection->getMethod('getFacadeAccessor');
- $method->setAccessible(true);
-
- $msg = "Expected class '$class' to have an accessor of '$accessor'.";
-
- $this->assertSame($accessor, $method->invoke(null), $msg);
- }
-
- public function testFacadeRoot()
- {
- $root = $this->getFacadeRoot();
- $class = $this->getFacadeClass();
- $reflection = new ReflectionClass($class);
- $method = $reflection->getMethod('getFacadeRoot');
- $method->setAccessible(true);
-
- $msg = "Expected class '$class' to have a root of '$root'.";
-
- $this->assertInstanceOf($root, $method->invoke(null), $msg);
- }
-
- public function testServiceProvider()
- {
- $accessor = $this->getFacadeAccessor();
- $provider = $this->getServiceProviderClass($this->app);
-
- if ($provider) {
- $reflection = new ReflectionClass($provider);
- $method = $reflection->getMethod('provides');
- $method->setAccessible(true);
-
- $msg = "Expected class '$provider' to provide '$accessor'.";
- $this->assertContains($accessor, $method->invoke(new $provider($this->app)), $msg);
- }
- }
-}
diff --git a/tests/TempHelpers/LaravelTrait.php b/tests/TempHelpers/LaravelTrait.php
deleted file mode 100644
index e27a49c..0000000
--- a/tests/TempHelpers/LaravelTrait.php
+++ /dev/null
@@ -1,67 +0,0 @@
-makeInjectableClass($name);
- $this->assertInstanceOf($name, $class->getInjectedObject());
- } catch (Exception $e) {
- $injectable = false;
- if ($msg = $e->getMessage()) {
- $message .= " $msg";
- }
- }
-
- $this->assertTrue($injectable, $message);
- }
-
- /**
- * Register and make a stub class to inject into.
- *
- *
- * @return object
- */
- protected function makeInjectableClass(string $name)
- {
- do {
- $class = 'testBenchStub'.Str::random();
- } while (class_exists($class));
-
- eval("
- class $class
- {
- protected \$object;
-
- public function __construct(\\$name \$object)
- {
- \$this->object = \$object;
- }
-
- public function getInjectedObject()
- {
- return \$this->object;
- }
- }
- ");
-
- return $this->app->make($class);
- }
-}
diff --git a/tests/TempHelpers/MockeryTrait.php b/tests/TempHelpers/MockeryTrait.php
deleted file mode 100644
index 51f6598..0000000
--- a/tests/TempHelpers/MockeryTrait.php
+++ /dev/null
@@ -1,30 +0,0 @@
-addToAssertionCount($container->mockery_getExpectationCount());
- }
-
- Mockery::close();
- }
- }
-}
diff --git a/tests/TempHelpers/ServiceProviderTrait.php b/tests/TempHelpers/ServiceProviderTrait.php
deleted file mode 100644
index 20624a4..0000000
--- a/tests/TempHelpers/ServiceProviderTrait.php
+++ /dev/null
@@ -1,44 +0,0 @@
-getServiceProviderClass($this->app);
-
- $reflection = new ReflectionClass($class);
-
- $provider = new ReflectionClass(ServiceProvider::class);
-
- $msg = "Expected class '$class' to be a service provider.";
-
- $this->assertTrue($reflection->isSubclassOf($provider), $msg);
- }
-
- public function testProvides()
- {
- $class = $this->getServiceProviderClass($this->app);
- $reflection = new ReflectionClass($class);
-
- $method = $reflection->getMethod('provides');
- $method->setAccessible(true);
-
- $msg = "Expected class '$class' to provide a valid list of services.";
-
- $this->assertIsArray($method->invoke(new $class($this->app)), $msg);
- }
-}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index a51058a..287725f 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -3,25 +3,12 @@
namespace Mollie\Laravel\Tests;
use Mollie\Laravel\MollieServiceProvider;
-use Mollie\Laravel\Tests\TempHelpers\LaravelTrait;
/**
* This is the abstract test case class.
*/
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
- use LaravelTrait;
-
- /**
- * Get the service provider class.
- *
- * @return string
- */
- protected function getServiceProviderClass()
- {
- return MollieServiceProvider::class;
- }
-
/**
* Get package providers.
*
diff --git a/tests/Wrappers/MollieApiWrapperTest.php b/tests/Wrappers/MollieApiWrapperTest.php
deleted file mode 100644
index 37fd851..0000000
--- a/tests/Wrappers/MollieApiWrapperTest.php
+++ /dev/null
@@ -1,230 +0,0 @@
-api = $this->getMockBuilder(MollieApiClient::class)
- ->disableOriginalConstructor()
- ->getMock();
- }
-
- public function testConstruct()
- {
- $wrapper = new MollieApiWrapper($this->app['config'], $this->app[MollieApiClient::class]);
- $this->assertInstanceOf(MollieApiWrapper::class, $wrapper);
- }
-
- public function testApiEndpoint()
- {
- $this->api->expects($this->once())->method('setApiEndpoint');
- $this->api->expects($this->once())->method('getApiEndpoint')->willReturn('/test');
-
- $wrapper = new MollieApiWrapper($this->app['config'], $this->api);
-
- $wrapper->setApiEndpoint('/test');
- $this->assertSame('/test', $wrapper->getApiEndpoint());
- }
-
- public function testSetGoodApiKey()
- {
- $this->api->expects($this->atLeastOnce())->method('setApiKey')->with('test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
-
- $wrapper = new MollieApiWrapper($this->app['config'], $this->api);
- $wrapper->setApiKey('test_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
- }
-
- public function testSetBadApiKey()
- {
- $this->expectException(\Mollie\Api\Exceptions\ApiException::class);
- $this->expectExceptionMessage("Invalid API key: 'live_'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long.");
- $wrapper = new MollieApiWrapper($this->app['config'], $this->app[MollieApiClient::class]);
- $wrapper->setApiKey('live_');
- }
-
- public function testDoesNotSetKeyWhenEmpty()
- {
- config(['mollie.key' => '']);
- $this->assertEmpty($this->app['config']['mollie']['key']);
- $this->api->expects($this->never())->method('setApiKey');
-
- $wrapper = new MollieApiWrapper($this->app['config'], $this->api);
- }
-
- public function testSetGoodToken()
- {
- $this->api->expects($this->once())->method('setAccessToken')->with('access_xxx');
-
- $wrapper = new MollieApiWrapper($this->app['config'], $this->api);
- $wrapper->setAccessToken('access_xxx');
- }
-
- public function testSetBadToken()
- {
- $this->expectException(\Mollie\Api\Exceptions\ApiException::class);
- $this->expectExceptionMessage("Invalid OAuth access token: 'BAD'. An access token must start with 'access_'.");
- $wrapper = new MollieApiWrapper($this->app['config'], $this->app[MollieApiClient::class]);
- $wrapper->setAccessToken('BAD');
- }
-
- public function testEnableDebugging()
- {
- $this->api->expects($this->once())->method('enableDebugging');
-
- $wrapper = new MollieApiWrapper($this->app['config'], $this->api);
- $wrapper->enableDebugging();
- }
-
- public function testDisableDebugging()
- {
- $this->api->expects($this->once())->method('disableDebugging');
-
- $wrapper = new MollieApiWrapper($this->app['config'], $this->api);
- $wrapper->disableDebugging();
- }
-
- public function testWrappedEndpoints()
- {
- $client = $this->app[MollieApiClient::class];
- $wrapper = new MollieApiWrapper(
- $this->app['config'],
- $client
- );
-
- foreach ($this->endpoints as $endpoint) {
- $this->assertWrappedEndpoint($client, $wrapper, $endpoint);
- }
- }
-
- public function testWrappedPropertyEndpoints()
- {
- $client = $this->app[MollieApiClient::class];
- $wrapper = new MollieApiWrapper(
- $this->app['config'],
- $client
- );
-
- foreach ($this->endpoints as $endpoint) {
- $this->assertWrappedPropertyEndpoint($client, $wrapper, $endpoint);
- }
- }
-
- public function testUnknownWrappedEndpoint()
- {
- $client = $this->app[MollieApiClient::class];
- $wrapper = new MollieApiWrapper(
- $this->app['config'],
- $client
- );
-
- $this->expectException(\Error::class);
- $this->expectExceptionMessage('Call to undefined method Mollie\Laravel\Wrappers\MollieApiWrapper::unknown()');
-
- $wrapper->unknown();
- }
-
- public function testUnknownWrappedPropertyEndpoint()
- {
- $client = $this->app[MollieApiClient::class];
- $wrapper = new MollieApiWrapper(
- $this->app['config'],
- $client
- );
-
- $this->expectException(\Error::class);
- $this->expectExceptionMessage('Mollie\Laravel\Wrappers\MollieApiWrapper has no property or method "unknown".');
-
- $wrapper->unknown;
- }
-
- /**
- * Asserts that the referenced wrapper method matches the client attribute
- * I.e. $wrapper->payments() returns the same as $client->payments.
- *
- * @param MollieApiClient $client
- * @param MollieApiWrapper $wrapper
- * @param string $reference
- * @return null
- *
- * @throws ExpectationFailedException
- * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
- */
- protected function assertWrappedEndpoint($client, $wrapper, $reference)
- {
- $this->assertEquals($client->$reference, $wrapper->$reference());
- }
-
- /**
- * Asserts that the referenced wrapper property matches the client attribute
- * I.e. $wrapper->payments returns the same as $client->payments.
- *
- * @param MollieApiClient $client
- * @param MollieApiWrapper $wrapper
- * @param string $reference
- * @return null
- *
- * @throws ExpectationFailedException
- * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
- */
- protected function assertWrappedPropertyEndpoint($client, $wrapper, $reference)
- {
- $this->assertEquals($client->$reference, $wrapper->$reference);
- }
-}