catarse_pagarme 2.9.8 → 2.9.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 539f0a1d892950356a3905c81128a24bd4adbc24
4
- data.tar.gz: ecc70fd87f7c736542efac872129ca7642311801
3
+ metadata.gz: 716842fae1e53a63a7b9ce00c580b3f3e313e276
4
+ data.tar.gz: d62b246e987cedff38ce634a244ea7730e39aacb
5
5
  SHA512:
6
- metadata.gz: e83a89104df7abfbadf1eb9ae1b88f3c1d5cbf15eb502dc24d3633371e7b7b7e39fbfcf2a5948e5b5e0c38b1143a111110ba08f2b487380d3a17034a70ff6cb0
7
- data.tar.gz: 65903c85d65efbaccb06b1aaebd929b805f44967392b39bd87fd730b5c1be625825f385b6d7ed13de1362591d07353bbe94d2585f8b59c0656ad220e3c6359b6
6
+ metadata.gz: 593b4892adca5e56921e6d8cba2a1b3c46a29836c86a6e324c21efb79ea8920d16437d7b38c23a454d718d83151c39864cb3314a1b2980911c1a7a15039ad14e
7
+ data.tar.gz: a58b9621ed0a8ce3b4b2d4dbcbc4d60341b7647362b704569dd0e4dc45a1049880d15555e62807648cc9e75626992189d597368d564405992733a4fe7ee9e575
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.9.8)
4
+ catarse_pagarme (2.9.9)
5
5
  pagarme (= 2.1.3)
6
6
  rails (~> 4.0)
7
7
  sidekiq
@@ -12,6 +12,14 @@ module CatarsePagarme
12
12
  render json: { payment_status: 'failed', message: e.message }
13
13
  end
14
14
 
15
+ def get_installment_json
16
+ render json: installments_for_json.to_json
17
+ end
18
+
19
+ def get_encryption_key_json
20
+ render json: { key: CatarsePagarme.configuration.ecr_key }
21
+ end
22
+
15
23
  protected
16
24
 
17
25
  def credit_card_attributes
@@ -81,5 +89,23 @@ module CatarsePagarme
81
89
  end
82
90
  end
83
91
 
92
+ def installments_for_json
93
+ if contribution.value.to_f >= CatarsePagarme.configuration.minimum_value_for_installment.to_f
94
+ project = payment.project
95
+ installments = payment.pagarme_delegator.get_installments['installments']
96
+ collection = installments.map do |installment|
97
+ installment_number = installment[0].to_i
98
+ if installment_number <= (project.try(:total_installments) || CatarsePagarme.configuration.max_installments.to_i)
99
+ amount = installment[1]['installment_amount'] / 100.0
100
+
101
+ {amount: amount, number: installment_number}
102
+ end
103
+ end
104
+ else
105
+ collection = [{amount: payment.value, number: 1}]
106
+ end
107
+ collection.compact
108
+ end
109
+
84
110
  end
85
111
  end
data/config/routes.rb CHANGED
@@ -5,6 +5,8 @@ CatarsePagarme::Engine.routes.draw do
5
5
  get :review
6
6
  get :slip_data, to: 'slip#slip_data'
7
7
  get :second_slip, to: 'slip#update'
8
+ get :get_installment, to: 'credit_cards#get_installment_json'
9
+ get :get_encryption_key, to: 'credit_cards#get_encryption_key_json'
8
10
  post :pay_credit_card, to: 'credit_cards#create'
9
11
  post :pay_slip, to: 'slip#create'
10
12
  end
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.9.8"
2
+ VERSION = "2.9.9"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catarse_pagarme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.8
4
+ version: 2.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antônio Roberto Silva
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-13 00:00:00.000000000 Z
12
+ date: 2016-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails