Spacer
Spacer

NGCODERS.COM

[ NEXT GENERATION CODERS ]

Spacer

Archive Page 2



Since last year i have been working on lots of Web Application,During this time I have gone through many frameworks like Code Igniter , CakePHP , Symfony and RoR trying to find what will suit me best. RoR i learned and used a little but never got to using it in a release app , but i did learn a few of the cool stuff which RoR is famous for. CI i just found a little too simple but i still recommend it to beginners, Symfony was a configuration mess. So Cake PHP is what i was working on mostly , But when delivering Small applications to clients i found it a mess to deliver a 1 MB framework with a 30 kb of actual code. Actually coming from an embedded systems background i like my work to be small , fast and do max possible in minimal code.

So i found another framework released by the author of Frog CMS , It was blazingly fast , really small ( 30 kb file ) and php5 with pdo.But i wanted php4 and php5 support and i was used to CakePHP and liked the way it worked. So i started writing my own thing based on the Light framework and modified API And directory structure to be more like cake among other things. I hate to reinvent the wheel , but using truck tyres for a bicycle dosent really make sense and stripping these mammoths would have taken more time.

I have a basic framework ready and will base all my work on the new framework . For a start it has most basic features of cakePHP under < 30k zipped. Here are some of the features -

  • FAST - Really fast
  • SMALL - Really small
  • SIMPLE - Few API to get u started fast
  • Fully OO MVC Code
  • Almost Zero Configuration

Before i release my framework as documentation is left and any advice any of you guys would like to give ?

Speed Simulator

Speed simulator is a simple throttling proxy which allows you to see how your site behaves under diffrent connection speeds. It was written by me to test AJAX/Flash loaders and see how much my time took to load.You can simulate various speeds like that of a modem or a ADSL.A pre delay function is also there to help simulate delays due to DNS , connection establishment etc.

See the Demo Video to see how it works.

Installation

Simply unzip from the archive and double click on it to run it.

Usage

Just select the Speed and the Port on which you want Speed Simulator to start on. Once this is done open your favorite browser and set the proxy to 127.0.0.1 and set the port to the select port (default 8080).Now click start in Speed Simulator and open the site that you wish to test.

I had been really busy lately and one of the reasons was Videoswiper , which was released last month after about 2 months of development.

Videoswiper is a Mass embedding applications which allows Webmasters running video sites to embed Videos on their sites very easily and efficiently.Initial response has been good and with constantly new features being added I think it will do quite well.For more info just go and register yourself an account.

I learned quite a few things while building , which i will share in some other post … so stay tuned.

Recently I wanted to sell a small script for which I was getting some requests.I wanted the procedure to be as efficient as possible where the user was delivered the script though a secret link once the payment was made. After some thorough searching around the net , I found that though the Idea and procedure is so simple there exist No Free scripts
to do so ( Weired ). So in this tutorial we build a small script which can be used anywhere to sell digital goods online using Paypal IPN.They can be ebooks, shareware , software, images anything Bits and Bytes.

The script has the following features

  • Complete automation of your online orders.
  • Automatically emails your customers and provides them with a unique download link to your digital product.
  • Automatically expiring links as required by the user.
  • File Attachments in Email.
  • Easy to test and debug.
  • Easy to integrate into any existing website.
  • Easy to install and configure. Only one settings file.

IPN is what this system is designed around.Instant Payment
Notification (IPN) allows you to integrate PayPal payments with your
website’s back-end operations. IPN provides immediate notification and
confirmation of PayPal payments you receive. Here is how IPN works

How IPN Works

  • A customer payment or a refund triggers IPN. This payment can be
    via Website Payments Standard FORMs or via the PayPal Web Services
    API’s for Express Checkout, Mass Pay, or Refund Transaction. If the
    payment has a “Pending” status, you receive another IPN when the
    payment clears, fails, or is denied.
  • PayPal posts HTML FORM variables to a program at a URL you specify.
    You can specify this URL either in your Profile or with the notify_url
    variable on each transaction. This post is the heart of IPN. Included
    in the notification is the customer’s payment information (such as
    customer name, payment amount). All possible variables in IPN posts are
    detailed in this guide. When your server receives a notification, it
    must process the incoming data.
  • Your server must then validate the notification to ensure that it
    is legitimate.Once this is verified you can go ahead and deliver the
    goods with a link which expires after sometime to the payer.

To activate IPN, you can either change a setting in your PayPal
Profile or include the notify_url variable in the payment FORMs on your
website. We will us the notify_url method.

Also as we will not be using any encryption in the buttons we will
verify all the IPN details during the verification procedure.

Before you begin this tutorial please download the source and refer to it side by side for better understanding.

Step 1 : Setting up to receive and validate IPN
request . We are going to use one of the many Paypal Classes available
freely, I have taken one from micah carrick
.This class handles the request which Paypal send back to us.So the
validation code which will be called once the Paypal invokes our IPN.
validate_ipn() is the function which handles this part.

Step 2 : Now we want do define the products which
we want to sell , As my aim was to sell 1 - 2 odd scripts there was no
use of building a shopping cart. Also as i planned to skip the database
, and keep things simple as possible. So my products listing is a
simple array defined in the settings.php file. The array item index is
the item number which is used when creating a button.

// product[number] = array(’Name’ ,’Price’ , ‘Download Link’);

$products[2] = array(’My Script’,’32′,’downloads/myscript.zip’);

Step 3 : As we will be using non encrypted buttons
, users might try to fool the script by sending in fake IPN requests or
paying different amount and invoking the IPN script. To prevent such
kind of things from happening we put in a validation function which
checks various parameters according to our defined products. This
function is validate_product().

Step 4 : Now we need a Buy now button for our
product which defines our IPN callback, Item number , price etc. This
button is simple HTML and can be placed anywhere and all the user is
required is to click it and pay up , rest the script will take care of.

<form action=”https://www.sandbox.paypal.com/cgi-bin/webscr” method=”post”>

<input type=”hidden” name=”cmd” value=”_xclick”>
<input type=”hidden” name=”business” value=”mail@mybusiness.com”>

<input type=”hidden” name=”item_name” value=”My Ebook”>
<input type=”hidden” name=”item_number” value=”2″>
<input type=”hidden” name=”amount” value=”32.00″>
<input type=”hidden” name=”rm” value=”2″>

<input type=”hidden” name=”return” value=”http://www.mybusiness.com/thankyou.html”>
<input type=”hidden” name=”cancel_return” value=”http://www.mybusiness.com/”>
<input type=”hidden” name=”notify_url” value=”http://www.mybusiness.com/paypal/paypal.php”>

<input type=”image” src=”https://www.paypal.com/en_US/i/btn/x-click-but23.gif” border=”0″ name=”submit” alt=”Make
payments with PayPal - it’s fast, free and secure!”>
<img alt=”” border=”0″ src=”https://www.paypal.com/en_US/i/scr/pixel.gif” width=”1″ height=”1″>
</form>

Step 5 : Now if everything goes fine and user pays
up we need to send him a secret link which expires at our pre decided
time( say 24 hours ). Now this procedure will only takes place if the
IPN return a verified value. The secret link just contains a timestamp
and a product ID which is encrypted using RC4 encryption and then base
64 Encoded so that it can be used in a URL. Then a email is sent to the
user with the Download link.

// Client has successfully paid for the product

$product_id = $p->ipn_data[’item_number’];

$download = $product_id.’|’.time();

$download_link = $script_location.’download.php?file=’.base64_encode(RC4Crypt::encrypt($secret,$download));

Step 6 : Now we need a script which takes this link
and validates it and gives the user the download if everything goes
fine. download.php is the file which does this.

That’s it , you have a set of 2 scripts which will allow you to sell downloads online.

The package also includes a check.php which helps you check if Digisell is functioning properly. Run it after you have editing the settings file.

Back after a long time !!!

Back after a long time , have been quite busy the last few months. Also due to a screwup my old database got deleted.

But i have copies of most of my stuff and will be posting it back slowly and steadily.

If you missed anything while this blog was down , please let know ill put it back online.




About

You are currently browsing the NGCoders - Next Generation Coders weblog archives.

Categories

Subscribe