Home arrow Ruby-on-Rails arrow Tracking Expenditures with PayPal
RUBY-ON-RAILS

Tracking Expenditures with PayPal


If you conduct a lot of business through PayPal, this article can help you use reporting with Ruby-on-Rails to save you time and make your accounts more orgainzed. It is excerpted from chapter seven of the book Practical Reporting with Ruby on Rails, written by David Berube (Apress; ISBN: 1590599330).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 7
April 07, 2010
TABLE OF CONTENTS:
  1. · Tracking Expenditures with PayPal
  2. · Reporting PayPal Expenses
  3. · Using FasterCSV
  4. · Converting PayPal CSV Data
  5. · Dissecting the Code
  6. · Analyzing the Data
  7. · Dissecting the Code in More Detail

print this article
SEARCH DEVARTICLES

Tracking Expenditures with PayPal
(Page 1 of 7 )

PayPal is an e-commerce service that facilitates the electronic transfer of monies via the Internet. Often, PayPal is used by merchants as an easy way to accept credit cards without a merchant account. Additionally, PayPal accounts can be linked to special debit cards, which allows purchases to be made at brick-and-mortar stores using the money in a PayPal account. You can learn more about PayPal at http://www.paypal.com/.

Individuals who do a great deal of business online frequently use PayPal as a convenient way to spend and receive money. In those cases, reporting on data from PayPal can provide important information about financial transactions, as demonstrated in the example in this chapter.

Gathering Data from PayPal

You can take a couple approaches to gathering PayPal data for analysis. One is to use PayPal's web API to download transaction information. Unfortunately, results from searches via the PayPal web API are limited to 100 transactions, which makes it implausible to analyze any significant amount of data.


Tip  This chapter covers reporting on PayPal transactions. If you would like your application to be able to accept payments via PayPal, you can do that with the paypal gem, available from
http://dist.leetsoft.com/api/paypal/.


Another approach is to download data in CSV format through PayPal's web site. If you have a business PayPal account, you can use the following procedure to download your own PayPal data for this chapter's example. If you don't have a business PayPal account, or you don't have any activity to analyze, you can download sample data from the Source/Downloads area of the Apress web site (http://www.apress.com) or from http://rubyreporting.com/examples/ paypal_example.csv. (The reason you need a business account is that its data includes a number of additional fields that are not in the personal account data.)

  1. Log in to your PayPal account at
    http://www.paypal.com/.
  2. Click the History tab, as shown in Figure 7-1.


    Figure 7-1.  PayPal History screen 
  3. Click Download My History to see a screen similar to Figure 7-2.


    Tip  If you have a large volume of data, PayPal will put your report in a queue and e-mail you when it is ready for download.





    Figure 7-2.  PayPal Download History screen

  4. Select a date range. It doesn't matter which range you pick for this example, as long as it reflects some activity on your PayPal account.
  5. From the File Types for Download drop-down list, select Comma Delimited -All Activity.
  6. Click Download History.
  7. When prompted to save the file, do so. Remember the location, as you'll use this file in this chapter's example.

Note  Why aren't we automating the download? Unfortunately, it's because there's no web service available to download it programmatically. It's possible to script the download using, say, the Ruby net/http.rb download library and an HTML parsing library like Hpricot, but unless you have explicit permission from the web site in question, that's typically not a good idea. Potentially, you could be blocked from PayPal or, in an extreme situation, get sued. However, if you do decide to take that route, you might want to employ a library that is easier to use than Ruby's built-in libraries, such as scRUBYt! (http://scrubyt.org/).


Now that you have a CSV file, you can analyze it. It's possible to analyze the data file directly in Ruby, but you might not want to write your own statistical code. Instead, you can load the data into MySQL, and then use MySQL's built-in aggregation functions to analyze it in detail.

Many companies use CSV files to transfer financial, inventory, and other data, so this approach can work with data from organizations other than PayPal.


blog comments powered by Disqus
RUBY-ON-RAILS ARTICLES

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials