catarse_pagarme 2.14.0 → 2.14.1

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: 759be41182016de2403b4d8dda77eb30691dbd1f
4
- data.tar.gz: f161dd3654541d5ced3e5c0a7dd07dfb08fb82d0
3
+ metadata.gz: 23306e4f84f1866a86b3b2afa9e36d885447a6d3
4
+ data.tar.gz: eba54e8909cecd5fe595913fba13d7a215c64571
5
5
  SHA512:
6
- metadata.gz: a0c95c06bde334b295b76b41c5f739b9ddcd4e5c67a0267160e2ba52f0f68f88ccb046c1e7c52cc5f9604585d5bed4c4b79281428d0eb3839cb3dc0dd8735435
7
- data.tar.gz: a30bcc3414beebaf09ee900ffb777fbd7b16094bcd0188cac420b65b756b1dcbee22201e341d3ea45e787381f1b84d7369b3c378bba9032e2952b59453bdcf84
6
+ metadata.gz: 0ef4e604ce32df193d75eee9bc20e4e5b488ecd0a57ff265cfb883fd5d9e039b6b9062c7095fbcc86cf1a3c1226a245b5cd5789a2a42d92541b1643fd5248851
7
+ data.tar.gz: 9f1a29b1590b0432bbf9985cc311c40d6685ebe549f3516bcaf13c13b46adf3fa28e0fd342ff8c6556b6958611d83e379dbc7805d7845b6548b63e386751d3dc
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.14.0)
4
+ catarse_pagarme (2.14.1)
5
5
  countries (= 3.0.0)
6
6
  konduto-ruby (= 2.1.0)
7
7
  pagarme (= 2.1.4)
@@ -67,7 +67,7 @@ GEM
67
67
  factory_girl_rails (4.9.0)
68
68
  factory_girl (~> 4.9.0)
69
69
  railties (>= 3.0.0)
70
- faraday (0.17.0)
70
+ faraday (0.17.3)
71
71
  multipart-post (>= 1.2, < 3)
72
72
  globalid (0.4.2)
73
73
  activesupport (>= 4.2.0)
@@ -84,7 +84,7 @@ GEM
84
84
  mail (2.7.1)
85
85
  mini_mime (>= 0.1.1)
86
86
  method_source (0.9.0)
87
- mime-types (3.3)
87
+ mime-types (3.3.1)
88
88
  mime-types-data (~> 3.2015)
89
89
  mime-types-data (3.2019.1009)
90
90
  mini_mime (1.0.2)
@@ -103,7 +103,7 @@ GEM
103
103
  coderay (~> 1.1.0)
104
104
  method_source (~> 0.9.0)
105
105
  rack (1.6.10)
106
- rack-protection (2.0.7)
106
+ rack-protection (2.0.8.1)
107
107
  rack
108
108
  rack-test (0.6.3)
109
109
  rack (>= 1.0)
@@ -155,7 +155,7 @@ GEM
155
155
  rspec-mocks (~> 3.8.0)
156
156
  rspec-support (~> 3.8.0)
157
157
  rspec-support (3.8.0)
158
- sentry-raven (2.12.3)
158
+ sentry-raven (2.13.0)
159
159
  faraday (>= 0.7.6, < 1.0)
160
160
  sidekiq (5.2.7)
161
161
  connection_pool (~> 2.2, >= 2.2.2)
@@ -78,7 +78,11 @@ module CatarsePagarme
78
78
  end
79
79
 
80
80
  def document_number
81
- international? ? '00000000000' : contribution.user.cpf.gsub(/[-.\/_\s]/,'')
81
+ card_owner_document = contribution.card_owner_document.try(:gsub, /[-.\/_\s]/, '')
82
+ user_document = contribution.user.cpf.try(:gsub, /[-.\/_\s]/, '')
83
+ fallback_document = '00000000000'
84
+
85
+ card_owner_document || user_document || fallback_document
82
86
  end
83
87
 
84
88
  def phone_matches
@@ -25,11 +25,14 @@ module CatarsePagarme
25
25
  save_card = self.attributes.delete(:save_card)
26
26
 
27
27
  self.transaction = PagarMe::Transaction.new(
28
- amount: self.attributes[:amount],
29
- card_hash: self.attributes[:card_hash],
30
- capture: false,
31
- async: false,
32
- postback_url: self.attributes[:postback_url]
28
+ {
29
+ amount: self.attributes[:amount],
30
+ capture: false,
31
+ async: false,
32
+ postback_url: self.attributes[:postback_url],
33
+ installments: self.attributes[:installments],
34
+ soft_descriptor: self.attributes[:soft_descriptor]
35
+ }.merge(credit_card_identifier)
33
36
  )
34
37
 
35
38
  unless payment.update_attributes(gateway: 'Pagarme', payment_method: payment_method)
@@ -65,6 +68,14 @@ module CatarsePagarme
65
68
  @antifraud_wrapper ||= AntifraudOrderWrapper.new(self.attributes, self.transaction)
66
69
  end
67
70
 
71
+ def credit_card_identifier
72
+ if self.attributes[:card_hash].present?
73
+ { card_hash: self.attributes[:card_hash] }
74
+ else
75
+ { card_id: self.attributes[:card_id] }
76
+ end
77
+ end
78
+
68
79
  def save_user_credit_card
69
80
  card = self.transaction.card
70
81
 
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.14.0"
2
+ VERSION = "2.14.1"
3
3
  end
@@ -97,7 +97,13 @@ describe CatarsePagarme::CreditCardTransaction do
97
97
 
98
98
  describe '#authorize!' do
99
99
  let(:attributes) do
100
- { amount: 10, card_hash: 'capgojepaogejpeoajgpeaoj124pih3p4h32p', postback_url: 'https://example.com/postback' }
100
+ {
101
+ amount: 10,
102
+ card_hash: 'capgojepaogejpeoajgpeaoj124pih3p4h32p',
103
+ postback_url: 'https://example.com/postback',
104
+ installments: 2,
105
+ soft_descriptor: 'Catarse Test'
106
+ }
101
107
  end
102
108
 
103
109
  let(:transaction) do
@@ -106,8 +112,10 @@ describe CatarsePagarme::CreditCardTransaction do
106
112
  card_hash: attributes[:card_hash],
107
113
  capture: false,
108
114
  async: false,
109
- postback_url: attributes[:postback_url]
110
- )
115
+ postback_url: attributes[:postback_url],
116
+ installments: 2,
117
+ soft_descriptor: 'Catarse Test'
118
+ )
111
119
  end
112
120
 
113
121
  before do
@@ -122,7 +130,9 @@ describe CatarsePagarme::CreditCardTransaction do
122
130
  card_hash: attributes[:card_hash],
123
131
  capture: false,
124
132
  async: false,
125
- postback_url: attributes[:postback_url]
133
+ postback_url: attributes[:postback_url],
134
+ installments: attributes[:installments],
135
+ soft_descriptor: attributes[:soft_descriptor]
126
136
  }
127
137
 
128
138
  allow(PagarMe::Transaction).to receive(:new).with(transaction_attributes).and_return(transaction)
@@ -132,6 +142,16 @@ describe CatarsePagarme::CreditCardTransaction do
132
142
  expect(card_transaction.transaction).to eq transaction
133
143
  end
134
144
 
145
+ context 'when a saved credit card is used' do
146
+ let(:attributes) { { card_id: 'card_eaoj124pih3p4h32p' } }
147
+
148
+ it 'uses card id instead card hash' do
149
+ card_transaction.attributes = attributes
150
+
151
+ expect(card_transaction.send(:credit_card_identifier)).to eq(card_id: 'card_eaoj124pih3p4h32p')
152
+ end
153
+ end
154
+
135
155
  it 'updates payment gateway and payment_method' do
136
156
  card_transaction.authorize!
137
157
 
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.14.0
4
+ version: 2.14.1
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: 2019-12-04 00:00:00.000000000 Z
12
+ date: 2020-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: countries