• Resolved wibergsweb

    (@wibergsweb)


    Hi

    I want to get a response from server when clicking on the submit-button (in the donation frontend form).

    I’m able to use filter give_donation_form_required_fields to do this. Doing this way using a modal form allows the error to be shown directly under the submit-button in the donation form. If I do an set_error() in the give_gateway_[gateway] – action then the page is reloaded and the error is not shown in the modal form.

    When using give_donation_form_required_fields I can only test certain things on the external server. What I want to is to test an actual payment to the external gateway server and get a response that is output on the modal form if an error occurs. This requires the page not be reloaded, but it is reloaded when processing the actual payment.

    Do I need ajax doing this? Or are there any “prepayment” filter or so? (I need the purchase data to do the actual testing to the external server)

    • This topic was modified 1 year, 9 months ago by wibergsweb.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Ravinder Kumar

    (@ravinderk)

    @wibergsweb Give ajax uses to validate field values.

    for example:
    1. validate gateway
    2. validate amount
    3. spam detection
    3. etc.

    if you are using give_gateway_[gateway] then I will suggest you do not use set_error() fn instead use give_send_back_to_checkout with extra param and hook pre donation form filter to show your error.

    
    code 1:
    if( $error){
        give_send_back_to_checkout(
                'card_decline' => $payment_gateway_response
                 // add your custom error here
                 // use unique query param to prevent future conflict
        )
    }
    
    code 2:
    // pre form hook to show errors
    function xyz_render_errors( $form_id ){}
    add_action( 'give_pre_form', 'xyz_render_errors', 10, 1 );
    

    Aha. That was a good solution!give_pre_form! Thanks a lot!

    Plugin Author Matt Cromwell

    (@webdevmattcrom)

    Glad to hear we were able to help you sort this out. What are you building out exactly? Is it a third-party integration? Would love to hear what your use-case is.

    I’m building a plugin for a specific customer that is a startup-company. The company are going to offer swish as payment and I got the honor to do this. The customers business idea is about making donations to save the world 🙂 (basically)

    • This reply was modified 1 year, 9 months ago by wibergsweb.
    Plugin Author Matt Cromwell

    (@webdevmattcrom)

    Sounds awesome!

    Keep us updated on your organization’s success. Consider telling us all about it in one of these ways:

    • Let us know via Twitter or Facebook, we always share our users’ success on social when we hear about it

    Best of luck in all you, and we hope to hear from you soon!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Ajax needed?’ is closed to new replies.