Repository is archived
No commit activity in last 3 years
No release in over 3 years
This gem provides a simple way to check and parse the PagSeguro transaction notification.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.2.3
~> 1.6.4
~> 0.9.2
~> 2.3.0
~> 0.7.1

Runtime

~> 0.10.0
>= 0
 Project Readme

PagseguroCatcher

About

This is a little gem that helps you parsing the return of the Pagseguro’s transaction notification.
You can find more info about the notification API here.

Usage

The first thing you’ll need to do is to enable the Pagseguro’s transaction notification. When you do that, you’ll receive a post in the URL that you just set up.

When you’re done, it’s time to set up the PagseguroCatcher params. If you’re using Rails, the best way to do that is creating an initializer and set the following parameters:

PagseguroCatcher.configure do |config|
  config.token = "YOUR CONFIG TOKEN"
  config.email = "you@yourcompany.com"
end

Every time that some transaction occurs, you’ll receive a post in the URL that you set up on Pagseguro. When that post hits your app, you’ll do this (again, assuming you’re in a Rails application):

if request.post?    
  if params[:notificationCode] && params[:notificationType]
    transaction = PagseguroCatcher::Checker.new(params[:notificationCode], params[:notificationType]).check
    # your implementation logic goes here
  end

  render :nothing => true
end

The transaction object contains the all the magic:

transaction.date # => Thu, 10 Feb 2011 16:13:41 -0300
transaction.payment_method_type # => Cartão de crédito

You can also access others sections as well:

transaction.sender.name # => "John Doe"
transaction.amount.gross # => 199.99
transaction.shipping.zip # => "01452002"

Looping each item is easy too:

transaction.each_item do |item|
  puts item.description
end

Notebook Prata
Notebook Rosa

TODO

0.2.0

  • write the documentation
  • implement a nice way to rescue the ::Checker#check method, when the request isn’t successfull or the return is invalid

0.3.0:

  • maybe some nice logs?

Contributing to pagseguro_catcher

  • Check out the latest master to make sure the feature hasn’t been implemented or the bug hasn’t been fixed yet
  • Check out the issue tracker to make sure someone already hasn’t requested it and/or contributed it
  • Fork the project
  • Start a feature/bugfix branch
  • Commit and push until you are happy with your contribution
  • Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
  • Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.

Copyright

Copyright © 2011 Matias H. Leidemer. See LICENSE.txt for
further details.