Update (6/5/2015): We’ve published a documentation page for adding a new gateway option. See: Adding a New Gateway

One of our goals for PMPro v1.8 is to be able to add new payment gateways to PMPro without having to edit any core PMPro files. To this end, we’ve added a ton of new hooks to the payment settings admin page, the checkout page, and checkout preheader code. We’ve overhauled the existing gateways to use the new methods and hooks so that nearly all of the custom code for each gateway is now contained with the gateway classes.

If you are developing a new gateway, you will want to grab the latest version of v2.0 from GitHub upgrade to the latest version of Paid Memberships Pro in the WordPress repository and then develop your gateway on top of that version. We will have more thorough documentation when we can, but the basics of adding a gateway now are:

1. Create a custom plugin to house your gateway code.

2. Create a class for your gateway PMProGateway_gatewayname that extends the PMProGateway class. (The Stripe gateway class is a good one to use for reference.)

3. Override the class methods to use your gateway specific APIs.
Because this is all still in development, there may be bugs with this gateway code or other parts of PMPro. And there are likely to be updates to the PMPro plugin that might affect your custom gateway. Stay tuned to the blog here. At some point, we will announce an official “beta” period for v2.0 where we will be adding no new features and only fixing bugs with it.

Here are some of the new and old hooks and filters that you should consider using to integrate your gateway into the front and backend of PMPro.

  • pmpro_gateways – Filter to add your gateway to the list of gateway options.
  • getGatewayOptions – Which option names/keys, including new ones you are adding, should be loaded on the payment settings page.
  • pmpro_payment_options – Save new options you add to the payment settings page.
  • pmpro_payment_option_fields – Code to add fields to the payment options page.
  • pmpro_checkout_preheader – Run code within preheaders/checkout.php.
  • pmpro_checkout_order – Filter the order object to adjust or add properties to it before sending it to the process method of your gateway class.
  • pmpro_include_billing_address_fields – Set to __return_false to not include billing address fields at checkout. Can also use the filter to swap in your own version of the billing address code.
  • pmpro_show_billing_address_fields – Set to __return_false to include the HTML for the billing address fields but use CSS to hide it from display.
  • pmpro_include_payment_information_fields – Set to __return_false to not include payment information fields at checkout. Can also use the filter to swap in your own version of the payment info code.
  • pmpro_show_payment_information_fields – Set to __return_false to include the HTML for the payment information fields but use CSS to hide it from display.
  • pmpro_required_billing_fields – Filter which fields are required at checkout.
  • pmpro_registration_checks – Use this to check extra fields added to the checkout.
  • pmpro_checkout_before_processing – Called just before calling the process method of the gateway.
  • pmpro_checkout_confirmed – Used by the PayPal Express gateway to handle it’s own token/review/confirm process.
  • pmpro_checkout_before_change_membership_level – Called just before changing the user’s membership level during checkout.
  • pmpro_after_checkout – Do stuff after checkout is processed.

Again, v2.0 is still in very active development. These hooks may change and are not documented well yet if at all.

These updates are live as of version 1.8. If you have any questions or notice any bugs, please post to our member forums or open an issue at GitHub. Thanks!


This entry was posted in About PMPro and tagged . Bookmark the permalink. Last updated:

Comments (28)

Author’s gravatar

Does this developer version include the ability to have multiple subscriptions? Also does 2.0 break compatibility with the older PMPro Register Helper Plugin? I’ve been building out my own plugins for PMPro and I would like to test them to make sure they still work with 2.0.

Cheers for all the updates btw 🙂 Really helps keep track of how things are changing!

Reply
Author’s gravatar

The multiple membership support is not in 2.0 yet. But will be soon. I’ll post here when it is.

It will be compatible with PMPro Register Helper. In general, support for many addons may break at various points in testing/developing 2.0 but we plan to have them all working (or with graceful notices that they don’t work when applicable) before the official launch.

Reply
Author’s gravatar

I haven’t done other that install and test out the plugin, so maybe this is already supported.

However will it be possible to “redirect” to a payment gateway and thus avoid the whole SSL and PCI compliance on your own site?

Here in Denmark almost no companies take credit cards directly on their site (like integrate it directly with an alternative to Stripe that is not available in most of Europe), but instead use the hosted payment form on the gateway’s secure server.

Is this scenario supported in your plugin / new plugin architecture?

Reply
Author’s gravatar

Short answer is yes. The Stripe and Braintree gateways work this way, but they require/suggest having an SSL anyway. The PayPal Express and Standard gateways link out to PayPal to pay/etc avoiding SSL issues.

In general, this will make integrating with other gateways easier to do. Both because no edits are needed to the core PMPro plugin when doing so, but also because you’ll be able to create a partial gateway integration (that only does one time payments for example) and use that in your own plugin. In the past, we avoided certain gateways because adding support for recurring payments/syncing is 10x as much work as doing one time payments. We didn’t want to add them to the “official list” of gateways unless they were fully supported. However, now you can use your own plugin that isn’t fully supported/etc.

Reply
Author’s gravatar

So does this mean that there is some version of pmpro V2 out there to work with?

Thanks

Reply
Author’s gravatar

This will be a welcome development. I’ve always looked for a way to integrate my local payment processor with PMpro. I love this

Reply
Author’s gravatar

Excellent, this is exactly what I’m looking for. When do you envisage V2.0 will be released?

Reply
Author’s gravatar

I’m no longer giving estimates, sorry. It’s just a lot of work and the kind of thing that is getting bigger and bigger as we dig into it. As soon as I can.

Reply
Author’s gravatar

p.s. If v2.0 gets delayed too long, I might release an interim version with the gateway updates sometime next month. You are also free to use the v2.0 dev at your own risk on your site.

Reply
Author’s gravatar

Hi Jason, I don’t fully understand how this works.

If I add a new class in the gateways folder – nothing changes.
If I delete something from the gateways folder – all default gateways are still in the list.

A custom gateway that I need to integrate is fairly simple, all I need is:
1) redirect to the gateway page
2) have a successful payment page (redirected from the gateway)
3) have an error page (redirected from the gateway)
4) callback page that is only seen by the server and processes the payment

How do I do this with your current version? When should we expect the Beta V2.0 and more documentation?

Thanks.

Reply
Author’s gravatar

PMPro doesn’t auto-detect the gateway classes in that folder. If you are adding a gateway, you should program it as a separate custom plugin and include the class file.

RE coding the class itself, find the gateway class most like it and tweak it to use the new API. It’s not necessarily easy.

I’m not sharing timelines on v2.0 really (because I’m not able to accurately estimate when it will be ready) but as soon as it’s out, we’re going to code Bitcoin gateways and when I do that I’ll write up docs on creating gateways in general. It’s going to be a while.

Reply
Author’s gravatar

Couldn’t figure out a way to create my plugin, so I just added an extra line in paid-memberships-pro.php. Also, twocheckouts class seemed to be very similar to what I need and it works like a charm.

I look forward to 2.0 release, but the development version seems to have everything I need, thanks a lot.

Author’s gravatar

Oh I’m sorry, you probably meant the wordpress plugin, for some reason I was searching for how to create a Paid Memberships Add On (admin.php?page=pmpro-addons). Never mind then, everything works now 🙂

Reply
Author’s gravatar

One small remark:

‘pmpro_gateways’ filter has no effect when it is inside the ‘PMProGateway’ extended class. Custom gateway option only appears if you move the filter out of the class, near the ‘init’,

e.g.:

add_action(‘init’, array(‘PMProGateway_twocheckout’, ‘init’));
add_filter(‘pmpro_gateways’, array(‘PMProGateway_twocheckout’, ‘pmpro_gateways’));

class PMProGateway_Twocheckout extends PMProGateway
{
function PMProGateway_Twocheckout($gateway = NULL)
{
………..
………..

Reply
Author’s gravatar

Another small bug:

If I have my custom gateway class in a separate file, classes\class.memberorder.php line 128 still tries to insert my class file from the gateways folder, even though the file doesn’t exist and the class is already defined elsewhere. Adding a “file_exists” condition fixes it and the checkout works fine.

Reply
Author’s gravatar

How to integrate more simple and advanced gateway like Liqpay: https://www.liqpay.com/en/doc#liq_buy it has just html code for shop button. What can you advise to intergrate into PMPro instead PayPal?

Reply
Author’s gravatar

We don’t generally integrate via “buttons” code. The process for integration would be the same, all though it is much easier if you don’t worry about recurring payments and syncing subscriptions.

Reply
Author’s gravatar

Hi Jason,

Are there any status to the gateway thing?

Reply
Author’s gravatar

The v2 beta on GitHub has all of the gateway updates (minus some stuff we’re doing with the Stripe gateway). We won’t have time to work on the docs until after the other parts of v2.0 are out, but I can answer any specific questions in the forums.

Reply
Author’s gravatar

hi, I’m curious if you could maybe short term integrate the following easy options into your great plugin so it’s more attractive for a larger user-base also;

– more flexible payment API gateway support. (e.g. to include other bitcoin gateways like coinbase etc. The current bitcoin gateway, only available through Stripe is simply too limited.

– offer better documentated support for other payment API gateways, like the verotel flexpay API gateway

– an extension for your great membership plugin, so it can also work with other active woocommerce payment-gateways? At the moment your plugin itself has too limited payment gateway options. Anticipating the online trends of new private currencies and the many woocommerce extensions available, my own client is already using Coinbase (bitcoin) and other payment gateways and she would like to be able to use her current woocmmerce gateways in combination with your membership plugin.

– If above – is not possible, could you consider linking it to woocommerce order receipts/unique email id’s, so people can buy memberships (day,week,month) and use their emailID/orderID to login with your membershipplugin into private member section? All payment gateways of your plugin can be disabled – and re-routed to woocommerce then.

I’ve been researching quite some time online, and many people are looking into this matter, would be great if you could facilitate this need.

Thanks a lot in advance! And good luck with the plugin! 😉

Reply
Author’s gravatar

Our v1.8 has a better API for new gateways (basically everything can be done in a plugin vs having to update the core for new gateways). Once that is out, I plan to generate the documentation the first time I go through adding a new gateway.

RE WooCommerce, look for the PMPro WooCommerce plugin.

Reply
Author’s gravatar

Hi, I am trying to integrate a new payment gateway into PMPro. However, it is still not successful after reading the above information. I am just wondering when will the gateway documentation you mentioned in the last message available?

Thank you!!

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *