forked from viniciusnz/pagseguro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
96 changed files
with
1,252 additions
and
8,651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
spec/support/tmp/**/* | ||
pkg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--color --format documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
source :rubygems | ||
|
||
gem "rails", "3.0.0" | ||
gem "fakeweb" | ||
gem "rspec-rails", "2.0.0.beta.20" | ||
gem "faker" | ||
gem "ruby-debug19", :require => false | ||
gem "nokogiri" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
abstract (1.0.0) | ||
actionmailer (3.0.0) | ||
actionpack (= 3.0.0) | ||
mail (~> 2.2.5) | ||
actionpack (3.0.0) | ||
activemodel (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
builder (~> 2.1.2) | ||
erubis (~> 2.6.6) | ||
i18n (~> 0.4.1) | ||
rack (~> 1.2.1) | ||
rack-mount (~> 0.6.12) | ||
rack-test (~> 0.5.4) | ||
tzinfo (~> 0.3.23) | ||
activemodel (3.0.0) | ||
activesupport (= 3.0.0) | ||
builder (~> 2.1.2) | ||
i18n (~> 0.4.1) | ||
activerecord (3.0.0) | ||
activemodel (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
arel (~> 1.0.0) | ||
tzinfo (~> 0.3.23) | ||
activeresource (3.0.0) | ||
activemodel (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
activesupport (3.0.0) | ||
archive-tar-minitar (0.5.2) | ||
arel (1.0.1) | ||
activesupport (~> 3.0.0) | ||
builder (2.1.2) | ||
columnize (0.3.1) | ||
diff-lcs (1.1.2) | ||
erubis (2.6.6) | ||
abstract (>= 1.0.0) | ||
faker (0.3.1) | ||
fakeweb (1.3.0) | ||
i18n (0.4.1) | ||
linecache19 (0.5.11) | ||
ruby_core_source (>= 0.1.4) | ||
mail (2.2.5) | ||
activesupport (>= 2.3.6) | ||
mime-types | ||
treetop (>= 1.4.5) | ||
mime-types (1.16) | ||
nokogiri (1.4.3.1) | ||
polyglot (0.3.1) | ||
rack (1.2.1) | ||
rack-mount (0.6.13) | ||
rack (>= 1.0.0) | ||
rack-test (0.5.4) | ||
rack (>= 1.0) | ||
rails (3.0.0) | ||
actionmailer (= 3.0.0) | ||
actionpack (= 3.0.0) | ||
activerecord (= 3.0.0) | ||
activeresource (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
bundler (~> 1.0.0) | ||
railties (= 3.0.0) | ||
railties (3.0.0) | ||
actionpack (= 3.0.0) | ||
activesupport (= 3.0.0) | ||
rake (>= 0.8.4) | ||
thor (~> 0.14.0) | ||
rake (0.8.7) | ||
rspec (2.0.0.beta.20) | ||
rspec-core (= 2.0.0.beta.20) | ||
rspec-expectations (= 2.0.0.beta.20) | ||
rspec-mocks (= 2.0.0.beta.20) | ||
rspec-core (2.0.0.beta.20) | ||
rspec-expectations (2.0.0.beta.20) | ||
diff-lcs (>= 1.1.2) | ||
rspec-mocks (2.0.0.beta.20) | ||
rspec-rails (2.0.0.beta.20) | ||
rspec (= 2.0.0.beta.20) | ||
ruby-debug-base19 (0.11.24) | ||
columnize (>= 0.3.1) | ||
linecache19 (>= 0.5.11) | ||
ruby_core_source (>= 0.1.4) | ||
ruby-debug19 (0.11.6) | ||
columnize (>= 0.3.1) | ||
linecache19 (>= 0.5.11) | ||
ruby-debug-base19 (>= 0.11.19) | ||
ruby_core_source (0.1.4) | ||
archive-tar-minitar (>= 0.5.2) | ||
thor (0.14.0) | ||
treetop (1.4.8) | ||
polyglot (>= 0.3.1) | ||
tzinfo (0.3.23) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
faker | ||
fakeweb | ||
nokogiri | ||
rails (= 3.0.0) | ||
rspec-rails (= 2.0.0.beta.20) | ||
ruby-debug19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,22 +16,29 @@ Após o processo de compra e pagamento, o usuário é enviado de volta a seu sit | |
|
||
Antes de enviar o usuário para essa URL, o robô do PagSeguro faz um POST para ela, em segundo plano, com os dados e status da transação. Lendo esse POST, você pode obter o status do pedido. Se o pagamento entrou em análise, ou se o usuário pagou usando boleto bancário, o status será "Aguardando Pagamento" ou "Em Análise". Nesses casos, quando a transação for confirmada (o que pode acontecer alguns dias depois) a loja receberá outro POST, informando o novo status. **Cada vez que a transação muda de status, um POST é enviado.** | ||
|
||
REQUISITOS | ||
---------- | ||
|
||
A versão atual que está sendo mantida suporta Rails 3.0.0 ou superior. | ||
|
||
Se você quiser esta biblioteca em versão mais antigas do Rails (2.3, por exemplo) deverá usar o [branch legacy](http://github.com/fnando/pagseguro/tree/legacy). Note que esta versão não será mais atualizada com novas funcionalidades; apenas correções de bugs serão aplicadas. | ||
|
||
COMO USAR | ||
--------- | ||
|
||
### Configuração | ||
|
||
O primeiro passo é instalar o plugin. Para isso, basta executar o comando abaixo na raíz de seu projeto. | ||
O primeiro passo é instalar a biblioteca. Para isso, basta executar o comando | ||
|
||
script/plugin install git://github.com/fnando/pagseguro.git | ||
gem install pagseguro | ||
|
||
Se for utilizar o modo de desenvolvimento também precisará da gem Faker: | ||
|
||
sudo gem install faker | ||
gem install faker | ||
|
||
Depois de instalar o plugin, você precisará executar a rake abaixo; ela irá gerar o arquivo `config/pagseguro.yml`. | ||
Depois de instalar a biblioteca, você precisará executar gerar o arquivo de configuração, que deve residir em `config/pagseguro.yml`. Para gerar um arquivo de modelo execute | ||
|
||
rake pagseguro:setup | ||
rails generate pagseguro:install | ||
|
||
O arquivo de configuração gerado será parecido com isto: | ||
|
||
|
@@ -92,7 +99,7 @@ Por padrão, o formulário é enviado para o email no arquivo de configuração. | |
|
||
### Recebendo notificações | ||
|
||
Toda vez que o status de pagamento for alterado, o [PagSeguro](https://pagseguro.uol.com.br/?ind=689659) irá notificar sua URL de retorno com diversos dados. Você pode interceptar estas notificações com o método `pagseguro_notification`. O bloco receberá um objeto da class `PagSeguro::Notification` e só será executado se for uma notificação verificada junto ao [PagSeguro](https://pagseguro.uol.com.br/?ind=689659). | ||
Toda vez que o status de pagamento for alterado, o [PagSeguro](https://pagseguro.uol.com.br/?ind=689659) irá notificar sua URL de retorno com diversos dados. Você pode interceptar estas notificações com o método `pagseguro_notification`. O bloco receberá um objeto da classe `PagSeguro::Notification` e só será executado se for uma notificação verificada junto ao [PagSeguro](https://pagseguro.uol.com.br/?ind=689659). | ||
|
||
class CartController < ApplicationController | ||
skip_before_filter :verify_authenticity_token | ||
|
@@ -141,15 +148,15 @@ O objeto `notification` possui os seguintes métodos: | |
|
||
### Utilizando modo de desenvolvimento | ||
|
||
Toda vez que você enviar o formulário no modo de desenvolvimento, um arquivo YAML será criado em `tmp/pagseguro-#{RAILS_ENV}.yml`. Esse arquivo conterá todos os pedidos enviados. | ||
Toda vez que você enviar o formulário no modo de desenvolvimento, um arquivo YAML será criado em `tmp/pagseguro-#{Rails.env}.yml`. Esse arquivo conterá todos os pedidos enviados. | ||
|
||
Depois, você será redirecionado para a URL de retorno que você configurou no arquivo `config/pagseguro.yml`. Para simular o envio de notificações, você deve utilizar a rake `pagseguro:notify`. | ||
|
||
$ rake pagseguro:notify ID=<id do pedido> | ||
|
||
O ID do pedido deve ser o mesmo que foi informado quando você instanciou a class `PagSeguro::Order`. Por padrão, o status do pedido será `completed` e o tipo de pagamento `credit_card`. Você pode especificar esses parâmetros como o exemplo abaixo. | ||
|
||
$ rake pagamento:notify ID=1 PAYMENT_METHOD=invoice STATUS=canceled NOTE="Enviar por motoboy" NAME="José da Silva" | ||
$ rake pagamento:notify ID=1 PAYMENT_METHOD=invoice STATUS=canceled NOTE="Enviar por motoboy" NAME="José da Silva" EMAIL="[email protected]" | ||
|
||
#### PAYMENT_METHOD | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "rspec/core/rake_task" | ||
require File.dirname(__FILE__) + "/lib/pagseguro/version" | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
begin | ||
require "jeweler" | ||
|
||
JEWEL = Jeweler::Tasks.new do |gem| | ||
gem.name = "pagseguro" | ||
gem.version = PagSeguro::Version::STRING | ||
gem.summary = "A wrapper for the PagSeguro payment gateway." | ||
gem.description = "" | ||
gem.authors = ["Nando Vieira"] | ||
gem.email = "[email protected]" | ||
gem.homepage = "http://github.com/fnando/pagseguro" | ||
gem.has_rdoc = false | ||
gem.files = FileList["{.rspec,Gemfile,Gemfile.lock,Rakefile,README.markdown,pagseguro.gemspec}", "{lib,spec,templates,test}/**/*"] | ||
gem.add_development_dependency "rspec", ">= 2.0.0" | ||
end | ||
|
||
Jeweler::GemcutterTasks.new | ||
rescue LoadError => e | ||
puts "You don't have Jeweler installed, so you won't be able to build gems." | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module PagSeguro | ||
module ActionController | ||
private | ||
def pagseguro_notification(token = nil, &block) | ||
return unless request.post? | ||
|
||
notification = PagSeguro::Notification.new(params, token) | ||
yield notification if notification.valid? | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.