captured sparks

Archive for May, 2008

The final 10%

The final 10% is always the hardest bit to do. Unfortunately, it’s generally that bit that makes something really work. It stops something being OK and makes it great. It makes you go “Wow”.

On my coffee application (I still don’t have a name apart from wanna coffee?, which I don’t like), the majority of the functionality is there. In its most basic form, the app works. It just doesn’t have that polish and that is what I’m talking about. That is the final 10% and I wouldn’t be happy launching it without that polish. I’m happy if some areas of functionality are not present at launch, provided they are not core to the purpose.

What I don’t want to do is launch at 90% of what I want, and would expect, version 1 to be like. It’s that 10% that I’m working on now.

More on ActiveMerchant and Paypal

I’ve had a few comments asking for some more information setting up AM with Paypal. I won’t profess to be an expert and there may be better ways of doing this.

I am using Paypal UK Website Payments Pro and for this have set up an account that gives me access to Paypal Manager.

As per my previous post, an account is created using the account key as subdomain model:

def create
    @account = Account.new(params[:account])
    @account.initial_plan = params[:plan_id]
    if @account.save
      @account.set_admin
      if @account.initial_plan == "2"
        redirect_to :host => account_host(@account.name), :controller => 'sessions', :action => 'new'
      else
        redirect_to :host => account_host(@account.name), :controller => 'subscriptions', :action => 'new'
      end
    else
      flash[:error] = "Could not create account. Please try again."
      redirect_to :controller => 'accounts', :action => 'new'
    end
  end

If the customer has selected anything other than a free account, they are redirect to the new action of the subscriptions controller. I am using the subscription model to act as a join between an account and a particular plan.

The template for the new action is a simple form with space for credit card information. Creating a subscription calls the following create action in the controller:

def create
    @plan = Plan.find_by_id(@account.initial_plan)
    first_name = params[:cc_name].split(' ')[0]
    surname = params[:cc_name].split(' ')[1]
    name = params[:cc_name]
    number = params[:cc_number]
    amount = @plan.price*100
    credit_card = {
      :number     => "#{number}",
      :first_name => "#{first_name}",
      :last_name  => "#{surname}",
      :name       => "#{name}",
      :month      => "#{params[:cc_month]}",
      :year       => "#{params[:cc_year]}",
      :verification_value => "#{params[:cc_cvv]}",
      :type       => "#{params[:cc_type]}"
    }
    subscription = Subscription.recurring(amount, credit_card, options = {:ip => request.remote_ip})
    if subscription
      subscription.plan_id = @plan.id
      subscription.account_id = @account.id
      subscription.save
      flash[:notice] = "Your account has been setup.  You can now login!"
      redirect_to matters_url
    else
      flash[:error] = "YIKES!"
      redirect_to new_subscription_url
    end
  end

I have no doubt that a lot of this could be refactored into the model. At the moment, I am focussing on getting the app running, not tidying up the code. You will note the class method “recurring”, which is in the subscription.rb file. The code for this is taken straight from the AM pdf mentioned in my earlier post so I cannot repost that here. This method creates a connection through AM to Paypal and creates a recurring subscription. Information that is returned includes a profile id that can be used to uniquely identify a particular subscription in both the app and Paypal manager.

Updating the subscription is fairly similar to creating a new subscription except you pass the profile id through so that Paypal knows which account to change.

One thing to note is that it is important to ensure consistency between Paypal and the subscriptions table in your app. It is very easy to update a subscription in Paypal so that a customer is billed the correct amount but fail to update the internal record in your app. This will result in revenues being either significantly higher or lower than you expect.

One of the questions in the comments to the original post is how much information in the pdf was relevant to Paypal US. I can’t directly answer that but I can say that the code works as a great starting point but some re-coding will necessary to make it work for your app.

A new look

I’ve spent the past few weeks working a redesign for captured sparks and this weekend, as you can see, I have put it live.

I have also taken the opportunity to implement some functionality that has been missing. As you might know, captured sparks is published on my own system coded in Rails and even though I have had the basics running for a few months, there were some key things that I needed but never found the time to implement.

During the course of the redesign, I’ve added the following functionality:

Post Status

I can now classify a post as either a draft or published.

Comment Administration

Up until now, I have had to manage any comments by logging into the server and directly editing the database through the Rails console. I’ve now added the ability to approve or reject comments in the admin area.

I’ve also made the decision to effectively ignore IE6. The site uses PNGs for titles and I’ve not taken any steps to address IE6’s failure in this regard. Nor have I checked to see how the site looks in IE6 generally. I’m using IE conditional comments to present a friendly warning to those users with IE6 that the site may not look great and suggesting an upgrade.

Busy times

I haven’t had much opportunity to post here recently due to some travel and a mix of work on my own projects and work for clients. Aside from my development work, I also maintain a few websites and the updates and maintenance for these have been coming thick and fast.

One of my own projects is approaching fruition. It’s a small application that allows people to review coffee shops that are local to them or that they visit. The idea came following a trip to Hull where I had about 5 hours to kill and there was no way to find details of a good coffee shop where I could spend a few hours. I suppose I hope it may help unearth some gems and stop people heading for the nearest Starbucks or Costa.

The application uses the Google Maps API and the GeoKit plugin to geocode the location of coffee houses. I think this is the type of application that really suits having a mobile version and once the web version is sufficiently complete, I’ll work on producing a mobile friendly version. There is quite a bit to do, but I’m going to push it live in the next month and hopefully get some feedback that will drive continued development.

I also hope to write up a bit more detail on ActiveMerchant and PayPal as I note from the logs that the entry on that topic has received quite a bit of traffic and I think it is definitely a topic that could do with more documentation.