• Resolved betyonfire

    (@betyonfire)


    I am using Contact Form 7 with the Stripe Integration to collection donations on a website and things have been working well. But we just had a donor enter a large donation and they used a comma in the amount field (1,000). For some reason, this came through fine in the receipt, but translated in Stripe to 1.00. Is there a workaround for something like this or a way to prevent users from entering commas in the field?

    Thanks for any tips on working this out. Definitely don’t want to discourage large donations!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi, betyonfire, I’m another CF7 user.

    You could try using some custom validation on the amount field (in conjunction with the strpos function):
    https://contactform7.com/2015/03/28/custom-validation/

    Thread Starter betyonfire

    (@betyonfire)

    Thanks for the tip @plantprogrammer. I was able to block commas with this code:

    // No commas allowed in the amount field
    add_filter('wpcf7_validate_text*', 'custom_text_validation_filter', 10, 2);
    
    function custom_text_validation_filter($result, $tag) {  
        $type = $tag['type'];
        $name = $tag['name'];
        if($name == 'your-amount') {
        $value = $_POST[$name];
        $Match_all = "/([\,])/";
        if(preg_match($Match_all,$value)){
    
            $result->invalidate( $tag, "Please remove any commas from your amount field!" );
                        }
        }
        return $result;
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with Stripe Integration and commas’ is closed to new replies.