Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: "Update Changelog"

on:
release:
types: [released]

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: master
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
28 changes: 28 additions & 0 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: PHPStan

on:
push:
paths:
- "**.php"
- "phpstan.neon.dist"
- ".github/workflows/phpstan.yml"

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.4"
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
24 changes: 17 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ jobs:
strategy:
fail-fast: true
matrix:
php: ['8.1', '8.2', '8.3', '8.4', '8.5']
laravel: ['10.0', '11.0', '12.0']
php: ['8.2', '8.3', '8.4', '8.5']
laravel: ['11.0', '12.0']
exclude:
- laravel: '11.0'
php: '8.0'
- laravel: '11.0'
php: '8.1'
- laravel: '12.0'
php: '8.1'
php: '8.2'

name: P${{ matrix.php }} - L${{ matrix.laravel }}

Expand All @@ -37,6 +33,20 @@ jobs:
tools: composer:v2
coverage: none

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}-${{ matrix.laravel }}
restore-keys: |
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-${{ matrix.php }}-
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}-
${{ runner.os }}-composer-

- name: Install dependencies
run: |
composer require "illuminate/contracts=^${{ matrix.laravel }}" --no-update
Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ Accepting [iDEAL](https://www.mollie.com/en/payments/ideal/), [Apple Pay](https:
* 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 >= 8.1
* [Laravel](https://www.laravel.com) >= 10.0
* PHP >= 8.2
* [Laravel](https://www.laravel.com) >= 11.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 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).
## Upgrading from v3.x?
To support the enhanced Mollie API v3, 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.

Expand All @@ -43,7 +43,7 @@ Or add it to `composer.json` manually:

```json
"require": {
"mollie/laravel-mollie": "^3.0"
"mollie/laravel-mollie": "^4.0"
}
```

Expand Down Expand Up @@ -78,6 +78,10 @@ public function preparePayment()
"webhookUrl" => route('webhooks.mollie'),
"metadata" => [
"order_id" => "12345",
"customer_info" => [
"name" => "John Doe",
"email" => "john@example.com"
]
],
]);

Expand Down
31 changes: 19 additions & 12 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,41 @@
![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png)

# Migrating from Laravel-Mollie v2.x to v3
# Migrating from Laravel-Mollie v3.x to v4

## Update composer dependencies

Update `composer.json` to match this:

```json
"require": {
"mollie/laravel-mollie": "^3.0"
"mollie/laravel-mollie": "^4.0"
}
```

Then run `composer update mollie/laravel-mollie`.

## Review Changes
### Updating Dependencies
Laravel-Mollie now requires PHP 8.1.0 or greater.
Laravel-Mollie now requires PHP 8.2.0 or greater and supports Laravel 11.0 and 12.0 only. It leverages mollie-api-php version 3, which includes several breaking changes.

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)
### Mollie API PHP v3 Upgrade
This version upgrades to mollie-api-php v3, which includes several breaking changes:

#### 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.
1. **Metadata Type Restriction**: In v3, metadata in request payloads is restricted to only accept arrays (not strings or objects).
2. **Class & Method Renames**: Several endpoint classes and methods have been renamed.
3. **Streamlined Constants**: Redundant prefixes have been removed for a cleaner API.
4. **Test Mode Handling**: Automatic detection with API keys and explicit parameter for organization credentials.
5. **Modern HTTP Handling**: PSR-18 support and typed request objects.

### Removed Classes
In order to enhance maintainability the following class was removed:
For full details on the mollie-api-php v3 changes, see the [official upgrade guide](https://github.com/mollie/mollie-api-php/blob/master/UPGRADING.md).

- `MollieApiWrapper`
### Socialite Integration Changes
The Socialite integration has been moved to a dedicated service provider (`MollieSocialiteServiceProvider`) which is automatically registered alongside the main provider. This allows the main `MollieServiceProvider` to be deferred, improving application performance when the Mollie API is not being used.

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.
### Deferred Service Provider
The main `MollieServiceProvider` is now deferrable, which means it will only be loaded when the Mollie API is actually used in your application. This can improve application performance.

If you're using the Socialite integration, the `MollieSocialiteServiceProvider` will still be loaded on every request to ensure the Socialite driver is properly registered.

### 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.****
Expand All @@ -44,7 +51,7 @@ 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
- use the `Mollie\Laravel\Facades\Mollie::api()` 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.

Expand All @@ -66,4 +73,4 @@ if (! function_exists('mollie')) {
```

## Stuck?
Feel free to open an [issue](https://github.com/mollie/laravel-mollie/issues).
Feel free to open an [issue](https://github.com/mollie/laravel-mollie/issues) or come say hi in the [Mollie Community Discord](https://discord.gg/mollie).
158 changes: 158 additions & 0 deletions bin/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#!/bin/bash

VERSION=$1

# Check if version is provided
if [ -z "$VERSION" ]; then
echo "❌ Error: Version number is required"
echo "Usage: ./bin/release <version>"
echo "Example: ./bin/release 1.0.0"
exit 1
fi

# Check if gh CLI is installed
if ! command -v gh &> /dev/null; then
echo "❌ Error: GitHub CLI (gh) is not installed"
echo "Please install it from: https://cli.github.com/"
exit 1
fi

# Check if we're in a git repository
if ! git rev-parse --git-dir > /dev/null 2>&1; then
echo "❌ Error: Not in a git repository"
exit 1
fi

# Check if there are uncommitted changes
if ! git diff-index --quiet HEAD --; then
echo "❌ Error: There are uncommitted changes. Please commit or stash them first."
exit 1
fi

# Get default branch from GitHub with better error handling
echo "🔍 Getting default branch from GitHub..."
DEFAULT_BRANCH_JSON=$(gh repo view --json defaultBranchRef 2>/dev/null)
if [ $? -ne 0 ]; then
echo "❌ Error: Failed to get repository information from GitHub"
echo " Please check your GitHub CLI authentication and repository access"
exit 1
fi

DEFAULT_BRANCH=$(echo "$DEFAULT_BRANCH_JSON" | grep -o '"name":"[^"]*"' | cut -d'"' -f4)
if [ -z "$DEFAULT_BRANCH" ]; then
echo "⚠️ Warning: Could not determine default branch, using 'main'"
DEFAULT_BRANCH="main"
fi

echo "📌 Local HEAD: $(git rev-parse HEAD)"
echo "📌 GitHub default branch: $DEFAULT_BRANCH"

# Fetch latest changes from remote
echo "🔄 Fetching latest changes from remote..."
git fetch origin

# Check if local branch is up-to-date with remote
LOCAL_HEAD=$(git rev-parse HEAD)
REMOTE_HEAD=$(git rev-parse origin/$DEFAULT_BRANCH 2>/dev/null)

if [ -z "$REMOTE_HEAD" ]; then
echo "❌ Error: Could not find remote branch origin/$DEFAULT_BRANCH"
exit 1
fi

if [ "$LOCAL_HEAD" != "$REMOTE_HEAD" ]; then
echo "❌ Error: Local branch is not up-to-date with remote"
echo " Local HEAD: $LOCAL_HEAD"
echo " Remote HEAD: $REMOTE_HEAD"
echo " Please pull the latest changes: git pull origin $DEFAULT_BRANCH"
exit 1
fi

echo "✅ Local repository is up-to-date with remote"

# Define the path to MollieServiceProvider.php
MOLLIE_CLIENT_FILE="src/MollieServiceProvider.php"

# Check if MollieServiceProvider.php exists
if [ ! -f "$MOLLIE_CLIENT_FILE" ]; then
echo "❌ Error: MollieServiceProvider.php not found at $MOLLIE_CLIENT_FILE"
exit 1
fi

# Check if tag already exists
if git tag -l | grep -q "^v$VERSION$"; then
echo "❌ Error: Tag v$VERSION already exists"
exit 1
fi

echo "🔄 Updating CLIENT_VERSION to $VERSION in MollieServiceProvider.php..."

# Update the CLIENT_VERSION constant in MollieServiceProvider.php
if sed -i.bak "s/const PACKAGE_VERSION = '[^']*'/const PACKAGE_VERSION = '$VERSION'/g" "$MOLLIE_CLIENT_FILE"; then
echo "✅ CLIENT_VERSION updated successfully"
# Remove backup file created by sed
rm "${MOLLIE_CLIENT_FILE}.bak"
else
echo "❌ Error: Failed to update CLIENT_VERSION"
exit 1
fi

# Check if the version was actually updated
if grep -q "CLIENT_VERSION = '$VERSION'" "$MOLLIE_CLIENT_FILE"; then
echo "✅ Version update verified"
else
echo "❌ Error: Version update verification failed"
exit 1
fi

# Commit the version update
echo "📝 Committing version update..."
git add "$MOLLIE_CLIENT_FILE"
git commit -m "Update CLIENT_VERSION to $VERSION"

echo "🏷️ Creating tag v$VERSION..."

# Create tag and push
git tag -a "v$VERSION" -m "Release $VERSION"
git push origin "v$VERSION"

echo "⏱️ Waiting for GitHub to recognize the new tag..."
sleep 3

# Verify tag exists on GitHub
echo "🔍 Verifying tag exists on GitHub..."
TAG_CHECK=$(gh release list --repo mollie/laravel-mollie 2>/dev/null | grep "v$VERSION" || echo "")
if [ -n "$TAG_CHECK" ]; then
echo "❌ Error: Release v$VERSION already exists on GitHub"
exit 1
fi

# Double-check that we can see the tag
GH_TAG_CHECK=$(gh api repos/mollie/laravel-mollie/git/refs/tags/v$VERSION 2>/dev/null || echo "not_found")
if [ "$GH_TAG_CHECK" = "not_found" ]; then
echo "⚠️ Warning: Tag not immediately visible on GitHub, waiting longer..."
sleep 5
fi

echo "🚀 Creating GitHub release..."

# Generate release from current HEAD with better error handling
RELEASE_OUTPUT=$(gh release create "v$VERSION" \
--target "$(git rev-parse HEAD)" \
--latest \
--generate-notes 2>&1)

if [ $? -eq 0 ]; then
echo "✅ Release v$VERSION created successfully!"
echo "$RELEASE_OUTPUT"
else
echo "❌ Error: Failed to create GitHub release"
echo "$RELEASE_OUTPUT"
echo ""
echo "🔍 Troubleshooting tips:"
echo " 1. Check if you have write permissions to the repository"
echo " 2. Verify your GitHub CLI authentication: gh auth status"
echo " 3. Try creating the release manually on GitHub.com"
echo " 4. Check if the tag was created successfully: git tag -l | grep v$VERSION"
exit 1
fi
Loading