Okay, I've come up with a couple possible solutions.
DEALING WITH PAYMENT VERIFICATION
WooCommerce's Paypal Standard gateway actually has support for Paypal's IPN service built right in to it. You'll want to use that regardless of the 'hook' route you choose.
HOW TO SET UP PAYPAL IPN
Paypal IPN is connected to whichever account is the receiver of the money. For example, if you're getting paid at myemail@gmail.com, then you need to set up IPN with that account. All IPN is, is Paypal sending out a "Payment Complete!" (of sorts) notification to the URL of your choice. In order to choose the url that you want Paypal to send the notice to, you need to do these steps:
- Log in to Paypal
- Click on the little face icon on the top right
- Click "Profile and settings"
- Click "My selling tools" in the left sidebar
- Find "Instant payment notifications" and click "Update"
- Enable them and set the url. Your WooCommerce Paypal Payments Standard gateway url is: http://yoursite.com/?wc-api=WC_Gateway_Paypal (which is noted in WooCommerce's Paypal Standard documentation).
- Save your settings
Your WooCommerce installation will now hear from Paypal when the payment is complete. Oh, and by the way, make sure that:
- Your "Receiver E-mail" in your Paypal settings is correct
- fsockopen is enabled on your server (you can check this "System Status" in your WooCommerce settings)
NOW LET'S GET TO WORK ON THE HOOKS
OPTION 1: Auto-complete orders that have completed payment and hook in to woocommerce_order_status_completed
for your special actions/functions
In order to get your products to auto-complete upon verified payment, you can simply install Mirko Grewing's fabulous WooCommerce Autocomplete Order plugin. Be sure to set the correct settings (which will appear under the "Woo Extra Options" tab in your WooCommerce settings).
Now that your orders are being autocompleted when the payments are verified, you can simply hook in to your completion hook, `woocommerce_order_status_completed, for your special functionality.
The benefit to that method is that if allows you to hook in any order that is completed--regardless of whether or not you manually completed it or it was automatically completed. In other words, it's pretty versatile.
OPTION 2: Hook in to the woocommerce_payment_complete_order_status
filter, which denotes a successful payment.
I guess that one is pretty self-explanatory. The benefit to this method is that it's pretty much the first step in the whole process, and takes place prior to the completion hook above (if you have your priorities set appropriately).
I don't know if one is better than the other, but they both seem to accomplish my goal: perform an action AFTER payment has been verified.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…