mollie / mollie-api-php

Mollie API client for PHP
http://www.mollie.com
BSD 2-Clause "Simplified" License
552 stars 191 forks source link

The amount is higher than the maximum. #49

Closed DePalmo closed 7 years ago

DePalmo commented 7 years ago

I'm trying to do a subscription based billing and everything is working fine, up to a point when I actually do call create subscription. Customer is even properly charged on first payment, but when trying to create a subscription, error occurs. This was only tested on test API, not yet on live.

From what I have been able to figure it out, this error shows on creditcard type of payment when amount is above 250.00, but when I call $mollie->methods->get('creditcard'), I see that the maximum is 1000.00.

So, why this error?

Some code:

$customer=$mollie->customers->create([
    'name'=>'Test User',
    'email'=>'test@example.com,
    'metadata'=>array(
        'user_id'=>1
    )
]);
$mollie->customers_payments->withParentId($customer->id)->create([
    'amount'=>360.00,
    'description'=>'Subscription',
    'redirectUrl'=>'http://www.example.com/return-url/?with=params',
    'recurringType'=>'first',
    'metadata'=>array(
        'user_id'=>$_SESSION['uID']
    ),
    'webhookUrl'=>'http://www.example.com/payment-hook/'
]);

Note that this payments goes through normally. User is redirected and he/she gives a consent for futher billing.

Next a check for valid or pending mandate is made, so I will skip this part of code and go straight to subscription creation:

$mollie->customers_subscriptions->withParentId($customer->id)->create([
    'amount'=>360.00, // anything above 250.00 throw error (The amount is higher than the maximum.)
    'interval'=>'1 month',
    'startDate'=>date('Y-m-d',$time_with_added_one_month),
    'description'=>'Subscription',
    'webhookUrl'=>'http://www.example.com/payment-hook/'
]);

As far as I'm understanding your documentation, this should work, but it doesn't. Can you please give any clues why not?

Daanvm commented 7 years ago

Hi @DePalmo,

The maximum amount for CreditCard is indeed 1000.00. The maximum of 250.00 that you're seeing is for the payment method Direct Debit.

You didn't specify a payment method for the first payment, so you had to select it on the Mollie payment screen. You probably didn't chose the CreditCard option, so you created a mandate with payment method directdebit.

You can specify the payment method for the first payment with 'method'=>'creditcard'.

I admit it's a bit confusing that you can complete the first payment of 360.00 euro with for example ideal, while we know in advance that you'll never be able to do a second recurring payment with the same amount. On the other hand I can think of use cases where the amount of first payment will be higher than the recurring payments, e.g. because of some setup fee. So we probably don't want to restrict this.

Depending on the service that you're offering we can also increase the default maximum amount for Direct Debit payments. You should contact Support at info@mollie.com for more info.

DePalmo commented 7 years ago

Hi @Daanvm

Thank you for your response. Actually, on the Mollie payment screen I did select Credit Card option and despite it's true that I didn't specify the payment method in my code, the subscription that were created successfully always returned payment method of creditcard, it never returned the directdebit. That's why it's quite puzzling why this error occurs. Or is there some mechanism that determines by amount which payment method will be used for a subscription? Like, if the payment is above 250.00, the system automatically decides to use directdebit and not previously used method of payment.

In my case, first payment CAN be lower than next payments because of discount my client will offer to her customers.

DePalmo commented 7 years ago

If we look at this page: https://www.mollie.com/en/docs/reference/subscriptions/create , under method option it says:

Optional – The payment method used for this subscription, either forced on creation or null if any of the customer's valid mandates may be used.

I always selected creditcard on payment screen, never selected directdebit and none of mandates returned till now showed a directdebit as active mandate.

And here are results from running a code that creates a subscription:

customer loaded from previous session ...
Array
(
    [resource] => customer
    [id] => cst_V9x2UcsgAH
    [mode] => test
    [name] => Test User
    [email] => errors@kotest.eu
    [locale] => 
    [metadata] => Array
        (
            [user_id] => 22224
        )

    [recentlyUsedMethods] => Array
        (
        )

    [createdDatetime] => 2016-12-03T09:23:03.0Z
)

loading first payment from previous session ...
Array
(
    [resource] => payment
    [id] => tr_dGUQt9Q5Sp
    [mode] => test
    [amount] => 150.00
    [amountRefunded] => 
    [amountRemaining] => 
    [description] => Subscription
    [method] => 
    [status] => open
    [expiryPeriod] => PT15M
    [createdDatetime] => 2016-12-03T09:23:04.0Z
    [paidDatetime] => 
    [cancelledDatetime] => 
    [expiredDatetime] => 
    [profileId] => pfl_Cz6e9MCWKS
    [customerId] => cst_V9x2UcsgAH
    [recurringType] => first
    [mandateId] => 
    [subscriptionId] => 
    [locale] => 
    [metadata] => Array
        (
            [user_id] => 20942
        )

    [details] => 
    [links] => Array
        (
            [paymentUrl] => https://www.mollie.com/payscreen/select-method/dGUQt9Q5Sp
            [webhookUrl] => http://site.expatfriendlylocals.com/paymentstest.php
            [redirectUrl] => http://www.localhost.local/ptest.php?id=1737
        )

)

get user mandates ...
Mollie_API_Object_List Object
(
    [totalCount] => 4
    [offset] => 0
    [count] => 4
    [data] => Array
        (
            [0] => stdClass Object
                (
                    [resource] => mandate
                    [id] => mdt_F63g9puCDv
                    [status] => valid
                    [method] => creditcard
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => HabNMUbFmtPNMhF4B9V4GDNM
                            [cardExpiryDate] => 2016-12-31
                        )

                    [customerId] => cst_AcNuDcQKb9
                    [createdDatetime] => 2016-12-03T09:14:41.0Z
                )

            [1] => stdClass Object
                (
                    [resource] => mandate
                    [id] => mdt_QWKkr7NxM6
                    [status] => valid
                    [method] => creditcard
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => WRbPCag7tMqckj9qdUuwzGWF
                            [cardExpiryDate] => 2016-12-31
                        )

                    [customerId] => cst_AcNuDcQKb9
                    [createdDatetime] => 2016-12-03T09:08:56.0Z
                )

            [2] => stdClass Object
                (
                    [resource] => mandate
                    [id] => mdt_j8Gurm2mSK
                    [status] => valid
                    [method] => creditcard
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => RHPm7746Ux5vCmAUj7CsFz3a
                            [cardExpiryDate] => 2016-12-31
                        )

                    [customerId] => cst_AcNuDcQKb9
                    [createdDatetime] => 2016-12-02T18:19:22.0Z
                )

            [3] => stdClass Object
                (
                    [resource] => mandate
                    [id] => mdt_RetPA8yr4D
                    [status] => valid
                    **[method] => creditcard**
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => WM5JAAsfE6PtmDD5njyQfwgM
                            [cardExpiryDate] => 2016-12-31
                        )

                    [customerId] => cst_AcNuDcQKb9
                    [createdDatetime] => 2016-11-29T03:40:29.0Z
                )

        )

    [storage:ArrayObject:private] => Array
        (
            [0] => Mollie_API_Object_Customer_Mandate Object
                (
                    [resource] => mandate
                    [id] => mdt_F63g9puCDv
                    [status] => valid
                    [method] => creditcard
                    [customerId] => cst_AcNuDcQKb9
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => HabNMUbFmtPNMhF4B9V4GDNM
                            [cardExpiryDate] => 2016-12-31
                        )

                    [createdDatetime] => 2016-12-03T09:14:41.0Z
                )

            [1] => Mollie_API_Object_Customer_Mandate Object
                (
                    [resource] => mandate
                    [id] => mdt_QWKkr7NxM6
                    [status] => valid
                    [method] => creditcard
                    [customerId] => cst_AcNuDcQKb9
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => WRbPCag7tMqckj9qdUuwzGWF
                            [cardExpiryDate] => 2016-12-31
                        )

                    [createdDatetime] => 2016-12-03T09:08:56.0Z
                )

            [2] => Mollie_API_Object_Customer_Mandate Object
                (
                    [resource] => mandate
                    [id] => mdt_j8Gurm2mSK
                    [status] => valid
                    [method] => creditcard
                    [customerId] => cst_AcNuDcQKb9
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => RHPm7746Ux5vCmAUj7CsFz3a
                            [cardExpiryDate] => 2016-12-31
                        )

                    [createdDatetime] => 2016-12-02T18:19:22.0Z
                )

            [3] => Mollie_API_Object_Customer_Mandate Object
                (
                    [resource] => mandate
                    [id] => mdt_RetPA8yr4D
                    [status] => valid
                    [method] => creditcard
                    [customerId] => cst_AcNuDcQKb9
                    [details] => stdClass Object
                        (
                            [cardHolder] => T. TEST
                            [cardNumber] => 6787
                            [cardLabel] => Mastercard
                            [cardFingerprint] => WM5JAAsfE6PtmDD5njyQfwgM
                            [cardExpiryDate] => 2016-12-31
                        )

                    [createdDatetime] => 2016-11-29T03:40:29.0Z
                )

        )

)

create new subscription ...
mandates found ...
mandate with active or pending status found, create subscription ...

Notice:  Payment gateway error: Error executing API call (request): The amount is higher than the maximum. in ...

So, the documentation specifies that if I do not force a method of payment, any active user's mandate will be used. The user's only active mandates are creditcard, but subscription with higher amount than 250.00 still won't be created. Since I do expect that test gateway should work as live one would, I do expect an issue on live gateway as well and I do expect from you:

christiancannata commented 7 years ago

I have the same problem! :( I receive "The amount is higher than the maximum." when I try to post a new subscription in test mode with an amount of 300€

DePalmo commented 7 years ago

I was in touch with their support team (info@mollie.com) and they have confirmed the bug and forwarded it to their development team, but it's not a high priority issue and they can't say when it will be solved.

I haven't yet tested if this is also an issue with live subscription. When I do, I will post an update here.

To Mollie: It's not a good policy to close the issue right after providing (an invalid and not related) answer to the issue reported ... Since this is an official API library, we would expect a more serious approach and prompt responses.

christiancannata commented 7 years ago

Thank you very much for the update! I hope they resolve this bug as soon as possible

ndijkstra commented 7 years ago

Hi! Our development team solved the problem. Can you test it again with an amount lower than €1000?

christiancannata commented 7 years ago

Perfect, thank you very much!

DePalmo commented 7 years ago

The subscription was successfully created with amount of 360.00 for creditcard payment method.

Thank you for solving this issue and reporting back to us!

willemstuursma commented 7 years ago

Thank you for bringing this to our attention.