From e8c0206bf25d9719a7c2e37f55692fd7a51149e7 Mon Sep 17 00:00:00 2001 From: Krishan Koenig Date: Thu, 7 Mar 2024 13:02:40 +0100 Subject: [PATCH] wip --- UPGRADE.md | 63 ++++++++++++++++++++++++- docs/migration_instructions_v1_to_v2.md | 52 -------------------- docs/mollie_connect.md | 5 +- docs/recurring_and_direct_charge.md | 8 ++-- docs/roadmap.md | 22 +-------- docs/webhook.md | 4 +- 6 files changed, 70 insertions(+), 84 deletions(-) delete mode 100644 docs/migration_instructions_v1_to_v2.md diff --git a/UPGRADE.md b/UPGRADE.md index a9d0346..cf7499b 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -2,7 +2,7 @@ # Migrating from Laravel-Mollie v2.x to v3 -### Step 1: Update composer dependencies +## Update composer dependencies Update `composer.json` to match this: @@ -14,8 +14,67 @@ Update `composer.json` to match this: Then run `composer update mollie/laravel-mollie`. -### Step 2: +## 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 +Previous versions of Laravel-Mollie forced you to call our endpoints through a static `api()` call. This has been removed to be in line with the mollie-api-php sdk. This also means that you can inject the `MollieApiClient` anywhere you like and it will already have the api key set for you. + +```php +// before +Mollie::api()->payments()->create(); + +// now +Mollie::payments()->create(); +``` + +Another small change we introduce is accessing endpoints through methods instead of properties. Previous versions would allow both. Going forward we will only support accessing endpoints through methods as this makes maintainability much easier. + +```php +// before +$client->payments->create(); + +// now +$client->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..a866f84 100644 --- a/docs/mollie_connect.md +++ b/docs/mollie_connect.md @@ -44,9 +44,8 @@ Route::get('login', function () { Route::get('login_callback', function () { $user = Socialite::with('mollie')->user(); - Mollie::api()->setAccessToken($user->token); + Mollie::setAccessToken($user->token); - return Mollie::api()->profiles()->page(); // Retrieve payment profiles available on the obtained Mollie account + return Mollie::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..e546ed2 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::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::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::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::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..4d3265e 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::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::payments()->get($request->id); if ($payment->isPaid()) { // do your thing...