Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Woocommerce function is called on PayPal IPN response?

I'm having a problem figuring out what function gets called when a payment is completed with Woocommerce and PayPal sends the IPN.

The IPN is being received because PayPal log file is being updated as soon as I click Pay, but I can't figure out what function is writing to that file.

I need to figure out if there is already a built in functionality to send emails to the admin when an order is created, and where this happens.

If it does exist I need to modify it to email other people too, and if not then I need to create it myself, but I need to know where to put the code.

like image 430
Brian Avatar asked Oct 19 '12 04:10

Brian


People also ask

How does PayPal work with WooCommerce?

From the Cart page customer selects “Checkout with PayPal” button. The customer is redirected to PayPal, and WooCommerce sends the order subtotal, customer information, and shipping address to PayPal (Customers can enter a new shipping address).

How do I check my WooCommerce checkout on PayPal?

On your WordPress dashboard, hover over WooCommerce and click 'Settings' Next, click the 'Payments' tab and then click 'Manage' in the PayPal Standard row. Then, check 'Enable PayPal Standard for Subscriptions' Finally, scroll to the bottom of the and click 'Save changes'

Does WooCommerce require PayPal identity token?

The PayPal identity token is essential for verifying payments without using PayPal's Instant Payment Notification (IPN). The token allows your customers to track their payment process in a secure channel.


1 Answers

Checking the file /wp-content/plugins/woocommerce/classes/gateways/paypal/class-wc-paypal.php, we see that there's an action hook inside the function check_ipn_response:

if ($this->check_ipn_request_is_valid()) :

    header('HTTP/1.1 200 OK');

    do_action("valid-paypal-standard-ipn-request", $_POST);

You can hook into it like this:

add_action( 'valid-paypal-standard-ipn-request', 'so_12967331_ipn_response', 10, 1 );

function so_12967331_ipn_response( $formdata )
{
    // do your stuff
}
like image 60
brasofilo Avatar answered Nov 05 '22 05:11

brasofilo