Using Stripe and Paypal Integration in one Form

Home Forums Quform WordPress Using Stripe and Paypal Integration in one Form

This topic is: resolved
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #32008
    sven
    Participant

    Hey there,

    I want to use the stripe and paypal intergration in one form. I added a option field so customers can choose between stripe and paypal payment. If stripe is selected the credit card form shows up through the defined logic rule and hides the other way. But when the paypal option is selected the credit card form still gets validated so that the form don’t fires up the confirmation method with the custom url linking to paypal.

    How can I disable the validation for the credit card form, when the paypal option is selected.

    Thanks for your help.
    Best Sven

    #32016
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #32019
    sven
    Participant

    Hi Ally,

    thanks for your reply. I tried your solution but the stripe card form still gets validated and stops the confirmation for the paypal payment.

    The code looks like this:

    
    add_filter('quform_post_validate_8', function (array $result, Quform_Form $form) {
        
        if($form->getValue('quform_8_133') == 'PayPal') {
            return $result;
        }
    
        require_once 'vendor/autoload.php';
    
        if (!isset($_POST['stripeToken']) || ! Quform::isNonEmptyString($_POST['stripeToken'])) {
            $result = array(
                'type' => 'error',
                'error' => array(
                    'enabled' => true,
                    'title' => '',
                    'content' => 'Bitte trage Deine Kreditkarteninformationen ein.'
                )
            );
    
            // No JS response
            $form->setConfig(array(
                'errorEnabled' => true,
                'errorTitle' => '',
                'errorContent' => 'Bitte aktiviere JavaScript und trage Deine Kreditkarteninformationen ein.'
            ));
    
            return $result;
        }
    
        \Stripe\Stripe::setApiKey('sk_test_xxxx');
    
        try {
            \Stripe\Charge::create([
                'amount' => 14964,
                'currency' => 'eur',
                'description' => 'wertvoll. Marken-Toolkit',
                'source' => $_POST['stripeToken'],
                'metadata' => [
                    'customer_email' => $form->getValueText('quform_8_124')
                ]
            ]);
        } catch (Exception $e) {
            $result = array(
                'type' => 'error',
                'error' => array(
                    'enabled' => true,
                    'title' => '',
                    'content' => $e->getMessage()
                )
            );
        }
    
        return $result;
    }, 10, 2);
    

    Did I something wrong.
    Thanks for your help. Best, Sven

    • This reply was modified 2 weeks, 3 days ago by sven.
    #32026
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #32033
    sven
    Participant

    Hi Ally,

    I’ve sended you the link via mail. Did you get it?

    Best, Sven

    #32035
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #32037
    sven
    Participant

    This solutions works.
    Thanks for your great support.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2020 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy