Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray committed Mar 7, 2024
1 parent 24c14e4 commit e8c0206
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 84 deletions.
63 changes: 61 additions & 2 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand All @@ -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
<?php

use \Mollie\Api\MollieApiClient;

if (! function_exists('mollie')) {
/**
* @return MollieApiClient
*/
function mollie()
{
return resolve(MollieApiClient::class);
}
}
```

## Stuck?
Feel free to open an [issue](https://github.com/mollie/laravel-mollie/issues).
52 changes: 0 additions & 52 deletions docs/migration_instructions_v1_to_v2.md

This file was deleted.

5 changes: 2 additions & 3 deletions docs/mollie_connect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
```

8 changes: 4 additions & 4 deletions docs/recurring_and_direct_charge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '[email protected]',
]);
Expand All @@ -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
Expand All @@ -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
Expand Down
22 changes: 1 addition & 21 deletions docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions docs/webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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...
Expand Down

0 comments on commit e8c0206

Please sign in to comment.