Chapter 63. Creating a Pay Subscription Site


Somewhere in versions 7.0 or 7.1, PHP-Nuke gained the ability to handle subscriptions. In other words, registered users pay you a fee to gain special access to your Web site for a specified period of time, after which their subscription expires and they go back to being a regular user. Earlier, I showed you that module and block access could be restricted to allow only subscribers in (check out Topics 10, "Controlling Access to Modules," and 37, "Selecting and Using Built-In Blocks").

So how do users get to be subscribers? Well, for starters, their entry in the PHP-Nuke users table (which I briefly discuss in the next topic) is marked as Subscriber. Also, the user gets an entry in the Subscriptions table, listing the user's expiration date. After that, PHP-Nuke handles the rest.

So how do you get the tables updated? One way is manually: Go to the Administration menu, click Edit Users, and enter the username to modify (this is easier if you have the NSN Your Account Tweak, which I covered in Topic 32, "Adding the NSN Your Account Tweak"). As shown in Figure 63.1, you can set the user to be a subscriber for a period of one to ten years.

Figure 63.1. Making a user a subscriber.


If you'll have only a few subscribers, that's not so bad. But it might be nice to have something more automated. For example, PayPal (www.paypal.com) is a popular credit cardprocessing service, and they offer recurring subscription sales capabilities. You can automate your site so that PayPal automatically notifies PHP-Nuke when a subscriber signs up, and notifies PHP-Nuke again when the subscriber renews or cancels. You just need to plug something into PHP-Nuke to accept those notifications and update the PHP-Nuke database appropriately.

To do so, you'll just need to create a new PHP page that examines the HTTP headers coming from the PayPal secure server. Perform a modulus check on the incoming key to ensure the integrity of the data, and then rip the data into individual variables. This all happens in post-back, of course, so you'll have to make sure… oh, wait. What a pain that all is.

Head over to www.nukescripts.net, the folks who brought you the NSN Your Account Tweak. They make a commercial PayPal add-in for PHP-Nuke, which they sell for a paltry $5. The add-in actually works with their NSN Groups add-in, which sort of supplants the PHP-Nuke subscription system and gives you more flexibility.

Other plug-ins accomplish the same thing. One, aMember (http://membership.cgi-central.net/scripts/amember/), works with PHP-Nuke and with a variety of payment providers, including PayPal, 2Checkout, CCBill, and more. It costs moreabout $140 for the standalone product, which doesn't include the PHP-Nuke integrationbut it does have a lot more flexibility and capability. If you really are a PHP guru and want to write your own scripts to automate the subscription process, check with your payment processor. For example, PayPal provides a page at www.paypal.com/cgi-bin/webscr?cmd= p/pdn/intro-outside that teaches developers how to integrate with their Instant Payment Notification (IPN) system; other payment processors should provide similar documentation if they have this capability.

Once you've got your users marked as subscribers, you simply need to create content areas for them by marking specific modules or blocks as Subscribers Only in the Modules and Blocks portions of the Administration menu.

Sidebar . FAQ

How does PayPal work?

Generally, they keep between 2 and 4 percent of whatever you charge and then pass the rest on to you. They use a system called Instant Payment Notification (IPN) to inform your Web site that a subscription was purchased; that's how the PayPal module from NukeScripts.Net is able to instantly add new subscribers to specified user groups.

If you're interested in PayPal, check them out. Carefully read their terms and conditions because some Web sites (typically those offering mature content, although there are other restricted categories) aren't permitted to use their services.




    PHP-Nuke Garage
    PHP-Nuke Garage
    ISBN: 0131855166
    EAN: 2147483647
    Year: 2006
    Pages: 235
    Authors: Don Jones

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net