studioespresso / craft-mollie-payments

Easily accept online payments on your Craft website through Mollie
Other
1 stars 4 forks source link

MySQL error when filling in a amount with a comma instead of a dot #69

Open arifje opened 2 months ago

arifje commented 2 months ago

Screenshot 2024-06-24 at 12 48 28

This is the result when submitting an amount like: 10,10

janhenckens commented 2 months ago

Which version of Craft and of the plugin are you running @arifje? And could you share the part of the form where you are setting the amount?

arifje commented 2 months ago

Running Craft Pro 4.9.7

I used the default donate form from your examples, with some small changes;

<form method="post" class="uk-form-stacked">

    {{ csrfInput() }}
    {{ actionInput("mollie-payments/payment/donate") }}
    {{ redirectInput("/doneren") }}

    <input type="hidden" name="form" value="{{ 'formHandle'|hash }}">

    <div class="uk-margin">
        <div class="uk-form-controls">
            <label>Aantal eurootjes</label>
            <input class="uk-input" type="text" id="amount" name="amount" type="number" pattern="^\d+(\.\d+)?$" required>
        </div>
    </div>
    <div class="uk-margin">
        <div class="uk-form-controls">
            <input class="uk-input" type="email" id="email" name="email" placeholder="Emailadres" value="{{ (currentUser) ? currentUser.email : '' }}" required>
        </div>
    </div>
    <div class="uk-margin">
        <div uk-grid>
            <div class="uk-width-1-2@s">
                <div class="uk-form-controls">
                    <input class="uk-input" type="text" id="firstName" placeholder="Voornaam" name="fields[firstName]" value="{{ (currentUser and currentUser.firstName) ? currentUser.firstName : '' }}" required>
                </div>
            </div>
            <div class="uk-width-1-2@s uk-padding-left-small">
                <div class="uk-form-controls">
                    <input class="uk-input" type="text" id="lastName" placeholder="Achternaam" name="fields[lastName]" value="{{ (currentUser and currentUser.lastName) ? currentUser.lastName : '' }}" required>
                </div>
            </div>
        </div>
    </div>
    <div class="uk-margin">
        <div class="uk-form-controls">
            <textarea class="uk-textarea" name="description" placeholder="Opmerking (optioneel)"></textarea>
        </div>
    </div>

    <div class="uk-margin uk-text-right">
        <input type="submit" class="uk-button uk-button-primary" value="Doneren">
    </div>
</form>

Note: I added the type="number" pattern="^\d+(.\d+)?$" attributes later to prevent filling in comma seperated values.

janhenckens commented 2 months ago

Ha, you have a number input for the amount - then I think the "pattern" fix you have in place is the best way to fix this. We usually make the amount field a dropdown or a radio button, so we can hint certain (preferred) amounts.