gonow_braspag 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'braspag'
4
+ gem 'spree_core'
5
+
6
+ group :development do
7
+ gem 'ruby-debug19'
8
+ end
@@ -0,0 +1,132 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.9)
6
+ actionpack (= 3.0.9)
7
+ mail (~> 2.2.19)
8
+ actionpack (3.0.9)
9
+ activemodel (= 3.0.9)
10
+ activesupport (= 3.0.9)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.5.0)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.14)
16
+ rack-test (~> 0.5.7)
17
+ tzinfo (~> 0.3.23)
18
+ activemerchant (1.15.0)
19
+ activesupport (>= 2.3.8)
20
+ braintree (>= 2.0.0)
21
+ builder (>= 2.0.0)
22
+ activemodel (3.0.9)
23
+ activesupport (= 3.0.9)
24
+ builder (~> 2.1.2)
25
+ i18n (~> 0.5.0)
26
+ activerecord (3.0.9)
27
+ activemodel (= 3.0.9)
28
+ activesupport (= 3.0.9)
29
+ arel (~> 2.0.10)
30
+ tzinfo (~> 0.3.23)
31
+ activeresource (3.0.9)
32
+ activemodel (= 3.0.9)
33
+ activesupport (= 3.0.9)
34
+ activesupport (3.0.9)
35
+ acts_as_list (0.1.2)
36
+ arel (2.0.10)
37
+ braintree (2.10.2)
38
+ builder (>= 2.0.0)
39
+ braspag (0.4.0)
40
+ curb (= 0.7.6)
41
+ handsoap (= 1.1.7)
42
+ rubigen (>= 1.3.4)
43
+ builder (2.1.2)
44
+ curb (0.7.6)
45
+ erubis (2.6.6)
46
+ abstract (>= 1.0.0)
47
+ faker (0.9.5)
48
+ i18n (~> 0.4)
49
+ handsoap (1.1.7)
50
+ highline (1.5.1)
51
+ i18n (0.5.0)
52
+ jquery-rails (0.2.6)
53
+ rails (~> 3.0)
54
+ thor (~> 0.14.4)
55
+ mail (2.2.19)
56
+ activesupport (>= 2.3.6)
57
+ i18n (>= 0.4.0)
58
+ mime-types (~> 1.16)
59
+ treetop (~> 1.4.8)
60
+ meta_search (1.0.5)
61
+ actionpack (~> 3.0.2)
62
+ activerecord (~> 3.0.2)
63
+ activesupport (~> 3.0.2)
64
+ arel (~> 2.0.2)
65
+ mime-types (1.16)
66
+ nested_set (1.6.6)
67
+ activerecord (>= 3.0.0)
68
+ railties (>= 3.0.0)
69
+ paperclip (2.3.11)
70
+ activerecord (>= 2.3.0)
71
+ activesupport (>= 2.3.2)
72
+ polyglot (0.3.2)
73
+ rack (1.2.3)
74
+ rack-mount (0.6.14)
75
+ rack (>= 1.0.0)
76
+ rack-test (0.5.7)
77
+ rack (>= 1.0)
78
+ rails (3.0.9)
79
+ actionmailer (= 3.0.9)
80
+ actionpack (= 3.0.9)
81
+ activerecord (= 3.0.9)
82
+ activeresource (= 3.0.9)
83
+ activesupport (= 3.0.9)
84
+ bundler (~> 1.0)
85
+ railties (= 3.0.9)
86
+ railties (3.0.9)
87
+ actionpack (= 3.0.9)
88
+ activesupport (= 3.0.9)
89
+ rake (>= 0.8.7)
90
+ rdoc (~> 3.4)
91
+ thor (~> 0.14.4)
92
+ rake (0.9.2)
93
+ rd_find_by_param (0.1.1)
94
+ activerecord (~> 3.0)
95
+ activesupport (~> 3.0)
96
+ rd_resource_controller (1.0.1)
97
+ rd_unobtrusive_date_picker (0.1.0)
98
+ rdoc (3.9.2)
99
+ rubigen (1.5.6)
100
+ activesupport (>= 2.3.5)
101
+ i18n
102
+ spree_core (0.60.1)
103
+ activemerchant (= 1.15.0)
104
+ acts_as_list (= 0.1.2)
105
+ faker (= 0.9.5)
106
+ highline (= 1.5.1)
107
+ jquery-rails (= 0.2.6)
108
+ meta_search (= 1.0.5)
109
+ nested_set (= 1.6.6)
110
+ paperclip (= 2.3.11)
111
+ rails (= 3.0.9)
112
+ rd_find_by_param (= 0.1.1)
113
+ rd_resource_controller
114
+ rd_unobtrusive_date_picker (= 0.1.0)
115
+ state_machine (= 0.9.4)
116
+ stringex (= 1.0.3)
117
+ will_paginate (= 3.0.pre2)
118
+ state_machine (0.9.4)
119
+ stringex (1.0.3)
120
+ thor (0.14.6)
121
+ treetop (1.4.10)
122
+ polyglot
123
+ polyglot (>= 0.3.1)
124
+ tzinfo (0.3.29)
125
+ will_paginate (3.0.pre2)
126
+
127
+ PLATFORMS
128
+ ruby
129
+
130
+ DEPENDENCIES
131
+ braspag
132
+ spree_core
@@ -1,7 +1,7 @@
1
- class Gateway::Braspag < Gateway
1
+ class Gateway::SpreeBraspag < Gateway
2
2
  preference :merchant_id, :string
3
3
 
4
- def provider_class
4
+ def provider_class
5
5
  ActiveMerchant::Billing::BraspagGateway
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.platform = Gem::Platform::RUBY
3
3
  s.name = 'gonow_braspag'
4
- s.version = '1.0.1'
4
+ s.version = '1.0.2'
5
5
  s.summary = "Extension to use on braspag's service"
6
6
  s.description = "Extension to use on braspag's service"
7
7
  s.required_ruby_version = '>= 1.8.7'
@@ -17,4 +17,5 @@ Gem::Specification.new do |s|
17
17
  s.requirements << 'none'
18
18
 
19
19
  s.add_dependency('spree_core', '>= 0.60.1')
20
+ s.add_dependency('braspag')
20
21
  end
@@ -26,6 +26,31 @@ module ActiveMerchant
26
26
  end
27
27
  end
28
28
 
29
+ def authorize(money, creditcard, options = {})
30
+ order_options = {
31
+ :merchantId => merchant_id,
32
+ :orderId => options[:order_id],
33
+ :customerName => full_name_from(creditcard),
34
+ :amount => format_amount(options[:subtotal]),
35
+ :paymentMethod => code_for_brand_of(creditcard),
36
+ :holder => full_name_from(creditcard),
37
+ :cardNumber => creditcard.number,
38
+ :expiration => format_expiration_from(creditcard),
39
+ :securityCode => creditcard.verification_value,
40
+ :numberPayments => 1,
41
+ :typePayment => 0
42
+ }
43
+
44
+ authorize_response = gateway.authorize! order_options
45
+ debugger
46
+ if success?(authorize_response)
47
+ capture_response = gateway.capture! :merchantId => merchant_id, :orderId => options[:order_id] if success?(authorize_response)
48
+ Response.new success?(authorize_response), capture_response['message'], { :transaction_id => authorize_response['transactionId'] }, :authorization => authorize_response['authorisationNumber']
49
+ else
50
+ Response.new false, authorize_response['message']
51
+ end
52
+ end
53
+
29
54
  private
30
55
 
31
56
  def success?(response)
@@ -41,7 +66,7 @@ module ActiveMerchant
41
66
  end
42
67
 
43
68
  def code_for_brand_of(creditcard)
44
- case CreditCard.type? creditcard[:number]
69
+ case CreditCard.type? creditcard.number
45
70
  when 'visa' then 22
46
71
  when 'master' then 23
47
72
  when 'american_express' then 18
@@ -69,4 +94,4 @@ module ActiveMerchant
69
94
  end
70
95
  end
71
96
  end
72
- end
97
+ end
@@ -1,5 +1,7 @@
1
- require 'spree_core'
2
1
  require 'gonow_braspag_hooks'
2
+ require 'active_merchant/billing/gateways/braspag'
3
+ require 'braspag'
4
+ require 'ruby-debug'
3
5
 
4
6
  module GonowBraspag
5
7
  class Engine < Rails::Engine
@@ -10,8 +12,11 @@ module GonowBraspag
10
12
  Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
11
13
  Rails.env.production? ? require(c) : load(c)
12
14
  end
15
+
16
+ Gateway::SpreeBraspag.register
13
17
  end
14
18
 
19
+
15
20
  config.to_prepare &method(:activate).to_proc
16
21
  end
17
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gonow_braspag
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-04 00:00:00.000000000Z
12
+ date: 2011-08-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
16
- requirement: &2158804760 !ruby/object:Gem::Requirement
16
+ requirement: &2153985400 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,18 +21,32 @@ dependencies:
21
21
  version: 0.60.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2158804760
24
+ version_requirements: *2153985400
25
+ - !ruby/object:Gem::Dependency
26
+ name: braspag
27
+ requirement: &2153984980 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2153984980
25
36
  description: Extension to use on braspag's service
26
37
  email:
27
38
  executables: []
28
39
  extensions: []
29
40
  extra_rdoc_files: []
30
41
  files:
42
+ - .gitignore
43
+ - Gemfile
44
+ - Gemfile.lock
31
45
  - LICENSE
32
46
  - README.md
33
47
  - Rakefile
34
48
  - Versionfile
35
- - app/models/gateway/braspag.rb
49
+ - app/models/gateway/spree_braspag.rb
36
50
  - config/routes.rb
37
51
  - db/seeds.rb
38
52
  - gonow_braspag.gemspec