Gateway Code is messy
-
Hi Patterson,
I’ve looked into the code, because one thing didn’t worked for me.
For example: If I turn on Paypal in the contact form and use a selection where paypal, stripe and transaction are inserted, choose transaction and on submit I will be redirected to Paypal. There shouldn’t be any redirection at this point.
This behaviour is mainly based on two things:
1.
cf7pp_before_send_mail in redirect_methods.php: Somewhere around line 150if ($enable == '1') { $gateway = 'paypal'; } if ($enable_stripe == '1') { $gateway = 'stripe'; } if ($enable == '1' && $enable_stripe == '1') { $gateway = $posted_data[$gateway_orig][0]; }The gateway check is not well here.
You don’t check against $posted_data, if only one payment is active. You need to check against it always.Something like this would fix the failure:
$gateway_data = strtolower(get_post_meta($post_id, "_cf7pp_gateway", true)); $gateway = ''; $gw = strtolower($posted_data[$gateway_data][0]); if ( ($enable_paypal == '1' && $gw == 'paypal') || ($enable_stripe == '1' && $gw == 'stripe') ){ $gateway = $gw; }2.
Based on the fix in redirect_methods.php we have this code-snippet here:
assets/js/redirect_method.js: Around Line 91// gateway chooser if (cf7pp_gateway != null)The redirection will be done, more or less regardless of the gateway.
The else-tree needs to terminate the action, because the posted gateway leads not to any gateway. On the other hand, if so, use the normal if-tree statements.Best regards,
Mike
The topic ‘Gateway Code is messy’ is closed to new replies.