Home › Forums › Quform WordPress › Using Stripe and Paypal Integration in one Form › Reply To: Using Stripe and Paypal Integration in one Form
October 2, 2020 at 4:42 pm #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 3 years, 5 months ago by sven.