I'm trying to write a WooCommerce plugin for a client's website that they're going to be selling subscriptions to customers. I've been exploring my options and the best one I can come up with is to roll my own payment gateway module to handle this. (Other advice appreciated if anyone's ever tackled something like this).

However, I'm trying to add a custom payment gateway, but it doesn't seem to be working up. It's not showing up under WooCommerce -> Settings -> Payment Gateways. The plugin is installed and activated in WordPress, and I've followed a couple guides from their docs pages.

  • WooCommerce version: 2.0.18 (via plugin installer)
  • gist code

I really don't know why or what would cause my payment gateway isn't showing up.

Thanks for the future help.

  • Did you implement woocommerce_payment_gateways filter? Is your class' PHP file loaded, or autoloaded? Have you looked at your error log to see if anything is being logged? – webaware Oct 30 '13 at 1:25
  • The gist link shows that I have used woocommerce_payment_gateways filter. The php file is loaded manually from in the plugin file. I'm unsure how to even use autoloading in PHP. I'll take a look at the error log when I get home today. – Zack Oct 30 '13 at 16:33
  • On a side note, I also found "WooSponsorship" plugin linked on this site and downloaded it from github and it's stripe gateway doesn't even load the gateway. :/ – Zack Oct 30 '13 at 17:04

Right, so the gist is your code; from your description I thought it was someone else's code you read for inspiration.

Your woostripe.php file, which loads your gateway class, bails out before loading the gateway class:

// bail on constructor if gateway class isn't loaded!
if (!class_exists('WooStripe_Gateway')) return;
// ...  
// why are you attempting to load WooCommerce's classes? Don't!
include_once(dirname(plugin_basename('woocommerce.php')) . 'classese/abstracts/abstract-wc-payment-gateway.php');
// never gets here to load this class, you've already left this function...
include_once(dirname(plugin_basename(__FILE__)) . 'classes/WooStripe_Gateway.php');

Remove the include statement for WooCommerce's class, that's WooCommerce's job not yours. Then move your WooStripe_Gateway include to the top of woocommerce_gateway_init() before the test to see if it exists. That class cannot exist until it is loaded.

  • A note, thanks for the help. I ended up going with the easier, albeit more expensive option due to time constraints. Thanks though! – Zack Oct 31 '13 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.