This plugin is an example of a working LifterLMS Payment Gateway integration.
The source of this plugin can be used to learn how a LifterLMS payment gateway is intended to work.
This is a WordPress plugin which can be cloned or downloaded and installed as a WordPress plugin. It requires LifterLMS to function.
- Visit the gateway's settings at LifterLMS -> Checkout -> Sample Gateway to enable and configure it
- Add
SECRET
for the TEST and LIVE API Key options to make checkout "work". - Use any other API key (or leave it blank) to see the gateway error.
- For success at checkout use credit card number
4242424242424242
with an expiration date that looks like a real date (eg12/3232
) and any CVC number. - To see an example of custom validation errors, create an access plan that's less that
0.50
or greater that1000.00
. - To see an example of card data validation errors use an expiration date that doesn't look like a real expiration date (eg
1234
). - To see an example of a declined card error use any card numbers other than the success card noted above.
- Recurring payments will succeed 50% of the time.
- Refunds can be processed via the gateway. They will never fail.
- A lot of information is automatically logged, enable debug logging in the gateway settings.
- If something isn't logged that you want to see, add additional logs using
llms_log( $var_you_want_to_inspect, 'sample' )
or useprint_f()
/var_dump()
.
Write unit tests (this example doesn't include example tests but one day maybe it will)
If you don't know how to write unit tests you can manually test recurring payments by:
- Create your recurring access plan
- Checkout to create the recurring order
- Navigate to the order on the admin panel
- Edit the "Next Payment Due Date" to be today at 00:00
- Save the order
- Navigate to the Tools -> Scheduled Actions (turn on
WP_DEBUG
&&WP_DEBUG_DISPLAY
if you don't see it) - Find the action matching the order ID of the order you're testing
- Refresh until the action runs (it runs background actions every one to two minutes)
- Check your logs, order status, etc...
You can fork this repository as a starting point or simply read through the source to help learn how LifterLMS payment gateways should work.
A real gateway will be much more complicated than this example. Our goal is not to teach how to work with any possible gateway but how to work with LifterLMS. It is very general and you will be responsible for filling in the gaps between what this example illustrates and the real world requirements of the payment provider your gateway chooses to integrate with.
Included in this plugin is a fake payment gateway API. The API is included by the plugin and can be found in the fake-rest-api directory.
This API is "functional" to show how the plugin could interact with a payment gateway API. It doesn't record or persist any data it retrieves and always returns random IDs and a limited set of information.
It requires an API key, passed in API request headers
Use SECRET
for successful authentication.
Most real APIs would have a more robust authentication method such as Basic (username/password) or Tokens.
If you choose to clone this repository as starting point you should remove this fake rest api from your payment gateway plugin!
This plugin does not aim to demonstrate or be an authority on data compliance. You should consult your gateways providers and, if necessary, legal counsel if you're unsure about how to ensure your gateway plugin is compliant and secure.
If you're building your own payment gateway and you have questions:
- Stop by
#developers
on the LifterLMS Community Slack Channel. Keep in mind that we're not going to build your payment gateway for you but we'll be excited to look at your code and help where possible. - Post a new question here on GitHub!
Note: LifterLMS has two developers. We very much wish to help every developer with a question but we will likely not respond as quickly as you would like us to respond. We appreciate your patience.
Report it here on GitHub!
Do not Slack us about bugs if you haven't first opened a bug report here! We will ask you to report it in GitHub anyway!
We love you, please open up a Pull Request!
If you've completed a LifterLMS Payment Gateway plugin we want to hear about it! Contact team@lifterlms.com.
Assuming it works and you're planning to offer support to prospective users we will help you promote and market it, list it on our third-party add-ons page, and more!