catarse_moip 2.4.0 → 3.0.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 -3
- data/app/assets/javascripts/catarse_moip/moip_form.js +16 -11
- data/app/assets/javascripts/catarse_moip/payment_card.js +7 -27
- data/app/assets/javascripts/catarse_moip/payment_slip.js +1 -9
- data/app/assets/javascripts/catarse_moip/user_document.js +11 -10
- data/app/controllers/catarse_moip/moip_controller.rb +1 -1
- data/app/views/catarse_moip/moip/_terms.html.slim +6 -0
- data/app/views/catarse_moip/moip/review.html.slim +91 -101
- data/catarse_moip.gemspec +0 -1
- data/config/initializers/moip.rb +0 -10
- data/lib/catarse_moip.rb +0 -2
- data/lib/catarse_moip/payment_engine.rb +3 -3
- data/lib/catarse_moip/version.rb +1 -1
- metadata +3 -17
- data/app/models/catarse_moip/v2/refund.rb +0 -121
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef96e5da1f2270198e6416796385168671fcaf34
|
4
|
+
data.tar.gz: ef660e2c1e1eb6cc085ba61883be6f14bfbf3e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1138927731e9d52691ce29951817d66e07012b957ca023fdea2e2ae59d38377c271644be3f6fda807885f8a85265aae880a9547cf6742c65895a099d0c86592
|
7
|
+
data.tar.gz: 36be1fd0495715889a6f368c8a3da463c72ecdf0d82dbefbcb0786d2447a7754b6e1f78a7d2316d9a93546bb6faf5cfc1d1e858a6ceeddbbfe965b98bbb297ed
|
data/Gemfile.lock
CHANGED
@@ -10,9 +10,8 @@ GIT
|
|
10
10
|
PATH
|
11
11
|
remote: .
|
12
12
|
specs:
|
13
|
-
catarse_moip (
|
13
|
+
catarse_moip (3.0.0)
|
14
14
|
enumerate_it
|
15
|
-
httparty
|
16
15
|
libxml-ruby (~> 2.6.0)
|
17
16
|
rails (~> 4.0)
|
18
17
|
|
@@ -99,7 +98,7 @@ GEM
|
|
99
98
|
rspec-core (~> 2.14.0)
|
100
99
|
rspec-expectations (~> 2.14.0)
|
101
100
|
rspec-mocks (~> 2.14.0)
|
102
|
-
sprockets (2.12.
|
101
|
+
sprockets (2.12.2)
|
103
102
|
hike (~> 1.2)
|
104
103
|
multi_json (~> 1.0)
|
105
104
|
rack (~> 1.0)
|
@@ -1,6 +1,11 @@
|
|
1
|
-
App.addChild('MoipForm', {
|
1
|
+
App.addChild('MoipForm', _.extend({
|
2
2
|
el: 'form.moip',
|
3
3
|
|
4
|
+
events: {
|
5
|
+
'blur input:not(#payment_card_cpf):not(#user_document_payment_slip)' : 'checkInput'
|
6
|
+
},
|
7
|
+
|
8
|
+
|
4
9
|
getMoipToken: function(onSuccess){
|
5
10
|
var that = this;
|
6
11
|
if($('#MoipWidget').length > 0) {
|
@@ -40,9 +45,8 @@ App.addChild('MoipForm', {
|
|
40
45
|
if(response_data.Codigo == 914){
|
41
46
|
response_data.Mensagem += '. Tente <a href="javascript:window.location.reload();">recarregar a página</a> e repetir a operação de pagamento.';
|
42
47
|
}
|
43
|
-
this.message.find('
|
44
|
-
this.message.
|
45
|
-
$('input[type="submit"]').removeAttr('disabled').show();
|
48
|
+
this.message.find('.message-text').html(response_data.Mensagem);
|
49
|
+
this.message.slideDown('slow');
|
46
50
|
},
|
47
51
|
|
48
52
|
checkoutSuccessful: function(data) {
|
@@ -56,10 +60,10 @@ App.addChild('MoipForm', {
|
|
56
60
|
|
57
61
|
// Go on otherwise
|
58
62
|
if(data.url && $('#payment_type_cards_section').css('display') != 'block') {
|
59
|
-
var link = $('<a target="__blank">
|
63
|
+
var link = $('<a class="alt-link" target="__blank">Clique aqui para ver o boleto e completar o pagamento.</a>')
|
60
64
|
link.attr('href', data.url);
|
61
|
-
$('.link_content
|
62
|
-
$('
|
65
|
+
$('.link_content').empty().html(link);
|
66
|
+
$('#payment-slip-link').slideDown('slow');
|
63
67
|
}
|
64
68
|
else {
|
65
69
|
var thank_you = $('#project_review').data('thank-you-path');
|
@@ -74,14 +78,15 @@ App.addChild('MoipForm', {
|
|
74
78
|
},
|
75
79
|
|
76
80
|
activate: function(){
|
77
|
-
this.message = this.$('.
|
81
|
+
this.message = this.$('.payment-error-message');
|
78
82
|
this.contributionId = $('input#contribution_id').val();
|
79
|
-
this.projectId = $('input#
|
83
|
+
this.projectId = $('input#contribution_project_id').val();
|
80
84
|
|
81
|
-
this.loader = this.$('.loader');
|
85
|
+
this.loader = this.$('.loader img');
|
82
86
|
|
83
87
|
window.checkoutSuccessful = _.bind(this.checkoutSuccessful, this);
|
84
88
|
window.checkoutFailure = _.bind(this.checkoutFailure, this);
|
89
|
+
this.setupForm();
|
85
90
|
}
|
86
|
-
});
|
91
|
+
}, Skull.Form));
|
87
92
|
|
@@ -2,19 +2,15 @@ App.views.MoipForm.addChild('PaymentCard', _.extend({
|
|
2
2
|
el: '#payment_type_cards_section',
|
3
3
|
|
4
4
|
events: {
|
5
|
-
'keyup input[type="text"]' : 'creditCardInputValidator',
|
6
5
|
'keyup #payment_card_number' : 'onKeyupPaymentCardNumber',
|
7
|
-
'click
|
6
|
+
'click #credit_card_submit' : 'onSubmit',
|
8
7
|
'keyup #payment_card_cpf' : 'onUserDocumentKeyup'
|
9
8
|
},
|
10
9
|
|
11
10
|
activate: function(options){
|
12
11
|
// Set credit card fields masks
|
13
12
|
this.moipForm = this.parent;
|
14
|
-
|
15
|
-
this.$('input#payment_card_birth').mask('99/99/9999');
|
16
|
-
this.$('input#payment_card_cpf').mask("999.999.999-99");
|
17
|
-
this.$('input#payment_card_phone').mask("(99) 9999-9999?9");
|
13
|
+
window.app.maskAllElements();
|
18
14
|
},
|
19
15
|
|
20
16
|
onKeyupPaymentCardNumber: function(e){
|
@@ -24,7 +20,11 @@ App.views.MoipForm.addChild('PaymentCard', _.extend({
|
|
24
20
|
onSubmit: function(e) {
|
25
21
|
var that = this;
|
26
22
|
e.preventDefault();
|
27
|
-
|
23
|
+
|
24
|
+
if(!that.moipForm.validate()){
|
25
|
+
return false;
|
26
|
+
}
|
27
|
+
|
28
28
|
that.moipForm.loader.show();
|
29
29
|
|
30
30
|
// Get token and send payment
|
@@ -50,26 +50,6 @@ App.views.MoipForm.addChild('PaymentCard', _.extend({
|
|
50
50
|
});
|
51
51
|
},
|
52
52
|
|
53
|
-
hasContent: function(element) {
|
54
|
-
var value = $(element).val().replace(/[\-\.\_\/\s]/g, '');
|
55
|
-
if(value && value.length > 0){
|
56
|
-
$(element).addClass("ok").removeClass("error")
|
57
|
-
return true
|
58
|
-
} else {
|
59
|
-
$(element).addClass("error").removeClass("ok")
|
60
|
-
return false
|
61
|
-
}
|
62
|
-
},
|
63
|
-
|
64
|
-
creditCardInputValidator: function() {
|
65
|
-
var that = this;
|
66
|
-
var all_ok = true;
|
67
|
-
$.each($('#payment_type_cards_section input[type="text"]'), function(i, item){
|
68
|
-
all_ok = that.hasContent(item);
|
69
|
-
});
|
70
|
-
$('input#credit_card_submit').attr('disabled', !all_ok);
|
71
|
-
},
|
72
|
-
|
73
53
|
getCardFlag: function(number) {
|
74
54
|
var cc = (number + '').replace(/\s/g, ''); //remove space
|
75
55
|
|
@@ -4,24 +4,16 @@ App.views.MoipForm.addChild('PaymentSlip', _.extend({
|
|
4
4
|
events: {
|
5
5
|
'click input#build_boleto' : 'onBuildBoletoClick',
|
6
6
|
'click .link_content a' : 'onContentClick',
|
7
|
-
'keyup #user_document_payment_slip' : '
|
8
|
-
},
|
9
|
-
|
10
|
-
onUserDocumentPaymentSlipKeyup: function(e){
|
11
|
-
var $documentField = $(e.currentTarget);
|
12
|
-
this.onUserDocumentKeyup(e);
|
13
|
-
$('input#build_boleto').attr('disabled', !$documentField.hasClass('ok'));
|
7
|
+
'keyup #user_document_payment_slip' : 'onUserDocumentKeyup'
|
14
8
|
},
|
15
9
|
|
16
10
|
activate: function(options){
|
17
11
|
this.moipForm = this.parent;
|
18
|
-
this.$('input#user_document_payment_slip').mask("999.999.999-99");
|
19
12
|
},
|
20
13
|
|
21
14
|
onBuildBoletoClick: function(e){
|
22
15
|
var that = this;
|
23
16
|
e.preventDefault();
|
24
|
-
$(e.currentTarget).hide();
|
25
17
|
that.moipForm.loader.show();
|
26
18
|
|
27
19
|
// Get token and send payment
|
@@ -14,13 +14,14 @@ App.views.MoipForm.UserDocument = {
|
|
14
14
|
var resultCnpj = this.validateCnpj(documentNumber.replace(/[\/.\-\_ ]/g, ''));
|
15
15
|
var numberLength = documentNumber.replace(/[.\-\_ ]/g, '').length
|
16
16
|
if(numberLength > 10) {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
if($documentField.attr('id') != 'payment_card_cpf'){
|
18
|
+
if(numberLength == 11) {$documentField.mask('999.999.999-99?999'); }//CPF
|
19
|
+
else if(numberLength == 14 ){$documentField.mask('99.999.999/9999-99');}//CNPJ
|
20
|
+
if(numberLength != 14 || numberLength != 11){ $documentField.unmask()}
|
21
|
+
}
|
22
22
|
|
23
|
-
|
23
|
+
if(resultCpf || resultCnpj) {
|
24
|
+
$('[data-error-for=' + $documentField.prop('id') + ']').hide();
|
24
25
|
$documentField.addClass('ok').removeClass('error');
|
25
26
|
|
26
27
|
$.ajax({
|
@@ -30,12 +31,12 @@ App.views.MoipForm.UserDocument = {
|
|
30
31
|
});
|
31
32
|
|
32
33
|
} else {
|
33
|
-
$documentField.
|
34
|
+
$documentField.trigger('invalid');
|
34
35
|
}
|
35
36
|
}
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
else{
|
38
|
+
$documentField.trigger('invalid')
|
39
|
+
}
|
39
40
|
|
40
41
|
},
|
41
42
|
|
@@ -137,7 +137,7 @@ module CatarseMoip
|
|
137
137
|
case params[:status_pagamento].to_i
|
138
138
|
when TransactionStatus::PROCESS
|
139
139
|
payment_notification.deliver_process_notification
|
140
|
-
when TransactionStatus::AUTHORIZED
|
140
|
+
when TransactionStatus::AUTHORIZED
|
141
141
|
contribution.confirm! unless contribution.confirmed?
|
142
142
|
when TransactionStatus::WRITTEN_BACK, TransactionStatus::REFUNDED
|
143
143
|
contribution.refund! unless contribution.refunded?
|
@@ -1,107 +1,97 @@
|
|
1
1
|
= javascript_include_tag 'catarse_moip'
|
2
2
|
#catarse_moip_form
|
3
|
-
= form_tag '
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
=
|
13
|
-
|
14
|
-
|
15
|
-
/
|
16
|
-
= radio_button_tag 'payment_type', "account"
|
17
|
-
= label_tag :payment_type_account, 'Débito em Conta', :class => "account"
|
18
|
-
|
3
|
+
= form_tag 'jaascript:void(0);', :class => 'moip' do
|
4
|
+
.back-payment-moip-options.next_step_after_valid_document
|
5
|
+
.w-row.list_payment.w-form
|
6
|
+
.w-col.w-col-7.w-col-small-7.back-payment-moip-options-column
|
7
|
+
= radio_button_tag 'payment_type', "cards", false, class: 'w-radio-input back-payment-radio-button'
|
8
|
+
= label_tag :payment_type_cards, nil, class: "cards w-form-label" do
|
9
|
+
= image_tag 'catarse_bootstrap/payment_cards.jpg'
|
10
|
+
.w-col.w-col-5.w-col-small-5.back-payment-moip-options-column
|
11
|
+
= radio_button_tag 'payment_type', "boleto", false, class: 'w-radio-input back-payment-radio-button'
|
12
|
+
= label_tag :payment_type_boleto, class: "boleto w-form-label" do
|
13
|
+
= image_tag 'catarse_bootstrap/payment_boleto.jpg'
|
14
|
+
.formwrapper
|
19
15
|
#payment_type_cards_section.payment_section
|
20
|
-
|
16
|
+
.w-row
|
17
|
+
.w-col.w-col-6.w-sub-col
|
18
|
+
= label_tag :payment_card_name, "Nome do titular do cartão", class: 'field-label fontweight-semibold'
|
19
|
+
= text_field_tag :payment_card_name, nil, class: 'w-input text-field', required: true
|
20
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_name"]
|
21
|
+
| Por favor digite o nome escrito no cartão
|
22
|
+
.w-col.w-col-6.cpf
|
23
|
+
= label_tag :payment_card_cpf, "CPF", class: 'field-label fontweight-semibold'
|
24
|
+
= text_field_tag :payment_card_cpf, nil, class: 'w-input text-field', data: {mask: '999.999.999-99'}, required: true
|
25
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_cpf"]
|
26
|
+
| Verifique o CPF do titular do cartão
|
27
|
+
.w-row
|
28
|
+
.w-col.w-col-6.w-sub-col.phone
|
29
|
+
= label_tag :payment_card_phone, "Telefone", class: 'field-label fontweight-semibold'
|
30
|
+
= text_field_tag :payment_card_phone, nil, class: 'w-input text-field', data: {mask: '(99) 9999-9999?9'}, required: true
|
31
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_phone"]
|
32
|
+
| Por favor digite o telefone de contato do titular
|
33
|
+
.w-col.w-col-6.birth
|
34
|
+
= label_tag :payment_card_birth, "Data de Nascimento", class: 'field-label fontweight-semibold'
|
35
|
+
= text_field_tag :payment_card_birth, nil, class: 'w-input text-field', data: {mask: '99/99/9999'}, required: true
|
36
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_birth"]
|
37
|
+
| Por favor digite a data de nascimento do titular
|
38
|
+
.w-row
|
39
|
+
.w-col.w-col-6.w-sub-col.number
|
40
|
+
= label_tag :payment_card_number, 'Número do cartão' , class: 'field-label fontweight-semibold'
|
41
|
+
.card-brand.prefix.text-field
|
42
|
+
.fontsize-smallest.fontcolor-secondary.u-text-center
|
43
|
+
.card-number
|
44
|
+
= text_field_tag :payment_card_number, nil, class: 'w-input text-field postfix', required: true
|
45
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_number"]
|
46
|
+
| Por favor verifique o número do cartão de crédito
|
47
|
+
.w-col.w-col-6
|
48
|
+
.w-row
|
49
|
+
.w-col.w-col-6.w-col-small-6.w-col-tiny-6.w-sub-col-middle.source
|
50
|
+
= label_tag :payment_card_source, 'Cód. Segurança', class: 'field-label fontweight-semibold'
|
51
|
+
= text_field_tag :payment_card_source, nil, class: 'w-input text-field', required: true
|
52
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_source"]
|
53
|
+
| Veja o código de segurança do cartão abaixo da tarja magnética
|
54
|
+
.w-col.w-col-6.w-col-small-6.w-col-tiny-6.date
|
55
|
+
= label_tag :payment_card_date, 'Data de Expiração', class: 'field-label fontweight-semibold'
|
56
|
+
= text_field_tag :payment_card_date, nil, class: 'w-input text-field', data: {mask: '99/99'}, required: true
|
57
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="payment_card_date"]
|
58
|
+
| Qual a data de expiração no cartão?
|
21
59
|
|
22
|
-
.
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
.
|
50
|
-
|
51
|
-
.
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
= label_tag :payment_card_flag, 'Bandeira'
|
59
|
-
= text_field_tag :payment_card_flag, nil, { disabled: true }
|
60
|
-
li.source
|
61
|
-
= label_tag :payment_card_source, 'Código de Segurança'
|
62
|
-
= text_field_tag :payment_card_source, nil
|
63
|
-
li.date
|
64
|
-
= label_tag :payment_card_date, 'Data de Expiração'
|
65
|
-
= text_field_tag :payment_card_date, nil
|
66
|
-
|
67
|
-
.clearfix
|
68
|
-
.bootstrap-twitter
|
69
|
-
.loader.hide= image_tag('loading.gif')
|
70
|
-
= submit_tag t('projects.contributions.review.form.labels.submit'), :disabled => true, :class => 'btn btn-primary btn-large', :id => "credit_card_submit"
|
71
|
-
#payment_type_boleto_section.hide.payment_section
|
72
|
-
h3= t('projects.contributions.review.form.labels.payment_boleto')
|
73
|
-
.clearfix
|
74
|
-
.bootstrap-twitter style="float: none;"
|
75
|
-
.alert.alert-danger.hide
|
76
|
-
p.error_msg
|
77
|
-
.clearfix
|
78
|
-
.bootstrap-twitter
|
79
|
-
= label_tag 'user_document_payment_slip', t('projects.contributions.review.form.labels.document')
|
80
|
-
= text_field_tag 'user_document_payment_slip', nil, { autocomplete: 'off' }
|
81
|
-
.loader.hide= image_tag('loading.gif')
|
82
|
-
= submit_tag t('projects.contributions.review.form.labels.build_boleto'), :class => 'btn btn-primary btn-large', :id => "build_boleto", :disabled => true
|
83
|
-
.clearfix
|
84
|
-
p.subtitle.hide= t('projects.contributions.review.form.labels.payment_boleto_subtitle')
|
85
|
-
.link_content
|
86
|
-
|
87
|
-
/
|
88
|
-
#payment_type_account_section.hide.payment_section
|
89
|
-
h3= t('projects.contributions.review.form.labels.payment_account')
|
90
|
-
.clearfix
|
91
|
-
.bootstrap-twitter style="float: none;"
|
92
|
-
.alert.alert-danger.hide
|
93
|
-
p.error_msg
|
94
|
-
.clearfix
|
95
|
-
.bootstrap-twitter
|
96
|
-
= label_tag 'user_document_account', t('projects.contributions.review.form.labels.document')
|
97
|
-
= text_field_tag 'user_document_account', nil, { autocomplete: 'off' }
|
98
|
-
= label_tag :account, t('projects.contributions.review.form.labels.select_account')
|
99
|
-
= select_tag :account, options_for_select([['Banco do Brasil', 'BancoDoBrasil'], ['Bradesco'], ['Banrisul'], ['Itaú', 'Itau'] ]), :include_blank => true
|
100
|
-
.loader.hide= image_tag('loading.gif')
|
101
|
-
= submit_tag t('projects.contributions.review.form.labels.submit'), :class => 'btn btn-primary btn-large', :id => "build_account_link", :disabled => true
|
102
|
-
p.subtitle.hide= t('projects.contributions.review.form.labels.select_account')
|
103
|
-
.link_content
|
104
|
-
|
105
|
-
|
60
|
+
.w-row
|
61
|
+
.w-col.w-col-12
|
62
|
+
.payment-error-message.card.card-error.u-radius.zindex-10.u-marginbottom-30.w-hidden
|
63
|
+
.fontsize-smaller.fontweight-bold.u-marginbottom-10= t('.review_errors_title')
|
64
|
+
.message-text.fontsize-smaller = t('.review_errors')
|
65
|
+
.w-row
|
66
|
+
.w-col.w-col-push-3.w-col-6
|
67
|
+
.loader.u-text-center.w-col.w-col-12.u-marginbottom-30 = image_tag "catarse_bootstrap/loader.gif"
|
68
|
+
= submit_tag t('projects.contributions.review.form.labels.submit'), class: 'btn btn-large u-marginbottom-20', id: "credit_card_submit"
|
69
|
+
= render partial: 'terms'
|
70
|
+
#payment_type_boleto_section.w-hidden.payment_section
|
71
|
+
.w-row
|
72
|
+
.w-col.w-col-6
|
73
|
+
= label_tag 'user_document_payment_slip', t('projects.contributions.review.form.labels.document'), class: 'field-label fontweight-semibold'
|
74
|
+
= text_field_tag 'user_document_payment_slip', nil, { autocomplete: 'off', class: 'w-input text-field', required: true, data: {mask: '999.999.999-99'} }
|
75
|
+
.fontsize-smaller.text-error.u-marginbottom-20.fa.fa-exclamation-triangle.w-hidden[data-error-for="user_document_payment_slip"]
|
76
|
+
| Verifique o CPF
|
77
|
+
.w-row
|
78
|
+
.w-col.w-col-12
|
79
|
+
.card.card-message.u-radius.fontsize-small.zindex-10.u-marginbottom-30
|
80
|
+
| Após clicar no botão abaixo, você receberá um link com o boleto para completar o pagamento.
|
81
|
+
.w-row
|
82
|
+
.w-col.w-col-12
|
83
|
+
.payment-error-message.card.card-error.u-radius.zindex-10.u-marginbottom-30.w-hidden
|
84
|
+
.fontsize-smaller.fontweight-bold.u-marginbottom-10= t('.review_errors_title')
|
85
|
+
.message-text.fontsize-smaller = t('.review_errors')
|
86
|
+
.w-row
|
87
|
+
.w-col.w-col-push-3.w-col-6
|
88
|
+
#card-loading.loader.u-text-center.w-col.w-col-12.u-marginbottom-30 = image_tag "catarse_bootstrap/loader.gif"
|
89
|
+
= submit_tag t('projects.contributions.review.form.labels.build_boleto'), class: 'btn btn-large u-marginbottom-20', id: "build_boleto"
|
90
|
+
= render partial: 'terms'
|
91
|
+
.w-row
|
92
|
+
.w-col.w-col-12
|
93
|
+
#payment-slip-link.card.card-message.fontsize-small.u-radius.u-marginbottom-30.zindex-10.w-hidden
|
94
|
+
.link_content.fontsize-smaller
|
95
|
+
.fontsize-smaller Você também receberá um email com esse boleto.
|
106
96
|
|
107
97
|
== javascript_include_tag js_moip_index_path
|
data/catarse_moip.gemspec
CHANGED
data/config/initializers/moip.rb
CHANGED
@@ -3,13 +3,3 @@
|
|
3
3
|
config.token = (PaymentEngines.configuration.get_without_cache(:moip_token) rescue nil) || ''
|
4
4
|
config.key = (PaymentEngines.configuration.get_without_cache(:moip_key) rescue nil) || ''
|
5
5
|
end
|
6
|
-
|
7
|
-
MOIP_V2_ENDPOINT = begin
|
8
|
-
if PaymentEngines.configuration.get_without_cache(:moip_test) == 'true'
|
9
|
-
'https://test.moip.com.br'
|
10
|
-
else
|
11
|
-
'https://api.moip.com.br'
|
12
|
-
end
|
13
|
-
rescue Exception => e
|
14
|
-
'https://test.moip.com.br'
|
15
|
-
end
|
data/lib/catarse_moip.rb
CHANGED
data/lib/catarse_moip/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catarse_moip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antônio Roberto Silva
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -26,20 +26,6 @@ dependencies:
|
|
26
26
|
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '4.0'
|
29
|
-
- !ruby/object:Gem::Dependency
|
30
|
-
name: httparty
|
31
|
-
requirement: !ruby/object:Gem::Requirement
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: '0'
|
36
|
-
type: :runtime
|
37
|
-
prerelease: false
|
38
|
-
version_requirements: !ruby/object:Gem::Requirement
|
39
|
-
requirements:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: '0'
|
43
29
|
- !ruby/object:Gem::Dependency
|
44
30
|
name: libxml-ruby
|
45
31
|
requirement: !ruby/object:Gem::Requirement
|
@@ -135,7 +121,7 @@ files:
|
|
135
121
|
- app/assets/javascripts/catarse_moip/payment_slip.js
|
136
122
|
- app/assets/javascripts/catarse_moip/user_document.js
|
137
123
|
- app/controllers/catarse_moip/moip_controller.rb
|
138
|
-
- app/
|
124
|
+
- app/views/catarse_moip/moip/_terms.html.slim
|
139
125
|
- app/views/catarse_moip/moip/review.html.slim
|
140
126
|
- catarse_moip.gemspec
|
141
127
|
- config/initializers/moip.rb
|
@@ -1,121 +0,0 @@
|
|
1
|
-
module CatarseMoip
|
2
|
-
module V2
|
3
|
-
class Refund
|
4
|
-
include ::HTTParty
|
5
|
-
|
6
|
-
base_uri ::MOIP_V2_ENDPOINT
|
7
|
-
|
8
|
-
attr_accessor :contribution, :refund_options
|
9
|
-
|
10
|
-
def self.start(contribution)
|
11
|
-
_instance = new(contribution)
|
12
|
-
_instance.refund
|
13
|
-
end
|
14
|
-
|
15
|
-
def initialize(contribution)
|
16
|
-
self.contribution = contribution
|
17
|
-
self.refund_options = define_refund_options
|
18
|
-
end
|
19
|
-
|
20
|
-
def refund
|
21
|
-
self.class.post("/v2/payments/#{parsed_payment_id}/refunds", {
|
22
|
-
body: self.refund_options.to_json
|
23
|
-
}.merge!(basic_auth_params))
|
24
|
-
end
|
25
|
-
|
26
|
-
def define_refund_options
|
27
|
-
if refund_method == 'BANK_ACCOUNT'
|
28
|
-
check_bank_account!
|
29
|
-
{
|
30
|
-
amount: amount_to_refund,
|
31
|
-
method: refund_method,
|
32
|
-
refundingInstrument: refund_instrument
|
33
|
-
}
|
34
|
-
else
|
35
|
-
{}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
protected
|
40
|
-
|
41
|
-
def check_bank_account!
|
42
|
-
unless bank_account.valid?
|
43
|
-
raise "Invalid bank account"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
def refund_instrument
|
48
|
-
{
|
49
|
-
method: refund_method,
|
50
|
-
bankAccount: {
|
51
|
-
type: 'CHECKING',
|
52
|
-
bankNumber: bank_account.bank_code,
|
53
|
-
agencyNumber: bank_account.agency.to_i,
|
54
|
-
agencyCheckNumber: bank_account.agency_digit.to_i,
|
55
|
-
accountNumber: bank_account.account.to_i,
|
56
|
-
accountCheckNumber: bank_account.account_digit.to_i,
|
57
|
-
holder: {
|
58
|
-
fullname: bank_account.owner_name,
|
59
|
-
taxDocument: {
|
60
|
-
type: bank_account_document_type,
|
61
|
-
number: parsed_holder_document
|
62
|
-
}
|
63
|
-
}
|
64
|
-
}
|
65
|
-
}
|
66
|
-
end
|
67
|
-
|
68
|
-
def bank_account
|
69
|
-
self.contribution.user.bank_account
|
70
|
-
end
|
71
|
-
|
72
|
-
def bank_account_document_type
|
73
|
-
if parsed_holder_document.size > 11
|
74
|
-
'CNPJ'
|
75
|
-
else
|
76
|
-
'CPF'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def parsed_holder_document
|
81
|
-
bank_account.owner_document.gsub(/[\.\-\/\s]/,'')
|
82
|
-
end
|
83
|
-
|
84
|
-
def amount_to_refund
|
85
|
-
if already_expired_refund_deadline?
|
86
|
-
((self.contribution.value - self.contribution.payment_service_fee.to_f) * 100).to_i
|
87
|
-
else
|
88
|
-
self.contribution.price_in_cents
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def refund_method
|
93
|
-
if already_expired_refund_deadline? || !self.contribution.is_credit_card?
|
94
|
-
'BANK_ACCOUNT'
|
95
|
-
else
|
96
|
-
'CREDIT_CARD'
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def already_expired_refund_deadline?
|
101
|
-
self.contribution.confirmed_at < 170.days.ago
|
102
|
-
end
|
103
|
-
|
104
|
-
def basic_auth_params
|
105
|
-
{
|
106
|
-
basic_auth: {
|
107
|
-
username: PaymentEngines.configuration[:moip_token],
|
108
|
-
password: PaymentEngines.configuration[:moip_key],
|
109
|
-
},
|
110
|
-
headers: {
|
111
|
-
'Content-Type' => 'application/json'
|
112
|
-
}
|
113
|
-
}
|
114
|
-
end
|
115
|
-
|
116
|
-
def parsed_payment_id
|
117
|
-
contribution.payment_id.gsub('.', '')
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|