mollie / laravel-cashier-mollie

Official Mollie integration for Laravel Cashier
https://www.cashiermollie.com/
MIT License
134 stars 44 forks source link

Error executing API call (422: Unprocessable Entity): No suitable payment methods found #249

Closed WEBronckhorst closed 4 weeks ago

WEBronckhorst commented 2 months ago

I am experiencing an issue when attempting to create a new subscription using the Laravel Cashier Mollie package. The error message returned is:

Error executing API call (422: Unprocessable Entity): No suitable payment methods found. Documentation: https://docs.mollie.com/overview/handling-errors

Function:

public function save()
{
    $name = ucfirst($this->plan).' membership';

    dd($this->user->newSubscription('etst', $this->plan)->create());
}

Config Files: config/cashier_plans.php:

<?php

use Laravel\Cashier\Coupon\CouponOrderItemPreprocessor as ProcessCoupons;
use Laravel\Cashier\Order\PersistOrderItemsPreprocessor as PersistOrderItems;
use Laravel\Cashier\Plan\AdvancedIntervalGenerator;

return [
    'defaults' => [
        'first_payment' => config('cashier.first_payment'),
        'order_item_preprocessors' => [
            ProcessCoupons::class,
            PersistOrderItems::class,
        ],
    ],
    'plans' => [
        'try out' => [
            'amount' => [
                'value' => '84.50',
                'currency' => 'EUR',
            ],
            'method' => ['ideal', 'paypal'],
            'interval' => [
                'generator' => AdvancedIntervalGenerator::class,
                'value' => 3,
                'period' => 'month',
                'monthOverflow' => true,
            ],
            'description' => 'Leen 4 items die je onbeperkt om mag wisselen.',
            'order_item_preprocessors' => [
                ProcessCoupons::class,
                PersistOrderItems::class,
            ],
        ],
        'regular' => [
            'amount' => [
                'value' => '289.00',
                'currency' => 'EUR',
            ],
            'interval' => [
                'generator' => AdvancedIntervalGenerator::class,
                'value' => 1,
                'period' => 'year',
                'monthOverflow' => true,
            ],
            'description' => 'Leen 4 items die je onbeperkt om mag wisselen + een GAIA shopper cadeau.',
        ],
        'premium' => [
            'amount' => [
                'value' => '579.00',
                'currency' => 'EUR',
            ],
            'interval' => [
                'generator' => AdvancedIntervalGenerator::class,
                'value' => 1,
                'period' => 'year',
                'monthOverflow' => true,
            ],
            'description' => 'Leen maar liefst 10 items die je onbeperkt om mag wisselen + een GAIA shopper cadeau.',
        ],
    ],
];

config/cashier.php:

<?php

return [
    'webhook_url' => 'webhooks/mollie',
    'aftercare_webhook_url' => 'webhooks/mollie/aftercare',
    'locale' => null,
    'order_number_generator' => [
        'model' => \Laravel\Cashier\Order\OrderNumberGenerator::class,
        'offset' => 0,
    ],
    'first_payment' => [
        'webhook_url' => 'webhooks/mollie/first-payment',
        'method' => ['ideal', 'paypal'],
        'redirect_url' => config('app.url'),
        'amount' => [
            'value' => '1.00',
            'currency' => 'EUR',
        ],
        'description' => 'Welcome to '.config('app.name'),
    ],
    'update_payment_method' => [
        'redirect_url' => config('app.url'),
        'amount' => [
            'value' => '1.00',
            'currency' => 'EUR',
        ],
        'description' => 'Update payment method for '.config('app.name'),
    ],
];

Steps to Reproduce:

Call the save() method in my controller. Receive the error mentioned above. Expected Behavior: The subscription should be created without errors.

Actual Behavior: The API call fails with the error message indicating that no suitable payment methods were found.

Additional Context:

Laravel version: 11 PHP version: 8.2

Please let me know if you need any further information to help diagnose this issue. Thank you!

sandervanhooft commented 2 months ago

Hi @WEBronckhorst ,

What payment methods have you enabled on your Mollie profile? Ensure that at least one is eligible for recurring.