-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from mollie/provide-laravel-11-compatibiity
Provide laravel 11 compatibiity
- Loading branch information
Showing
31 changed files
with
211 additions
and
1,594 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
</p> | ||
<h1 align="center">Mollie for Laravel</h1> | ||
|
||
<img src="https://github.com/mollie/laravel-mollie/assets/7265703/d86d2ab5-d83c-4bc5-b49d-60ee01922b2a" /> | ||
![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:[email protected]). | ||
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:[email protected]). | ||
|
||
## 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) — [email protected] — +31 20-612 88 55 | ||
Contact: [www.mollie.com](https://www.mollie.com) — [email protected] | ||
|
||
* [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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
<?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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' => '[email protected]', | ||
]); | ||
|
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.