This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 4

Stripe Variable Payment Discount not rounding - Bug?


  1. timcov
    Member

    My first time creating a payments form having signed up with Stripe. All good except when testing variable discount I often get a failure message such as "Invalid Integer - 13495.25". Pretty sure the "error" is caused by Machform not rounding either the discount or the total amount (which in this case should be £134.95 being £149.95 -25%discount +20% tax = £134.95 showing on the payment screen but £134.9525 unrounded.

    Assuming I've assessed my issue correctly - can you suggest where I can tweak the php code to round the discount (or the total) to 2 decimal places?

    Fantastic product and also thank you for the recommendation of Stripe by the way (great to have a streamlined alternative to Paypal).

    Many Thanks,

    Posted 9 years ago #
  2. yuniar

    What is your exact MachForm version? There was some bug previously with older v4.x I think, related with this one.


    MachForm Founder

    Posted 9 years ago #
  3. timcov
    Member

    Hi, My problem is with v4.4 - I just upgraded from v4.2 but never used payments until now after upgrading. It isn't a new install though - so the mysql database is an upgrade from 4.2.

    Posted 9 years ago #
  4. timcov
    Member

    I think I have found this glitch and does I think currently affect the v4.4 I downloaded earlier this week:
    In payment_submit_stripe.php on line 160: $payment_calculated_discount = round($payment_calculated_discount,2); //round to 2 digits decimal
    This I think should be changed to: $payment_calculated_discount = round($payment_calculated_discount,0); //round to 0 digits decimal

    This is because $payment_calculated_discount and $charge_amount are already valued in cents not dollars. Making that change seems to have eliminated the errors I was getting.

    Posted 9 years ago #
  5. yuniar

    Ahh.. you're right. This seems to be a new bug and what you did to fix it is correct. Thanks for letting us know! I'll update our code.


    MachForm Founder

    Posted 9 years ago #

RSS feed for this topic

Reply