pagarme 1.9.4 → 1.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b76b03abe5cdc463af38c4885cb4986b794a17a1
4
- data.tar.gz: 3c3a7dce4fabb033c9737b451043abe2b1d7524c
3
+ metadata.gz: 8e0e00753c649eaab912a05e42c3761d7a64e714
4
+ data.tar.gz: 04c7e8a5d52b5d22bf0fa6a02031771984e2f6f8
5
5
  SHA512:
6
- metadata.gz: 8dfc8b1fc0a6d0f46126dfe5a424abc67dc051e0d348f699ddf868bb07b826f02e2d922fa356fcfe8aff0d4fb6c555e086160a613dfc0128ca4680a282aee561
7
- data.tar.gz: c5b547b7fc14e56e529a92308dac533c793da8e634861e435fc611737891b7ce32235a715ec134007389361fc89da96208a631b9ea47ac87e51bfb0f456aa1b4
6
+ metadata.gz: 7135b0716c80d52da03da0f219f075de72b4f334098549051675e0826d6f9047217fcbee1bf4bae6c54aedfc295edeb53d9b41c77f2f0a3789476a0cac29eaa7
7
+ data.tar.gz: b9188fa4cd9b690754bffe96abf9e66daf8a99f3975e32ca4a277732959e57e85bfd32afadb74ba57729e5c4a99998d1ab7ba2d6eda60221eb5e9c66138a3e19
data/.gitignore CHANGED
@@ -13,6 +13,7 @@ test/version_tmp
13
13
  tmp
14
14
  *.swp
15
15
  vimsession
16
+ Gemfile.lock
16
17
 
17
18
  # YARD artifacts
18
19
  .yardoc
@@ -3,8 +3,6 @@ require File.join(File.dirname(__FILE__), '..', 'pagarme')
3
3
 
4
4
  module PagarMe
5
5
  class Subscription < TransactionCommon
6
-
7
-
8
6
  def create
9
7
  if self.plan
10
8
  self.plan_id = plan.id
@@ -33,7 +31,7 @@ module PagarMe
33
31
  request = PagarMe::Request.new(self.url + '/transactions', 'POST')
34
32
  request.parameters = {
35
33
  :amount => amount,
36
- :installments => installments
34
+ :installments => installments
37
35
  }
38
36
  response = request.run
39
37
 
@@ -9,72 +9,16 @@ module PagarMe
9
9
  self.payment_method = 'credit_card' unless self.payment_method
10
10
  self.installments = 1 unless self.installments
11
11
  self.status = 'local' unless self.status
12
- before_set_filter :amount, :format_amount
13
12
  end
14
13
 
15
14
  def create
16
- validation_error = self.card_hash ? nil : validate
17
15
  self.card_hash = generate_card_hash unless self.card_hash
18
- unset_creditcard_information
19
- super
20
- end
21
-
22
- def unset_creditcard_information
23
16
  self.card_number = nil
24
17
  self.card_holder_name = nil
25
18
  self.card_expiration_year = nil
26
19
  self.card_expiration_month = nil
27
20
  self.card_cvv = nil
28
- end
29
-
30
- def is_valid_credit_card(card)
31
- s1 = s2 = 0
32
- card.to_s.reverse.chars.each_slice(2) do |odd, even|
33
- s1 += odd.to_i
34
-
35
- double = even.to_i * 2
36
- double -= 9 if double >= 10
37
- s2 += double
38
- end
39
- (s1 + s2) % 10 == 0
40
- end
41
-
42
- def validate
43
- error = PagarMeError.new
44
- if self.payment_method == 'credit_card'
45
- if !self.card_number || self.card_number.to_s.length > 20 || !is_valid_credit_card(self.card_number.to_s)
46
- error.errors << PagarMeError.new("Número do cartão inválido.", 'card_number')
47
- end
48
- if !self.card_holder_name || !self.card_holder_name || self.card_holder_name.length == 0
49
- error.errors << PagarMeError.new("Nome do portador inválido.", 'card_holder_name')
50
- end
51
- if !self.card_expiration_month || self.card_expiration_month.to_i <= 0 || self.card_expiration_month.to_i > 12
52
- error.errors << PagarMeError.new("Mês de expiração inválido.", 'card_expiration_date')
53
- end
54
- if !self.card_expiration_year || self.card_expiration_year.to_i <= 0
55
- error.errors << PagarMeError.new("Ano de expiração inválido.", 'card_expiration_date')
56
- end
57
- if !self.card_cvv || self.card_cvv.to_s.length < 3 || self.card_cvv.to_s.length > 4
58
- error.errors << PagarMeError.new("Código de segurança inválido.", 'card_cvv')
59
- end
60
- end
61
- if(error.errors.any?)
62
- error.message = error.errors.map {|e| e.message}
63
- error.message = error.message.join(',')
64
- raise error
65
- else
66
- nil
67
- end
68
- end
69
-
70
- def format_amount(amount)
71
- if amount.kind_of?(String)
72
- value = amount.gsub(/\./, "")
73
- value = value.strip
74
- value = value.match(/\d+/)[0]
75
- amount = value
76
- end
77
- amount
21
+ super
78
22
  end
79
23
 
80
24
  def card_data_parameters
@@ -89,9 +33,15 @@ module PagarMe
89
33
  def generate_card_hash
90
34
  request = PagarMe::Request.new("/transactions/card_hash_key", 'GET')
91
35
  response = request.run
36
+ card_data = {
37
+ :card_number => self.card_number,
38
+ :card_holder_name => self.card_holder_name,
39
+ :card_expiration_date => "#{self.card_expiration_month}#{self.card_expiration_year}",
40
+ :card_cvv => self.card_cvv
41
+ }
92
42
 
93
43
  public_key = OpenSSL::PKey::RSA.new(response['public_key'])
94
- ret = "#{response['id']}_#{Base64.strict_encode64(public_key.public_encrypt(card_data_parameters.to_params))}"
44
+ ret = "#{response['id']}_#{Base64.strict_encode64(public_key.public_encrypt(card_data.to_params))}"
95
45
  end
96
46
  end
97
47
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "pagarme"
7
- spec.version = "1.9.4"
7
+ spec.version = "1.9.5"
8
8
  spec.authors = ["Pedro Franceschi", "Henrique Dubugras"]
9
9
  spec.email = ["pedrohfranceschi@gmail.com", "henrique@pagar.me"]
10
10
  spec.description = %q{Pagar.me's ruby gem}
@@ -82,13 +82,6 @@ module PagarMe
82
82
  assert transaction.status == 'refunded'
83
83
  end
84
84
 
85
- should 'should allow transactions with R$ amount' do
86
- transaction = test_transaction
87
- transaction.amount = 'R$ 10.00'
88
- transaction.charge
89
- assert transaction.amount == 1000
90
- end
91
-
92
85
  should 'validate invalid transaction' do
93
86
 
94
87
  #Test invalid card_number
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagarme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.4
4
+ version: 1.9.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Franceschi
@@ -9,90 +9,90 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-08-18 00:00:00.000000000 Z
12
+ date: 2014-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: shoulda
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - ~>
46
+ - - "~>"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 3.4.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ~>
53
+ - - "~>"
54
54
  - !ruby/object:Gem::Version
55
55
  version: 3.4.0
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: test-unit
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: multi_json
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  description: Pagar.me's ruby gem
@@ -103,10 +103,9 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
- - .gitignore
107
- - .travis.yml
106
+ - ".gitignore"
107
+ - ".travis.yml"
108
108
  - Gemfile
109
- - Gemfile.lock
110
109
  - README.md
111
110
  - Rakefile
112
111
  - certs/public_key.pem
@@ -140,12 +139,12 @@ require_paths:
140
139
  - lib
141
140
  required_ruby_version: !ruby/object:Gem::Requirement
142
141
  requirements:
143
- - - '>='
142
+ - - ">="
144
143
  - !ruby/object:Gem::Version
145
144
  version: '0'
146
145
  required_rubygems_version: !ruby/object:Gem::Requirement
147
146
  requirements:
148
- - - '>='
147
+ - - ">="
149
148
  - !ruby/object:Gem::Version
150
149
  version: '0'
151
150
  requirements: []
@@ -1,50 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- pagarme (1.8)
5
- multi_json
6
- rest-client
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- activesupport (4.0.0)
12
- i18n (~> 0.6, >= 0.6.4)
13
- minitest (~> 4.2)
14
- multi_json (~> 1.3)
15
- thread_safe (~> 0.1)
16
- tzinfo (~> 0.3.37)
17
- atomic (1.1.14)
18
- bourne (1.5.0)
19
- mocha (>= 0.13.2, < 0.15)
20
- i18n (0.6.5)
21
- metaclass (0.0.1)
22
- mime-types (2.0)
23
- minitest (4.7.5)
24
- mocha (0.14.0)
25
- metaclass (~> 0.0.1)
26
- multi_json (1.8.2)
27
- rake (10.1.0)
28
- rest-client (1.6.7)
29
- mime-types (>= 1.16)
30
- shoulda (3.4.0)
31
- shoulda-context (~> 1.0, >= 1.0.1)
32
- shoulda-matchers (~> 1.0, >= 1.4.1)
33
- shoulda-context (1.1.5)
34
- shoulda-matchers (1.5.6)
35
- activesupport (>= 3.0.0)
36
- bourne (~> 1.3)
37
- test-unit (2.5.5)
38
- thread_safe (0.1.3)
39
- atomic
40
- tzinfo (0.3.38)
41
-
42
- PLATFORMS
43
- ruby
44
-
45
- DEPENDENCIES
46
- bundler (~> 1.3)
47
- pagarme!
48
- rake
49
- shoulda (~> 3.4.0)
50
- test-unit