Support » Plugin: Pronamic Pay » Prevent payment redirect gravityforms

  • Resolved Anonymous User 17646384

    (@anonymized-17646384)


    Hey,

    Is there a way to prevent the payment redirect from happening through a wp hook?

    For example:
    prevent the redirect if field 2 has value ‘hello’ in gform_confirmation hook or any other hook?

    
    add_filter( 'gform_confirmation', 'block_redirect', 10, 4);
    function block_redirect( $confirmation, $form, $entry ) {
        if( $form['id'] == 1 && rgar($entry, '48') == 'pin-betaald' || rgar($entry, '48') == 'achteraf') {
    		//TBD prevent payment redirect
        } 
        return $confirmation;
    }
    
Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Reüel van der Steege

    (@pronamic_reuel)

    I’m not sure why you would want to prevent the redirect, payments usually have a limited time after which they will expire automatically. Starting a payment, but not redirecting to let the customer complete the payment doesn’t seem logical (or are you somehow going to redirect the customer after the confirmation text is shown?).

    Aside of that, our confirmation hooks into gform_confirmation with priority 10. If you use a higher priority (e.g. “11”) you should be able to override the confirmation. See the Gravity Forms docs at https://docs.gravityforms.com/gform_confirmation/ for further details.

    Anonymous User 17646384

    (@anonymized-17646384)

    Thanks for your response.

    We have a field in the form that is only shown for admin users. This field has a checkbox which should skip the payment and directly go to a ‘thank you page'(anything but the payment page) because the payment is done in real life. (does not matter if payment was successful or not in the gf entry)

    Changing priority of the gform_confirmation hook would skip the payment in all cases. But we want a sort of exception in the hook itself. (as in the code sample I provided)

    I hope you understand what I am trying to do.

    Plugin Author Reüel van der Steege

    (@pronamic_reuel)

    If it’s just one checkbox, I’d suggest to set the condition for that field on the Advanced tab in the payment feed settings of the form.

    Anonymous User 17646384

    (@anonymized-17646384)

    This is an almost working solution.
    But it is actually a radio button with multiple options. My mistake for saying it was a checkbox.

    So I need 2 condition:
    ‘field’ > ‘is not’ > ‘value1 to skip payment’
    OR
    ‘field’ > ‘is not’ > ‘value2 to skip payment’

    But I am only able to add 1 condition through the Advanced tab.

    • This reply was modified 1 year ago by Anonymous User 17646384.
    Plugin Author Reüel van der Steege

    (@pronamic_reuel)

    There’s no option 3 by chance which you can use in the condition to only process the feed if that option has been chosen? (instead of the other way around) Maybe with multiple similar feeds?

    Also, another suggestion (I’m not sure if it suits your case) would be to only show the product field if you want to process the payment. If the total amount of the form entry is 0, it won’t get processed by our plugin too.

    Anonymous User 17646384

    (@anonymized-17646384)

    There isn’t a third option, but I just added a third option which is ‘default’.

    This solved the issue, thank you 🙂

    Anonymous User 17646384

    (@anonymized-17646384)

    One more problem I found after testing.

    When enabling the condition it skips the payment page as expected, but It redirects me to the ‘payment error’ page. But in this case it isn’t an error.

    Is there a way to go to a different page for conditions?

    Anonymous User 17646384

    (@anonymized-17646384)

    ^ Anyone able to help me with this?

    Plugin Author Reüel van der Steege

    (@pronamic_reuel)

    Has this payment error page been set as the default confirmation in the settings of the form (Forms » [ Choose form ] » Settings » Confirmations)?

    If there’s no payment started after submitting an entry (see WordPress admin » Pay » Payments), our plugin won’t redirect to a payment error page.

    Anonymous User 17646384

    (@anonymized-17646384)

    There indeed was no payment started so your plugin did not make the redirect.
    it was the condition i put on the error message which was wrong

    Plugin Author Reüel van der Steege

    (@pronamic_reuel)

    Thank you for your update. Glad the issue has been resolved.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Prevent payment redirect gravityforms’ is closed to new replies.