Wednesday, December 20, 2006

Article Using the Salesforce.com API on oreillynet

Tony Stubblebine continues his series on how to build and distibute applications on AppExchange. He develops an application which connects comments on a blog with leads in Salesforce.com. Although he uses Perl it is an interesting read for Ruby developers.

Here's the link: Using the Salesforce.com API

Thursday, November 23, 2006

Introduction to Salesforce.com's AppExchange on oreillynet

The article highlights various ways to customize salesforce.com and develop AppExchange applications. It is not Ruby specific but gives a good overview of how to work with salesforce.com.

An Introduction to Salesforce.com's AppExchange by Tony Stubblebine

technorati tags:,

Tuesday, October 24, 2006

Pragmatic Bookshelf: Payment Processing with Paypal and Ruby

The Pragmatic Bookshelf offers a very affordable PDF book titled Payment Processing with Paypal and Ruby. I did not have the time to read it yet, but regarding the reputation of the Pragmatic Bookshelf it is shure worth it.

From the Pragmatic Fridays Series site:

"Building a top-notch web site requires a lot of technical expertise. Keeping track of changing requirements and new technologies, not to mention the competition, can keep you on your toes. Processing payments is a small, but important part of a successful site.

If you're running a web site, you probably don't want to know the details of processing payments. You want to know just enough to solve your problems so you can go to production. As powerful and popular as Ruby is, there isn't much information on credit card processing.

This Friday will give you enough information to make a good decision, and enough technical know-how to implement that decision using Paypal and Ruby."

technorati tags:, , ,

Link to Synchronizing SalesForce and Ruby on Rails

I came across an article on the Clean Air Blog by Highgroove Studios. May be you are interested as well:

Synchronizing SalesForce and Ruby on Rails

"Highgroove Studios is working on a Salesforce-Rails application, and one of the things we have to do is synchronize a local MySQL database with Salesforce."

They describe how they enhanced ActiveRecord to get the syncing done.

technorati tags:, , ,

Thursday, October 05, 2006

Integrating PayPal payments with Ruby on Rails

In Agile Web Development with Rails the Pragmatic Programmers develop the Depot shopping application. The application manages a book catalog, displays the catalog to prospective buyers, manages a shopping cart and checkout. What they do not develop is payment processing after the checkout.

I recently created a PayPal account to make selling stuff I do not need any more on ebay easier to handle. What does it take to enhance the Depot application to do payment processing with PayPal?

The following code is an example used to understand how PayPal works with Ruby on Rails. For real world applications please take a look at the Active Merchant library first. Of course we do not want to reeinvent the wheel!

Getting a PayPal test environment / account

On the PayPal Developer Network you can singn in to Developer Central. Here you can find among other things How-To articles, documentation and a Sandbox test environment.

Standard Checkout

On Integration Center under Additional Payment Options you find a description of the Standard Checkout procedure. It works with HTML-Form code which POSTs a transaction to the PayPal site. The PayPal HTML-Form provides variables for specifying the items to check out.
An other integration option is the Website Payments Pro SOAP API. But for the time beeing we will take a look how Website Payments Standard Simple Checkout can be used to check out the Depot application's shopping cart. The SAOP API may be a topic of an upcoming blog posts.

Task: Payment processing with PayPal

Iteration 1: Website Payments Standard

The goal of the iteration is to enhance the checkout page with PayPal payment processing.

I will use the code of Depot application as at the end of Chapter 10 "Task E: Checkout!". At the time of this writing I have Agile Web Development with Rails 2nd Ed. available as a beta book version B1.12.

Checkout View

To create the form code for the PayPal button we need to iterate over the cart items and add appropriate form fields.

checkout.rhtml:

<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<%= hidden_field_tag "cmd", "_cart" %>
<%= hidden_field_tag "upload", "1" %>
<%= hidden_field_tag "business", "test@test.com" %>

<%= render(:partial => "paypal_item", :collection => @cart.items) %>

<%= hidden_field_tag "return", "http://localhost:3000/store" %>
<%= submit_tag "Buy with PayPal", :class => "submit" %>
<% end_form_tag %>

_paypal_item.rhtml:

<%= hidden_field_tag sprintf("item_name_%d", paypal_item_counter + 1), h(paypal_item.title) %>
<%= hidden_field_tag sprintf("amount_%d", paypal_item_counter + 1), paypal_item.price %>

To-Do (future Iterations)

  • On success of the PayPal payment we need to empty the cart.
  • Use Instant Payment Notification (form field notify_url) to get PayPal payment information and store this information to the Depot database.
  • If the user cancels the PayPal payment we want him to proceed shoping at our site. With the cancel_return form field you can set the URL. PayPal redirects the user to this URL.

What does it have to do with Salesforce?

Nothing in particular, but what about capturing a successful web-sale as an opportunity in salesforce.com? By the way adding buyer information as a lead or contact?

What does the information flow on your e-commerce sites look like? How would you like e-commerce sites integrate with salesforce.com?

ion flow on your e-commerce site look like? How would you like e-commerce sites integrate with salesforce.com?

technorati tags:, ,

Friday, September 22, 2006

Display salesforce.com account listing with Ruby on Rails

I would like to show you, how I did my first connection from Rails to salesforce.com. As an example I would like to display a listing of salesforce.com accounts on a web page.



Getting Started

Following the instructions on ActiveSalesforce (ASF) I installed ActiveSalesforce gem, created a Rails application and configured the application and database.




D:\projects>gem install activesalesforce --include-dependencies

D:\projects>rails sftest

D:\projects>cd sftest


Edit D:\projects\sftest\config\environment.rb and add the line require_gem 'activesalesforce'. If you forget to require the gem you will get an error message: database configuration specifies nonexistent activesalesforce adapter (ActiveRecord::AdapterNotFound).


Edit D:\projects\sftest\config\database.yml and add your salesforce.com account information.


adapter: activesalesforce

url: https://www.salesforce.com/services/Soap/u/7.0

username: salesforce-username

password: salesforce-password

Create module and controller.



D:\projects\sftest>ruby script/generate model account

D:\projects\sftest>ruby script/generate controller account

Edit D:\projects\sftest\app\controllers\account_controller.rb.



class AccountController < ApplicationController

  scaffold :account

end

Run the server and watch the result in your browser.



D:\projects\sftest>ruby sript/server



Resources

technorati tags:, , ,



Thursday, September 14, 2006

Error with mysql 2.7.1 gem

The last two days I was stuck tracking down the source of an error message. Running rake db:migrate or accessing the admin controller of the depot application I got the error message undefined method `each' for #<Mysql:0x352d430>.

I was experimenting with edge rails, Ruby 1.8.5. and MySQL 5.0.27 on Windows XP. rubyonrails.org recommends Ruby 1.8.4, but downgrading did not solve my problem.

To find the cause of the error, I did a clean install of Ruby 1.8.5 and Rails gem. Then I set up a test application:

  1. D:\projects>mysqladmin -u root -p create test
  2. D:\projects>rails test
  3. Edit D:\projects\test\config\database.yml
  4. D:\projects>rake db:migrate

The database connection was successful and no error message came up. So where did the message come from previously?

Then I remembered installing mysql 2.7.1. And yes, this is the cause!

Has anyone an idea why mysql 2.7.1 does not work?

technorati tags:, , ,

Friday, September 08, 2006

Getting started with Ruby on Rails

To get to know Rails, I recommend the "get exited" screencasts on rubyonrails.org. Then go get it installed on your computer! I used the Windows Installer from rubyforge.org. This sets a good base from which you could go further by installing gems (see the download page at rubyonrails.org).

Which editor to use is a very personal decision. Working with the command line and notepad++ on Windows was a good start for me. The magic of IDEs often hide details, which I find important to learn and master first.

I personally like learning by books. I bougt a pdf copy of "Agile Web Development with Rails - second edition". Several minutea after buying online, I began reading Part I. Following along the development of the Depot Application of Part II, I liked the links between different sections of the book and of course the links to the souce code. I am not reading online all the time, so I was looking for a way to use the links to the source offline.

To have the code available offline, I did download the code from the Pragmatic Programmers, put it in the document root of my local webserver and redirected the domain media.pragprog.com to localhost.

On Windows XP put the following line in C:\windows\system32\drivers\etc\hosts:

127.0.0.1 localhost media.pragprog.com

By the way, the pdf book is really well done. Links between sections of the book and to external ressources add value. Most of the time I prefer paper books over ebooks. If all ebooks were made like this one, my preferences would possibly change.

Halfway through the Depot Application I was looking for a more comfortable development environment. I like RadRails although it took some time to find out what configuration options to tweak and how it worked.

OK. Where are we now?

I have got a basic understanding of Ruby and Ruby on Rails. I could read some code and figure out what it does. So next I will have a look at some open-source applications to learn how they build their applications.

technorati tags: