woocommerce woocommerce_payment_complete is not working, please help.


#1

I am using paypal sandbox mode for testing payments. and this hook woocommerce_payment_complete after payement returning to website. It doesnot fire the function.

add_action( 'woocommerce_payment_complete', 'payment_complete_func' );

function payment_complete_func(){

	file_get_contents("http://localhost/wordpress/test.php?i
d=paymentagain2");
}

#2

please help


#3

winner of this weeks div buster title thread.

can you not use curl


#4

@yourkishore, Couldn’t help but notice your URL. Your on localhost, hence Paypal IPN ( instant payment notification) will not work for you.

You are required to provide a URL that can be accessed from the outside (outside your localhost), one that Paypal can reach ( from their servers). How are you expecting Paypal to send you a notification with just a localhost address ? Hence why you end up not getting a notification at all :stuck_out_tongue:


#5

i am using file_get_contnets just for testing the function, the actual code is different. to ust test wheather its working or not.


#6
Typps said

@yourkishore, Couldn’t help but notice your URL. Your on localhost, hence Paypal IPN ( instant payment notification) will not work for you.

You are required to provide a URL that can be accessed from the outside (outside your localhost), one that Paypal can reach ( from their servers). How are you expecting Paypal to send you a notification with just a localhost address ? Hence why you end up not getting a notification at all :stuck_out_tongue:

Thanks for the reply, the local host file is nothing to do with paypal. I just wantted to fire that function and check its working or not the local host link is connected to my local database.


#7

OK, but do verify that in your actual code, the notify URL provided is not a localhost address. If you have provided a public URL, then I’m out of ideas :slight_smile:


#8

By the way, if it is not clear, at some point somewhere you’ve specified the notify URL, this is the URL that Paypal will hit to send you a notification.

For the record, my response has got nothing to do with the URL you’ve used in file_get_contents, but it did help to see that your testing in localhost ( the root of your problem).


#9
Typps said

By the way, if it is not clear, at some point somewhere you’ve specified the notify URL, this is the URL that Paypal will hit to send you a notification.

For the record, my response has got nothing to do with the URL you’ve used in file_get_contents, but it did help to see that your testing in localhost ( the root of your problem).

Yeah, thats what i think. The localhost may be the problem. I will test it in a live wordpress environment and will let you know the result :slight_smile: Thansk for the reply.