Permalink
Browse files

Going to last version

  • Loading branch information...
2 parents 369068d + 050d8b5 commit 66b4ced9579f671c47a760f94e3f622c3ec8324a @renatoelias renatoelias committed Oct 9, 2012
Showing with 3,315 additions and 620 deletions.
  1. +0 −5 .document
  2. +5 −1 .gitignore
  3. +1 −0 .rspec
  4. +2 −7 Gemfile
  5. +10 −0 Guardfile
  6. +33 −7 README.textile → README.md
  7. +20 −0 RELEASES.md
  8. +4 −52 Rakefile
  9. +0 −41 braspag.gemspec
  10. +17 −0 config/braspag.yml
  11. +0 −32 lib/braspag.rb
  12. +0 −12 lib/braspag/connection.rb
  13. +0 −42 lib/braspag/cryptography.rb
  14. +0 −46 lib/braspag/gateway.rb
  15. +0 −35 lib/braspag/recorrente.rb
  16. +0 −16 lib/braspag/service.rb
  17. +15 −0 lib/generators/braspag/install/install_generator.rb
  18. +17 −0 lib/generators/braspag/install/templates/config/braspag.yml
  19. +45 −0 lib/rbraspag.rb
  20. +160 −0 lib/rbraspag/bill.rb
  21. +37 −0 lib/rbraspag/connection.rb
  22. +181 −0 lib/rbraspag/credit_card.rb
  23. +91 −0 lib/rbraspag/crypto/jar_webservice.rb
  24. +100 −0 lib/rbraspag/crypto/webservice.rb
  25. +90 −0 lib/rbraspag/eft.rb
  26. +39 −0 lib/rbraspag/errors.rb
  27. +43 −0 lib/rbraspag/order.rb
  28. +72 −0 lib/rbraspag/payment_method.rb
  29. +36 −0 lib/rbraspag/poster.rb
  30. +155 −0 lib/rbraspag/protected_credit_card.rb
  31. +32 −0 lib/rbraspag/utils.rb
  32. +3 −0 lib/rbraspag/version.rb
  33. +33 −0 rbraspag.gemspec
  34. +427 −0 spec/bill_spec.rb
  35. +0 −74 spec/braspag/cryptography_spec.rb
  36. +0 −6 spec/braspag/layout_spec.rb
  37. +0 −34 spec/braspag/recorrente_spec.rb
  38. +152 −18 spec/connection_spec.rb
  39. +447 −0 spec/credit_card_spec.rb
  40. +187 −0 spec/crypto/jar_webservice_spec.rb
  41. +143 −0 spec/crypto/webservice_spec.rb
  42. +209 −0 spec/eft_spec.rb
  43. +0 −68 spec/gateway_spec.rb
  44. +118 −0 spec/order_spec.rb
  45. +53 −0 spec/poster_spec.rb
  46. +277 −0 spec/protected_credit_card_spec.rb
  47. +14 −39 spec/spec_helper.rb
  48. +47 −0 spec/utils_spec.rb
  49. +0 −85 tmp/layout
View
@@ -1,5 +0,0 @@
-README.rdoc
-lib/**/*.rb
-bin/*
-features/**/*.feature
-LICENSE
View
@@ -1,5 +1,9 @@
+nbproject
pkg
doc
tags
-*.swp
+*.sw*
.bundle
+.rvmrc
+Gemfile.lock
+
View
1 .rspec
@@ -0,0 +1 @@
+--colour
View
@@ -1,9 +1,4 @@
source "http://rubygems.org"
-gem "handsoap"
-gem "curb"
-
-group :test do
- gem "rspec"
- gem "nokogiri"
-end
+# Specify your gem's dependencies in rbraspag.gemspec
+gemspec
View
@@ -0,0 +1,10 @@
+guard 'bundler' do
+ watch('Gemfile')
+end
+
+guard 'rspec', :version => 2, :bundler => false do
+ watch(%r{^spec/(.*)_spec\.rb$})
+ watch(%r{^lib/rbraspag.rb$}) { "spec" }
+ watch(%r{^lib/rbraspag/(.*)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+end
@@ -1,14 +1,39 @@
-h2. INSTALLATION
+# rBraspag
-<pre><code>sudo gem install braspag</code></pre>
+rbraspag gem to use Braspag gateway
-h2. USAGE
+* This gem need RACK_ENV environment variable to identify the environment
-<pre><code>connection = Braspag::Connection.new '{84BE7E7F-698A-6C74-F820-AE359C2A07C2}'
-gateway = Braspag::Gateway.new connection
-gateway.authorize! :orderId => 'test001', :customerName => 'Walter Bishop', :amount => '1000000,00', ...</code></pre>
+# How to install
-h2. LICENSE:
+## for Rails 3 app
+
+### Add on your Gemfile
+
+ gem "rbraspag"
+
+### Create a config/braspag.yml file
+
+ $ rails generate braspag:install
+
+### Set RACK_ENV (our suggest)
+
+ # add last line in config/environment.rb
+ # ...
+ # ENV["RACK_ENV"] ||= ENV["RAILS_ENV"]
+
+### Edit config/braspag.yml with your Braspag merchant_id
+
+# Examples
+
+## to create a Bill (Boleto/Bloqueto for brazilian guys)
+ @bill = Braspag::Bill.generate({
+ :order_id => 1,
+ :amount => 3,
+ :payment_method => 10
+ })
+
+# License
(The MIT License)
@@ -32,3 +57,4 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
View
@@ -0,0 +1,20 @@
+# RELEASES
+
+## For next release
+
+d2b9a7a Voltando a usar o HTTPI
+
+## 0.1.1 - 09/01/2012
+
+9ffbcbd adicionando novos códigos de métodos de pagamento
+
+
+## 0.1.0 - 09/01/2012
+
+5cf697e adicionando Gemfile.lock ao .gitignore
+a6b1f54 removendo Gemfile.lock; modificando verificação do argumento has_interest
+a663e0a baixando a versão mínima requerida do nokogiri
+628d108 refatorando testes e implementação
+087549a moving Connection exceptions to errors.rb; tests for Utils class
+9a727eb bump up version
+6e5b1c3 refatorando para suportar o ambiente de produção da Braspag
View
@@ -1,54 +1,6 @@
-require 'rubygems'
-require 'rubygems/specification'
-require 'rake'
-require 'rake/gempackagetask'
-require 'spec/rake/spectask'
+require 'bundler/gem_tasks'
+require 'rspec/core/rake_task'
-GEM = "braspag"
-GEM_VERSION = "0.4.0"
-SUMMARY = "Access the Braspag webservices using Ruby"
-AUTHOR = "Gonow"
-EMAIL = "labs@gonow.com.br"
-HOMEPAGE = "http://www.gonow.com.br"
+RSpec::Core::RakeTask.new(:spec)
-spec = Gem::Specification.new do |s|
- s.name = GEM
- s.version = GEM_VERSION
- s.platform = Gem::Platform::RUBY
- s.summary = SUMMARY
- s.require_paths = ['lib']
- s.files = FileList['lib/**/*.rb', '[A-Z]*'].to_a
-
- s.add_dependency 'handsoap', '=1.1.7'
-
- s.add_development_dependency 'rspec'
- s.add_development_dependency 'nokogiri'
-
- s.author = AUTHOR
- s.email = EMAIL
- s.homepage = HOMEPAGE
-end
-
-Spec::Rake::SpecTask.new do |t|
- t.spec_files = FileList['spec/**/*_spec.rb']
- t.spec_opts = %w(-fs -fh:doc/specs.html --color)
-end
-
-Rake::GemPackageTask.new(spec) do |pkg|
- pkg.gem_spec = spec
-end
-
-desc "Install the gem locally"
-task :install => [:package] do
- sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
-end
-
-desc "Create a gemspec file"
-task :make_spec do
- File.open("#{GEM}.gemspec", "w") do |file|
- file.puts spec.to_ruby
- end
-end
-
-desc "Builds the project"
-task :build => :spec
+task :default => :spec
View
@@ -1,41 +0,0 @@
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{braspag}
- s.version = "0.4.0"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Gonow"]
- s.date = %q{2010-09-10}
- s.email = %q{labs@gonow.com.br}
- s.files = ["lib/braspag/connection.rb", "lib/braspag/cryptography.rb", "lib/braspag/gateway.rb", "lib/braspag/recorrente.rb", "lib/braspag/service.rb", "lib/braspag.rb", "Rakefile", "README.textile"]
- s.homepage = %q{http://www.gonow.com.br}
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.7}
- s.summary = %q{Access the Braspag webservices using Ruby}
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<rubigen>, [">= 1.3.4"])
- s.add_runtime_dependency(%q<handsoap>, ["= 1.1.7"])
- s.add_runtime_dependency(%q<curb>, ["= 0.7.6"])
- s.add_development_dependency(%q<rspec>, [">= 0"])
- s.add_development_dependency(%q<nokogiri>, [">= 0"])
- else
- s.add_dependency(%q<rubigen>, [">= 1.3.4"])
- s.add_dependency(%q<handsoap>, ["= 1.1.7"])
- s.add_dependency(%q<curb>, ["= 0.7.6"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<nokogiri>, [">= 0"])
- end
- else
- s.add_dependency(%q<rubigen>, [">= 1.3.4"])
- s.add_dependency(%q<handsoap>, ["= 1.1.7"])
- s.add_dependency(%q<curb>, ["= 0.7.6"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<nokogiri>, [">= 0"])
- end
-end
View
@@ -0,0 +1,17 @@
+development:
+ environment: "homologation"
+ merchant_id: "{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"
+ crypto_url: "http://localhost:9292"
+ crypto_key: "1234561246"
+
+test:
+ environment: "homologation"
+ merchant_id: "{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"
+ crypto_url: "http://localhost:9292"
+ crypto_key: "1234561246"
+
+production:
+ environment: "production"
+ merchant_id: "{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"
+ crypto_url: "http://localhost:9292"
+ crypto_key: "1234561246"
View
@@ -1,32 +0,0 @@
-require 'rubygems'
-require 'bundler/setup'
-
-require 'handsoap'
-require 'braspag/service'
-require 'braspag/cryptography'
-require 'braspag/connection'
-require 'braspag/gateway'
-require 'braspag/recorrente'
-
-module Braspag
- class Production
- BASE_URL = 'https://transaction.pagador.com.br'
- end
-
- class Test
- BASE_URL = 'https://homologacao.pagador.com.br'
- end
-end
-
-module Handsoap
- class Service
- private
- def invoke_and_parse(method_name, soap_action, &block)
- response = invoke("tns:#{method_name}", soap_action) do |message|
- message.add("tns:merchantId", @connection.merchant_id)
- block.call(message)
- end
- response.document.xpath("//ns:#{method_name}Result").first
- end
- end
-end
View
@@ -1,12 +0,0 @@
-module Braspag
- class Connection
- attr_reader :base_url, :environment, :merchant_id
-
- def initialize(merchant_id, environment = :production)
- environment = :test unless environment.eql? :production
- @environment = eval(environment.to_s.capitalize)
- @base_url = @environment::BASE_URL
- @merchant_id = merchant_id
- end
- end
-end
@@ -1,42 +0,0 @@
-module Braspag
- class Cryptography < Handsoap::Service
- include Braspag::Service
-
- def encrypt(map)
- soap_action = "#{base_action_url}/EncryptRequest"
- invoke_and_parse('EncryptRequest', soap_action) do |message|
- message.add("tns:request") do |sub_message|
- map.each do |key, value|
- sub_message.add("tns:string", "#{key}=#{value}")
- end
- end
- end.to_s
- end
-
- def decrypt(encripted_text)
- soap_action = "#{base_action_url}/DecryptRequest"
- document = invoke_and_parse('DecryptRequest', soap_action) do |message|
- message.add("tns:cryptString", encripted_text)
- end
- convert_request_to_map document
- end
-
- def base_action_url
- "https://www.pagador.com.br/webservice/BraspagGeneralService"
- end
-
- def uri
- "#{@connection.base_url}/BraspagGeneralService/BraspagGeneralService.asmx"
- end
-
- private
- def convert_request_to_map(document)
- map = {}
- document.xpath("//ns:string").each do |text|
- values = text.to_s.split("=")
- map[values[0].downcase.to_sym] = values[1]
- end
- map
- end
- end
-end
View
@@ -1,46 +0,0 @@
-module Braspag
- class Gateway < Handsoap::Service
- include Braspag::Service
-
- %w(authorize capture).each do |method|
- eval <<-METHOD
- def #{method}!(map)
- invoke! "#{method.capitalize}", map
- end
- METHOD
- end
-
- def void_transaction!(map)
- invoke! "VoidTransaction", map
- end
-
- protected
-
- def invoke!(method, map)
- document = invoke_and_parse(method, "#{uri}/#{method}") do |message|
- map.each do |key, value|
- message.add("tns:#{key}", "#{value}")
- end
- end
- convert_to_map document
- end
-
- def base_action_url
- "https://www.pagador.com.br/webservice/pagador"
- end
-
- def uri
- "#{@connection.base_url}/webservices/pagador/Pagador.asmx"
- end
-
- def convert_to_map(document)
- map = { "amount" => "", "authorisationNumber" => "", "message" => "", "returnCode" => "", "status" => "", "transactionId" => "" }
- map.each_key do |key|
- document.xpath("//ns:#{key}").each do |text|
- map[key] = text.to_s
- end
- end
- map
- end
- end
-end
Oops, something went wrong.

0 comments on commit 66b4ced

Please sign in to comment.