catarse_pagarme 2.6.12 → 2.7.0
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 +4 -4
- data/Gemfile.lock +2 -2
- data/app/assets/javascripts/catarse_pagarme/payment_slip.js +1 -24
- data/app/controllers/catarse_pagarme/slip_controller.rb +3 -15
- data/app/models/catarse_pagarme/credit_card_transaction.rb +2 -1
- data/app/models/catarse_pagarme/slip_transaction.rb +0 -25
- data/app/views/catarse_pagarme/pagarme/review.html.slim +12 -20
- data/lib/catarse_pagarme/version.rb +1 -1
- data/spec/controllers/catarse_pagarme/slip_controller_spec.rb +25 -37
- data/spec/models/catarse_pagarme/bank_account_concern_spec.rb +1 -1
- data/spec/models/catarse_pagarme/slip_transaction_spec.rb +1 -13
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a7691442df6379211a0252d3dcc8202f1aefbe0
|
4
|
+
data.tar.gz: 4a028f6662ae40be7fa81384179aa2ed110b7597
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98ea1073b18d52d380b5d344be6601906e38747c932cccc9abb09945b817f23bd7348f79ff8099b21c27024596fb5dedf47f729e3469a2f242c135c527a30812
|
7
|
+
data.tar.gz: 6dedb4d53784d8538bd8540ce2707c550ef89c6122e2d835db46ecd6bf784f9b4222e604144749823b12b9df49f0c33341519c7a26a9fadd78e5873b17def90b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
catarse_pagarme (2.
|
4
|
+
catarse_pagarme (2.7.0)
|
5
5
|
pagarme (= 1.10.0)
|
6
6
|
rails (~> 4.0)
|
7
7
|
weekdays (>= 1.0.2)
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
slop (3.6.0)
|
107
107
|
sprockets (3.2.0)
|
108
108
|
rack (~> 1.0)
|
109
|
-
sprockets-rails (2.3.
|
109
|
+
sprockets-rails (2.3.2)
|
110
110
|
actionpack (>= 3.0)
|
111
111
|
activesupport (>= 3.0)
|
112
112
|
sprockets (>= 2.8, < 4.0)
|
@@ -18,15 +18,6 @@ App.views.Pagarme.addChild('PaymentSlip', _.extend({
|
|
18
18
|
this.$('#user_bank_account_attributes_name').brbanks();
|
19
19
|
},
|
20
20
|
|
21
|
-
validateName: function(field) {
|
22
|
-
if(field.val().length < 5 || field.val().length > 30){
|
23
|
-
$(field).trigger('invalid');
|
24
|
-
return false;
|
25
|
-
}
|
26
|
-
|
27
|
-
return true;
|
28
|
-
},
|
29
|
-
|
30
21
|
onContentClick: function() {
|
31
22
|
var thank_you = $('#project_review').data('thank-you-path');
|
32
23
|
|
@@ -51,21 +42,7 @@ App.views.Pagarme.addChild('PaymentSlip', _.extend({
|
|
51
42
|
this.$('#payment-slip-instructions').slideUp('slow');
|
52
43
|
that.parent.loader.show();
|
53
44
|
|
54
|
-
|
55
|
-
user: {
|
56
|
-
bank_account_attributes: {
|
57
|
-
bank_id: that.$('select#user_bank_account_attributes_bank_id').val(),
|
58
|
-
agency: that.$('input#user_bank_account_attributes_agency').val(),
|
59
|
-
agency_digit: that.$('input#user_bank_account_attributes_agency_digit').val(),
|
60
|
-
account: that.$('input#user_bank_account_attributes_account').val(),
|
61
|
-
account_digit: that.$('input#user_bank_account_attributes_account_digit').val(),
|
62
|
-
owner_name: that.$('input#user_bank_account_attributes_owner_name').val(),
|
63
|
-
owner_document: that.$('input#user_bank_account_attributes_owner_document').val()
|
64
|
-
}
|
65
|
-
}
|
66
|
-
};
|
67
|
-
|
68
|
-
$.post('/payment/pagarme/'+that.parent.contributionId+'/pay_slip.json', bankAccountAttributes, null, 'json').success(function(response){
|
45
|
+
$.post('/payment/pagarme/'+that.parent.contributionId+'/pay_slip.json',null, 'json').success(function(response){
|
69
46
|
parent.loader.hide();
|
70
47
|
if(response.payment_status == 'failed'){
|
71
48
|
that.message.find('.message-text').html(response.message);
|
@@ -4,7 +4,7 @@ module CatarsePagarme
|
|
4
4
|
class SlipController < CatarsePagarme::ApplicationController
|
5
5
|
|
6
6
|
def create
|
7
|
-
transaction = SlipTransaction.new(
|
7
|
+
transaction = SlipTransaction.new(slip_attributes, payment).charge!
|
8
8
|
|
9
9
|
render json: { boleto_url: transaction.boleto_url, payment_status: transaction.status }
|
10
10
|
rescue PagarMe::PagarMeError => e
|
@@ -12,7 +12,7 @@ module CatarsePagarme
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def update
|
15
|
-
transaction = SlipTransaction.new(
|
15
|
+
transaction = SlipTransaction.new(slip_attributes, payment).charge!
|
16
16
|
render text: transaction.boleto_url
|
17
17
|
end
|
18
18
|
|
@@ -32,19 +32,7 @@ module CatarsePagarme
|
|
32
32
|
name: payment.user.name
|
33
33
|
},
|
34
34
|
metadata: metadata_attributes
|
35
|
-
}
|
35
|
+
}
|
36
36
|
end
|
37
|
-
|
38
|
-
def permitted_attributes
|
39
|
-
attrs = ActionController::Parameters.new(slip_attributes)
|
40
|
-
attrs.permit(:boleto_expiration_date, :payment_method, :amount, :postback_url, metadata: [:key], customer: [:name, :email],
|
41
|
-
user: [
|
42
|
-
bank_account_attributes: [
|
43
|
-
:bank_id, :account, :account_digit, :agency,
|
44
|
-
:agency_digit, :owner_name, :owner_document
|
45
|
-
]
|
46
|
-
])
|
47
|
-
end
|
48
|
-
|
49
37
|
end
|
50
38
|
end
|
@@ -6,7 +6,8 @@ module CatarsePagarme
|
|
6
6
|
|
7
7
|
self.transaction = PagarMe::Transaction.new(self.attributes)
|
8
8
|
|
9
|
-
payment.update_attributes(
|
9
|
+
payment.update_attributes({
|
10
|
+
gateway: 'Pagarme', payment_method: payment_method})
|
10
11
|
payment.save
|
11
12
|
|
12
13
|
self.transaction.charge
|
@@ -1,40 +1,15 @@
|
|
1
1
|
module CatarsePagarme
|
2
2
|
class SlipTransaction < TransactionBase
|
3
|
-
def initialize(attributes, payment)
|
4
|
-
super
|
5
|
-
build_default_bank_account
|
6
|
-
end
|
7
|
-
|
8
3
|
def charge!
|
9
|
-
update_user_bank_account
|
10
|
-
|
11
4
|
self.transaction = PagarMe::Transaction.new(self.attributes)
|
12
|
-
|
13
5
|
self.transaction.charge
|
14
6
|
|
15
7
|
change_payment_state
|
16
|
-
|
17
8
|
self.transaction
|
18
9
|
end
|
19
10
|
|
20
11
|
def payment_method
|
21
12
|
PaymentType::SLIP
|
22
13
|
end
|
23
|
-
|
24
|
-
protected
|
25
|
-
|
26
|
-
def update_user_bank_account
|
27
|
-
if self.attributes.include?(:user)
|
28
|
-
self.user.update_attributes(self.attributes.delete(:user))
|
29
|
-
end
|
30
|
-
|
31
|
-
if self.user.errors.present?
|
32
|
-
raise ::PagarMe::PagarMeError.new(self.user.errors.full_messages.to_sentence)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def build_default_bank_account
|
37
|
-
self.user.build_bank_account unless self.user.bank_account
|
38
|
-
end
|
39
14
|
end
|
40
15
|
end
|
@@ -93,21 +93,6 @@
|
|
93
93
|
|
94
94
|
#payment_type_slip_section.payment_section.w-hidden
|
95
95
|
= simple_form_for current_user, url: 'javascript:void(0)' do |f|
|
96
|
-
.card.card-message.u-radius.zindex-10.fontsize-small.u-marginbottom-30
|
97
|
-
= t('projects.contributions.edit.payment_slip_disclaimer')
|
98
|
-
.formwrapper
|
99
|
-
.bank_accounts
|
100
|
-
= f.simple_fields_for :bank_account do |bank_form|
|
101
|
-
.w-row
|
102
|
-
= bank_form.input :bank_id, as: :select, collection: Bank.order(:code, :name).to_collection, wrapper_html: {class: 'w-col w-col-12'}, input_html: {required: true}, validation_text: true
|
103
|
-
.w-row
|
104
|
-
= bank_form.input :agency, as: :tel, wrapper_html: {class: 'w-col w-sub-col-middle w-col-4 w-col-small-8 w-col-tiny-8'}, input_html: {required: true}, validation_text: true
|
105
|
-
= bank_form.input :agency_digit, as: :tel, wrapper_html: {class: 'w-col w-sub-col-middle w-sub-col w-col-2 w-col-small-4 w-col-tiny-4'}
|
106
|
-
= bank_form.input :account, as: :tel, wrapper_html: {class: 'w-col w-sub-col-middle w-col-4 w-col-small-8 w-col-tiny-8'}, input_html: {required: true}, validation_text: true
|
107
|
-
= bank_form.input :account_digit, as: :tel, wrapper_html: {class: 'w-col w-col-2 w-col-small-4 w-col-tiny-4'}, input_html: {required: true}, validation_text: true
|
108
|
-
.w-row
|
109
|
-
= bank_form.input :owner_name, as: :string, input_html: { required: true, value: bank_form.object.owner_name || current_user.name }, wrapper_html: {class: 'w-col w-sub-col w-col-6'}, validation_text: true
|
110
|
-
= bank_form.input :owner_document, as: :tel, input_html: { required: true, data: { :'validate-cpf-cnpj' => true }, value: (bank_form.object.owner_document || current_user.cpf) }, wrapper_html: {class: 'w-col w-col-6'}, validation_text: true
|
111
96
|
.w-row
|
112
97
|
.w-col.w-col-12
|
113
98
|
.payment-error-message.card.card-error.u-radius.zindex-10.u-marginbottom-30.w-hidden
|
@@ -117,9 +102,16 @@
|
|
117
102
|
.w-col.w-col-12
|
118
103
|
#payment-slip-link.card.card-message.fontsize-small.u-radius.u-marginbottom-30.zindex-10.w-hidden
|
119
104
|
.link_content.fontsize-small
|
120
|
-
.fontsize-small
|
105
|
+
.fontsize-small= t('projects.contributions.edit.review_slip_email')
|
121
106
|
.w-row
|
122
|
-
.w-col.w-col-
|
123
|
-
|
124
|
-
|
125
|
-
|
107
|
+
.w-col.w-col-12
|
108
|
+
.u-margintop-30.u-marginbottom-60.u-radius.card-big.card
|
109
|
+
- expiration_date = (CatarsePagarme.configuration.slip_week_day_interval || 2).weekdays_from_now
|
110
|
+
.fontsize-small.u-marginbottom-20= t('projects.contributions.edit.slip_expiration', date: l(expiration_date.to_date))
|
111
|
+
.fontsize-small.u-marginbottom-40= t('projects.contributions.edit.slip_message')
|
112
|
+
|
113
|
+
.w-row
|
114
|
+
.w-col.w-col-8.w-col-offset-2
|
115
|
+
#card-loading.loader.u-text-center.w-col.w-col-12.u-marginbottom-30 = image_tag "catarse_bootstrap/loader.gif"
|
116
|
+
= submit_tag t('projects.contributions.review.form.labels.build_boleto'), :class => 'btn btn-large u-marginbottom-20', :id => "build_boleto"
|
117
|
+
= render partial: 'terms'
|
@@ -12,13 +12,23 @@ describe CatarsePagarme::SlipController do
|
|
12
12
|
let(:credit_card) { create(:credit_card, subscription_id: '1542')}
|
13
13
|
|
14
14
|
describe 'PATCH update' do
|
15
|
-
|
15
|
+
context 'without an user' do
|
16
|
+
let(:user) { nil }
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
it 'should raise a error' do
|
19
|
+
expect {
|
20
|
+
patch :update, locale: :pt, id: contribution.id, use_route: 'catarse_pagarme'
|
21
|
+
}.to raise_error('invalid user')
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
|
-
context 'with
|
25
|
+
context 'with an user' do
|
26
|
+
let(:user) { payment.user }
|
27
|
+
|
28
|
+
before do
|
29
|
+
patch :update, locale: :pt, id: contribution.id, use_route: 'catarse_pagarme'
|
30
|
+
end
|
31
|
+
|
22
32
|
it 'boleto_url should be filled' do
|
23
33
|
expect(response.body).to be_present
|
24
34
|
end
|
@@ -39,42 +49,20 @@ describe CatarsePagarme::SlipController do
|
|
39
49
|
context 'with an user' do
|
40
50
|
let(:user) { payment.user }
|
41
51
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
} } }
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'boleto_url should be filled' do
|
52
|
-
expect(ActiveSupport::JSON.decode(response.body)['boleto_url']).not_to be_nil
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'payment_status should be waiting_payment' do
|
56
|
-
expect(ActiveSupport::JSON.decode(response.body)['payment_status']).to eq 'waiting_payment'
|
57
|
-
end
|
52
|
+
before do
|
53
|
+
post :create, {
|
54
|
+
locale: :pt, id: contribution.id, use_route: 'catarse_pagarme',
|
55
|
+
user: { bank_account_attributes: {
|
56
|
+
bank_id: Bank.first.id, agency: '1', agency_digit: '1', account: '1', account_digit: '1', owner_name: 'foo', owner_document: '1'
|
57
|
+
} } }
|
58
58
|
end
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
before do
|
64
|
-
post :create, { locale: :pt, id: contribution.id, use_route: 'catarse_pagarme', user: { bank_account_attributes: { owner_name: '' } } }
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'boleto_url should be nil' do
|
68
|
-
expect(ActiveSupport::JSON.decode(response.body)['boleto_url']).to be_nil
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'payment_status should be failed' do
|
72
|
-
expect(ActiveSupport::JSON.decode(response.body)['payment_status']).to eq 'failed'
|
73
|
-
end
|
60
|
+
it 'boleto_url should be filled' do
|
61
|
+
expect(ActiveSupport::JSON.decode(response.body)['boleto_url']).not_to be_nil
|
62
|
+
end
|
74
63
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
64
|
+
it 'payment_status should be waiting_payment' do
|
65
|
+
expect(ActiveSupport::JSON.decode(response.body)['payment_status']).to eq 'waiting_payment'
|
78
66
|
end
|
79
67
|
end
|
80
68
|
end
|
@@ -25,12 +25,6 @@ describe CatarsePagarme::SlipTransaction do
|
|
25
25
|
payment_method: 'boleto',
|
26
26
|
amount: payment.pagarme_delegator.value_for_transaction,
|
27
27
|
postback_url: 'http://test.foo'
|
28
|
-
}, user: {
|
29
|
-
bank_account_attributes: {
|
30
|
-
bank_id: 1, agency: '1', agency_digit: '1',
|
31
|
-
account: '1', account_digit: '1', owner_name: 'foo',
|
32
|
-
owner_document: 'bar'
|
33
|
-
}
|
34
28
|
}
|
35
29
|
}
|
36
30
|
end
|
@@ -39,12 +33,8 @@ describe CatarsePagarme::SlipTransaction do
|
|
39
33
|
{
|
40
34
|
slip_payment: {
|
41
35
|
payment_method: 'boleto',
|
42
|
-
amount:
|
36
|
+
amount: nil,
|
43
37
|
postback_url: 'http://test.foo'
|
44
|
-
}, user: {
|
45
|
-
bank_account_attributes: {
|
46
|
-
owner_name: ''
|
47
|
-
}
|
48
38
|
}
|
49
39
|
}
|
50
40
|
end
|
@@ -76,8 +66,6 @@ describe CatarsePagarme::SlipTransaction do
|
|
76
66
|
|
77
67
|
context "with valid attributes" do
|
78
68
|
before do
|
79
|
-
slip_transaction.should_receive(:update_user_bank_account).and_call_original
|
80
|
-
slip_transaction.user.should_receive(:update_attributes).and_return(true)
|
81
69
|
payment.should_receive(:update_attributes).at_least(1).and_call_original
|
82
70
|
PagarMe::Transaction.should_receive(:find_by_id).with(pagarme_transaction.id).and_return(pagarme_transaction)
|
83
71
|
CatarsePagarme::PaymentDelegator.any_instance.should_receive(:change_status_by_transaction).with('paid')
|
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.
|
4
|
+
version: 2.7.0
|
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: 2015-06-
|
12
|
+
date: 2015-06-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|