XF 2.0 How does the Purchasable Items System work?

Alpha1

Well-known member
The system is split up into several distinct parts.

There's the payment provider system which is what provides the ability to pay for items using any of the built in providers, e.g. PayPal, Stripe and the provider system is extensible so other developers can add other providers (see this resource for an example).

Then there's the purchasable item system which is the system that the user upgrades stuff is built upon.

The two systems are entirely separate, so theoretically you don't really need to know how the payment provider system works to create new purchasable items.

In lieu of the documentation, which we will work on at some point in the future, I recommend looking into how the user upgrade system works for guidance on how to create new purchasable items.

If you have any questions after this post, please post in the XenForo development discussions forum as this thread isn't the appropriate place for that kind of support.
Could you please tell me a little more about how the purchasable Items system works? As you know I am not a developer, but am interested in the possibilities and limitations. I would love to have functions where my members are presented with a BUY button to purchase single functions & actions.

For example after posting a thread have a BUY button to sticky the thread. Or similarly have a BUY button to post in a forum.
Such singular functionality seems very different from Account Upgrades. What are the things that can and cant be done with this? What is the general gist of extending it? I would be very interested to read anything you could share about this, because this is one of the main attractions of XenForo 2 for me and its not yet clear to me what the practical possibilities are.
 
This is very much something that needs a developer because integrating with the purchasable system is only half of it: you need a system to actually implement what they're purchasing as well.

In essence though, it's really just a system that handles the creation of a "purchase object" which describes the purchase and the necessary data for your purchasable item to know what actions to take. This purchase can be a one off or a recurring subscription. This purchase object gets handed over to the payment provider system for handling the actual money exchange. The payment provider system then handles things like callbacks from PayPal, Stripe, etc to know what action has just happened with regards to the purchase (completed, reversed, etc). This action is then passed back to the purchasable and the appropriate action is taken by the purchasable object (making a thread sticky, adding a credit so a user can post a thread in a forum, maybe removing those credits because there was a chargeback, whatever).

It's a pretty general purpose system.
 
It will be very interesting to see the first addon that offers singular purchases.
This action is then passed back to the purchasable and the appropriate action is taken by the purchasable object (making a thread sticky, adding a credit so a user can post a thread in a forum, maybe removing those credits because there was a chargeback, whatever).
Do you mean that the system has a form of credits built in, that can be used for purchasable items? If yes, can this be extended?
 
No, the system doesn't have any concept of that. I was using that with what's effectively your "pay to post" example: you could allow someone to purchase X threads at once; your code would track this using some sort of credit/token to indicate how many you have left and thus gating access based on that.
 
It will be very interesting to see the first addon that offers singular purchases.
For the record, both our Donate and Credits modifications uses this system in the XF2 versions (for receiving donations and for purchasing currency, respectively).

I am also working on another (XF2-only) mod that will make use of this system to handle more traditional purchases :)


Fillip
 
Anymore hints in this area?

I am working on creating a PesaPal payment gateway (Payment profile in Xenforo terms) and have discovered the Purchasable concept. It makes sense to use the builtin Xenforo concepts where ever possible.

What is the best approach to making access to a few selected forums "purchasable"? The next step is looking at the visual aspect of displaying a "Buy" button beside a forum - afterwards will be hooking the payment confirmation into assignment to a user group...
 
What is the best approach to making access to a few selected forums "purchasable"? The next step is looking at the visual aspect of displaying a "Buy" button beside a forum - afterwards will be hooking the payment confirmation into assignment to a user group...
That's entirely regulated through user group permissions. You would simply set permissions, then display your button, which hooks into the payment confirmation.
 
That's entirely regulated through user group permissions. You would simply set permissions, then display your button, which hooks into the payment confirmation.
How does a button get hooked to the payment system?

Ideally we want an option for forum creation that would flag it as purchable and associate a price.

Ideas / examples..
 
Anymore hints in this area?

I am working on creating a PesaPal payment gateway (Payment profile in Xenforo terms) and have discovered the Purchasable concept. It makes sense to use the builtin Xenforo concepts where ever possible.

What is the best approach to making access to a few selected forums "purchasable"? The next step is looking at the visual aspect of displaying a "Buy" button beside a forum - afterwards will be hooking the payment confirmation into assignment to a user group...
If anyone cares, the big hint is "User Upgrades". This core feature provides a complete example of using the "Purchasable System".

While not trivial, it appears to be very flexible and does not impose a predetermined UI. This definitely requires a lot of highly skilled code smithing to get something useful. I can see my efforts being broken into at least 3 addons:
- Payment Profile (which in eCommerce speak implements support for one or more Payment Gateways)
- Paid Content - generic internal Purchasable thingy that works with the Payment Profile
- Paid Forum - specialized Paid Content that provides a UI to buy access to forums.

Note that my comments in this thread are related to another thread I created: https://xenforo.com/community/threads/paywall-or-paid-premium-content.152472/
 
A little feedback regarding my experiences...

Payment Profiles & Purchasables are 2 distinct concepts that work closely together. XF2 provides a nice generic plugin platform for implementing:

- things to sell (Purchasable's)
- a means to buy things (Payment Profiles)

I needed to implement both. The generic heavy lifting was a new payment interface (XF Payment Profile) to PesaPal (think PayPal for Africa). This was the most interesting aspect of the project as it was generic.

The application specific Purchasable was paid access to specific forums - $$$ to access a forum.

In the end I created 3 add-ons ( my Drupal background makes me want to break things up):
- the payment profile
- the purchasable
- the net action of the purchase

Please feel free to ping me with questions.
 
Consider to release the addons.

Could you explain this one?
Based upon my Drupal background I tend to isolate re-usable logic into different add-ons - modules in Drupal Speak. Drupal has a very nice "dependency" system where a module is able to declare that it depends upon another module.

In this case the net action of the purchase will be to grant the user access to a specific forum node for a specified time period. So I placed the logic to grant access and cron revoke access into a separate add-on that could potentially be used by other add-ons. This permissions addon knows nothing about the Payment profile or the Purchasable logic.
 
Just an update on my experience in this area. The initial payment provider turned out to be less than optimal. So a different payment provider was required.

Since I had initially divided my problem into 3 different addons, it was simple to enhance my "payment gateway" addon to include a second payment provider - while also retaining the original payment provider.

My client now has functional PesaPal and iPay Africa payment provider integration into XenForo. Users get to purchase access to specific XF forums.

P.S. The even more interesting aspect of this project is that XF became the payment system of record, but the actual real content being purchased is online courses hosted by a separate Moodle system. This integration required development of a XF "Moodle Access" addon as well as a Moodle "XF Course Enrollment" plugin. Each time a user logins into the Moodle system to access online courses the XF system is checked in real time to determine their access levels. All user profiles / passwords are maintained by the XF system.
 
Consider to release the addons.
Sorry I missed responding to this before. The addons are the intellectual property of my client. So I can not open source or resell them.

I am free to share my experience / knowledge if people have specific problems or questions.
 
Top Bottom