1
votes

I need add PayPal IPN on my site in a specific contact form. I have integrate the funcions for IPN (listener and other) but I don't known how to invoke the Paypal from the CF7" and send the email only AFTER the payment confirm.

I think I have to use the wpcf7_before_send_mail function, but I don't know how. I add this simple wpcf7_before_send_mail function in my functions.php


    add_action("wpcf7_before_send_mail", "wpcf7_do_something_else");  

    function wpcf7_do_something_else($cf7) {
        // get the contact form object
        $wpcf = WPCF7_ContactForm::get_current();

           $form_id = $contact_form->posted_data['_wpcf7'];
           if ($form_id == 2969) {
               if (/*Check if payment in the PayPal it's ok */) {
                  //Send mail and thank you page
               } else {
                  $wpcf->skip_mail = true;    
               }
          }
        return $wpcf;
    }

But I don't known to check the IPN (i think first I have redirect to paypal url and after i need listen the paypal response).

Also, i have insert in fuction only the $wpcf->skip_mail = true; but the mail but the email is sent however.

Can you help me?

Regards, Marco

1

1 Answers

0
votes

If this is a form post that then redirects the user to a PayPal Payments Standard checkout, there will be no completed payment until later (and some portion of payments will go unpaid), so you will not be able to check for payment at the time the form is posted. That comes later.

The variable notify_url to be specified for IPN is documented here.