• Hi,

    we have an extra validation in place on the hook woocommerce_checkout_process to check that the address is not a po box. For Stripe, Klarna and Swish it works and stops the Klarna and Swish windows from opening and shows a notice but when choosing PayPal it opens the PayPal window without giving the notice?

Viewing 1 replies (of 1 total)
  • Plugin Author Payment Plugins

    (@mrclayton)

    Hi @fredrikvestin

    but when choosing PayPal it opens the PayPal window without giving the notice?

    That is because the PayPal plugin and integration is different and not comparable to how Stripe works. When you click the PayPal payment button, the checkout form isn’t being submitted yet. The checkout form is only submitted after the customer completes the payment in the PayPal popup window. You have two approaches you can take for this:

    1. On the PayPal Settings page you can enable the option Use Place Order Button. When enabled, the plugin uses the Place Order button, rather than rendering separate PayPal payment buttons. That will trigger your custom validation because the WooCommerce Checkout validations are triggered, and then the customer is redirected to PayPal.
    2. You can continue to use the PayPal buttons on your checkout page, and implement action wc_ppcp_checkout_validation. That action allows you to perform validations when using the PayPal payment buttons. Make sure you have the option Validate Checkout Fields enabled via the Advanced Settings page. Here is an example of how to use this action:
    add_filter('wc_ppcp_checkout_validation', function($validator, $request){
        if(!$request->get_param('custom_field')){
            $validator->add_error('Custom field is required to proceed');
        }
    }, 10, 2);

    Kind Regards

Viewing 1 replies (of 1 total)
  • The topic ‘Field validation prior to opening Paypal window’ is closed to new replies.