Quantcast

Jump to content






How We Implemented The Immediate Neocash Code Delivery System

Posted by Hydrogen, in Programming 26 August 2012 · 837 views

neocash programming products
How We Implemented The Immediate Neocash Code Delivery System Neocodex has recently started to sell Neocash cards through its store with immediate delivery. In this blog post, I want to take you through the history of how we got here, and how we implemented the immediate delivery solution that is custom to our website, and unique to all Neocash delivery services on the internet.

On April 16, 2012, Pyro699, one of the admins on our site offered to purchase Neocash for our members. The system was completely manual. Users would post in the thread, and Pyro699 would go to the store to buy the Neocash card for the user. The delivery would be made through a PM. The whole process would take a few days, depending on how long it took to go to the store at a convenient time. In the three months that the service was available, Pyro699 sold $215 worth of Neocash cards, plus a small fee.

On July 31, 2012, we evaluated the Neocash selling system that Pyro had set up and saw that it had generated quite a bit of sales. We decided to make things a bit more official and move the service into our store. The process was still the same, however: Pyro699 would go to the store whenever an order was generated and deliver the Neocash code through the PM system, manually. The service was available for three weeks and we sold 4 $10 Neocash cards, and 8 $25 Neocash cards, for a total of $240 plus our fee.

On August 19, 2012, we wrote a simple plugin to take things one step further and introduced a system that would deliver the Neocash card codes immediately without requiring users to wait for us to go to the store. It required us to keep an inventory of Neocash codes on hand and write a custom trigger for our e-commerce software, IP.Nexus.

To get an idea of what a custom action looks like, we've reproduced some of our code here:

<?php

/**
 * Externally instantiate the IPS API
 */
define('IPS_ENFORCE_ACCESS', TRUE);
define('IPB_THIS_SCRIPT', 'public');
require_once('/var/www/html/forum/initdata.php');
require_once(IPS_ROOT_PATH . 'sources/base/ipsRegistry.php');
require_once(IPS_ROOT_PATH . 'sources/base/ipsController.php');

class custom_actions_neocash {
    public function onPurchaseGenerated($member, $package, $invoice, $purchase) {
        /*
         * settings -- we might want to change these
         */
        $this->from_member_id = 34316; // pyro
        $this->low_stock_value = 1; // how many items remaining in our inventory constitutes a low stock alert?

        /*
         * Instantiate the IPS registry
         */
        $this->registry = ipsRegistry::instance();
        $this->registry->init();

        if(!$this->messengerFunctions) {
            $classToLoad = IPSLib::loadLibrary(IPSLib::getAppDir('members') . '/sources/classes/messaging/messengerFunctions.php', 'messengerFunctions', 'members');
            $this->messengerFunctions = new $classToLoad($this->registry);
        }

        /*
         * Set up a shorthand for the database connection
         */
        if(!$this->DB) {
            $this->DB = $this->registry->DB();
        }

        /*
         * Which package did the user purchase?
         */
        switch($package['p_id']) {
            case 8: // 1000 neocash
                $value = 1000;
                break;
            case 9: // 2500 neocash
                $value = 2500;
                break;
            case 15: // 1500 neocash
                $value = 1500;
                break;
            default:
                $this->send_out_of_stock_pm($member['member_id'], 'unknown package');
                return;
        }
    }
}

?>

A lot of the code has been omitted for brevity. All it does after what has been shown is pull the Neocash code from the database and send a PM to the user. To understand how to do this, you can consult the IPB API:


The system has some work left to do. If you didn't notice, purchasing multiple Neocash cards at the same time might not work yet. Furthermore, we have to make sure that the number of cards reported to be in stock is updated at every transaction, just in case. We don't want to report that there are cards in stock when there aren't.

While there is some work to do with the system, the basic framework is there to support immediate delivery of Neocash card codes :). Hopefully this post gives you a bit of insight about what it took to get a product from start to (almost) finish on Neocodex :). Expect more posts about the technological backend of Neocodex to follow :D.



August 19, 2011, eh?
  • Report

August 19, 2011, eh?

Oops :p. Fixed. Thanks!
  • Report
Looks good, glad there was an explanation for how all that worked. I hadn't been overly curious about the process but I had assumed it was something similar along these lines.

Now you just gotta fix it so that tab will take you to the Add Comment box and not the search box at the top of the screen. :p
  • Report

Search My Blog

Recent Comments

Latest Visitors