catarse_moip 2.2.1 → 2.3.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.
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- catarse_moip (2.2.0)
13
+ catarse_moip (2.3.0)
14
14
  enumerate_it
15
15
  libxml-ruby (~> 2.6.0)
16
16
  rails (~> 4.0)
@@ -8,7 +8,7 @@ App.addChild('MoipForm', {
8
8
  onSuccess();
9
9
  }
10
10
  } else {
11
- $.post('/payment/moip/' + this.backerId + '/get_moip_token').success(function(response, textStatus){
11
+ $.post('/payment/moip/' + this.contributionId + '/get_moip_token').success(function(response, textStatus){
12
12
  that.paymentChoice.$('input').attr('disabled', 'disabled');
13
13
  if(response.get_token_response.status == 'fail'){
14
14
  that.checkoutFailure({Code: 0, Mensagem: response.get_token_response.message});
@@ -47,7 +47,7 @@ App.addChild('MoipForm', {
47
47
 
48
48
  checkoutSuccessful: function(data) {
49
49
  var that = this;
50
- $.post('/payment/moip/' + this.backerId + '/moip_response', {response: data}).success(function(){
50
+ $.post('/payment/moip/' + this.contributionId + '/moip_response', {response: data}).success(function(){
51
51
  that.loader.hide();
52
52
  // Bail out when get an error from MoIP
53
53
  if(data.Status == 'Cancelado'){
@@ -75,7 +75,7 @@ App.addChild('MoipForm', {
75
75
 
76
76
  activate: function(){
77
77
  this.message = this.$('.next_step_after_valid_document .alert-danger');
78
- this.backerId = $('input#backer_id').val();
78
+ this.contributionId = $('input#contribution_id').val();
79
79
  this.projectId = $('input#project_id').val();
80
80
 
81
81
  this.loader = this.$('.loader');
@@ -24,9 +24,9 @@ App.views.MoipForm.UserDocument = {
24
24
  $documentField.addClass('ok').removeClass('error');
25
25
 
26
26
  $.ajax({
27
- url: '/projects/' + this.moipForm.projectId + '/backers/' + this.moipForm.backerId,
27
+ url: '/projects/' + this.moipForm.projectId + '/contributions/' + this.moipForm.contributionId,
28
28
  type: 'PUT',
29
- data: { backer: { payer_document: documentNumber } }
29
+ data: { contribution: { payer_document: documentNumber } }
30
30
  });
31
31
 
32
32
  } else {
@@ -3,7 +3,7 @@ require 'moip_transparente'
3
3
 
4
4
  module CatarseMoip
5
5
  class MoipController < ApplicationController
6
- attr_accessor :backer
6
+ attr_accessor :contribution
7
7
 
8
8
  class TransactionStatus < ::EnumerateIt::Base
9
9
  associate_values(
@@ -22,8 +22,8 @@ module CatarseMoip
22
22
  layout :false
23
23
 
24
24
  def create_notification
25
- @backer = PaymentEngines.find_payment key: params[:id_transacao]
26
- process_moip_message if @backer.payment_method == 'MoIP' || @backer.payment_method.nil?
25
+ @contribution = PaymentEngines.find_payment key: params[:id_transacao]
26
+ process_moip_message if @contribution.payment_method == 'MoIP' || @contribution.payment_method.nil?
27
27
  return render :nothing => true, :status => 200
28
28
  rescue Exception => e
29
29
  return render :text => "#{e.inspect}: #{e.message} recebemos: #{params}", :status => 422
@@ -46,13 +46,13 @@ module CatarseMoip
46
46
  end
47
47
 
48
48
  def moip_response
49
- @backer = PaymentEngines.find_payment id: params[:id], user_id: current_user.id
50
- first_update_backer unless params[:response]['StatusPagamento'] == 'Falha'
49
+ @contribution = PaymentEngines.find_payment id: params[:id], user_id: current_user.id
50
+ first_update_contribution unless params[:response]['StatusPagamento'] == 'Falha'
51
51
  render nothing: true, status: 200
52
52
  end
53
53
 
54
54
  def get_moip_token
55
- @backer = PaymentEngines.find_payment id: params[:id], user_id: current_user.id
55
+ @contribution = PaymentEngines.find_payment id: params[:id], user_id: current_user.id
56
56
 
57
57
  ::MoipTransparente::Config.test = (PaymentEngines.configuration[:moip_test] == 'true')
58
58
  ::MoipTransparente::Config.access_token = PaymentEngines.configuration[:moip_token]
@@ -61,30 +61,30 @@ module CatarseMoip
61
61
  @moip = ::MoipTransparente::Checkout.new
62
62
 
63
63
  invoice = {
64
- razao: "Apoio para o projeto '#{backer.project.name}'",
65
- id: backer.key,
66
- total: backer.value.to_s,
64
+ razao: "Apoio para o projeto '#{contribution.project.name}'",
65
+ id: contribution.key,
66
+ total: contribution.value.to_s,
67
67
  acrescimo: '0.00',
68
68
  desconto: '0.00',
69
69
  cliente: {
70
- id: backer.user.id,
71
- nome: backer.payer_name,
72
- email: backer.payer_email,
73
- logradouro: "#{backer.address_street}, #{backer.address_number}",
74
- complemento: backer.address_complement,
75
- bairro: backer.address_neighbourhood,
76
- cidade: backer.address_city,
77
- uf: backer.address_state,
78
- cep: backer.address_zip_code,
79
- telefone: backer.address_phone_number
70
+ id: contribution.user.id,
71
+ nome: contribution.payer_name,
72
+ email: contribution.payer_email,
73
+ logradouro: "#{contribution.address_street}, #{contribution.address_number}",
74
+ complemento: contribution.address_complement,
75
+ bairro: contribution.address_neighbourhood,
76
+ cidade: contribution.address_city,
77
+ uf: contribution.address_state,
78
+ cep: contribution.address_zip_code,
79
+ telefone: contribution.address_phone_number
80
80
  }
81
81
  }
82
82
 
83
83
  response = @moip.get_token(invoice)
84
84
 
85
- session[:thank_you_id] = backer.project.id
85
+ session[:thank_you_id] = contribution.project.id
86
86
 
87
- backer.update_column :payment_token, response[:token] if response and response[:token]
87
+ contribution.update_column :payment_token, response[:token] if response and response[:token]
88
88
 
89
89
  render json: {
90
90
  get_token_response: response,
@@ -98,20 +98,20 @@ module CatarseMoip
98
98
  }
99
99
  end
100
100
 
101
- def first_update_backer
102
- response = ::MoIP.query(backer.payment_token)
101
+ def first_update_contribution
102
+ response = ::MoIP.query(contribution.payment_token)
103
103
  if response && response["Autorizacao"]
104
104
  params = response["Autorizacao"]["Pagamento"]
105
105
  params = params.first unless params.respond_to?(:key)
106
106
 
107
- backer.with_lock do
107
+ contribution.with_lock do
108
108
  if params["Status"] == "Autorizado"
109
- backer.confirm!
110
- elsif backer.pending?
111
- backer.waiting!
109
+ contribution.confirm!
110
+ elsif contribution.pending?
111
+ contribution.waiting!
112
112
  end
113
113
 
114
- backer.update_attributes({
114
+ contribution.update_attributes({
115
115
  :payment_id => params["CodigoMoIP"],
116
116
  :payment_choice => params["FormaPagamento"],
117
117
  :payment_method => 'MoIP',
@@ -122,20 +122,20 @@ module CatarseMoip
122
122
  end
123
123
 
124
124
  def process_moip_message
125
- backer.with_lock do
126
- PaymentEngines.create_payment_notification backer_id: backer.id, extra_data: JSON.parse(params.to_json.force_encoding('iso-8859-1').encode('utf-8'))
127
- payment_id = (backer.payment_id.gsub(".", "").to_i rescue 0)
125
+ contribution.with_lock do
126
+ PaymentEngines.create_payment_notification contribution_id: contribution.id, extra_data: JSON.parse(params.to_json.force_encoding('iso-8859-1').encode('utf-8'))
127
+ payment_id = (contribution.payment_id.gsub(".", "").to_i rescue 0)
128
128
 
129
129
  if payment_id <= params[:cod_moip].to_i
130
- backer.update_attributes payment_id: params[:cod_moip]
130
+ contribution.update_attributes payment_id: params[:cod_moip]
131
131
 
132
132
  case params[:status_pagamento].to_i
133
133
  when TransactionStatus::AUTHORIZED
134
- backer.confirm! unless backer.confirmed?
134
+ contribution.confirm! unless contribution.confirmed?
135
135
  when TransactionStatus::WRITTEN_BACK, TransactionStatus::REFUNDED
136
- backer.refund! unless backer.refunded?
136
+ contribution.refund! unless contribution.refunded?
137
137
  when TransactionStatus::CANCELED
138
- backer.cancel! unless backer.canceled?
138
+ contribution.cancel! unless contribution.canceled?
139
139
  end
140
140
  end
141
141
  end
@@ -17,7 +17,7 @@
17
17
  = label_tag :payment_type_account, 'Débito em Conta', :class => "account"
18
18
 
19
19
  #payment_type_cards_section.payment_section
20
- h3= t('projects.backers.review.form.labels.payment_card')
20
+ h3= t('projects.contributions.review.form.labels.payment_card')
21
21
 
22
22
  .clearfix
23
23
 
@@ -30,7 +30,7 @@
30
30
 
31
31
  .choose_card
32
32
  .div
33
- span= t('projects.backers.review.form.labels.owner_card')
33
+ span= t('projects.contributions.review.form.labels.owner_card')
34
34
  .owner_outside
35
35
  .owner
36
36
  ol.inputs
@@ -47,7 +47,7 @@
47
47
  = label_tag :payment_card_birth, "Data de Nascimento"
48
48
  = text_field_tag :payment_card_birth, nil
49
49
  .div
50
- span= t('projects.backers.review.form.labels.number_card')
50
+ span= t('projects.contributions.review.form.labels.number_card')
51
51
  .infocard_outside
52
52
  .infocard
53
53
  ol.inputs
@@ -67,39 +67,39 @@
67
67
  .clearfix
68
68
  .bootstrap-twitter
69
69
  .loader.hide= image_tag('loading.gif')
70
- = submit_tag t('projects.backers.review.form.labels.submit'), :disabled => true, :class => 'btn btn-primary btn-large', :id => "credit_card_submit"
70
+ = submit_tag t('projects.contributions.review.form.labels.submit'), :disabled => true, :class => 'btn btn-primary btn-large', :id => "credit_card_submit"
71
71
  #payment_type_boleto_section.hide.payment_section
72
- h3= t('projects.backers.review.form.labels.payment_boleto')
72
+ h3= t('projects.contributions.review.form.labels.payment_boleto')
73
73
  .clearfix
74
74
  .bootstrap-twitter style="float: none;"
75
75
  .alert.alert-danger.hide
76
76
  p.error_msg
77
77
  .clearfix
78
78
  .bootstrap-twitter
79
- = label_tag 'user_document_payment_slip', t('projects.backers.review.form.labels.document')
79
+ = label_tag 'user_document_payment_slip', t('projects.contributions.review.form.labels.document')
80
80
  = text_field_tag 'user_document_payment_slip', nil, { autocomplete: 'off' }
81
81
  .loader.hide= image_tag('loading.gif')
82
- = submit_tag t('projects.backers.review.form.labels.build_boleto'), :class => 'btn btn-primary btn-large', :id => "build_boleto", :disabled => true
82
+ = submit_tag t('projects.contributions.review.form.labels.build_boleto'), :class => 'btn btn-primary btn-large', :id => "build_boleto", :disabled => true
83
83
  .clearfix
84
- p.subtitle.hide= t('projects.backers.review.form.labels.payment_boleto_subtitle')
84
+ p.subtitle.hide= t('projects.contributions.review.form.labels.payment_boleto_subtitle')
85
85
  .link_content
86
86
 
87
87
  /
88
88
  #payment_type_account_section.hide.payment_section
89
- h3= t('projects.backers.review.form.labels.payment_account')
89
+ h3= t('projects.contributions.review.form.labels.payment_account')
90
90
  .clearfix
91
91
  .bootstrap-twitter style="float: none;"
92
92
  .alert.alert-danger.hide
93
93
  p.error_msg
94
94
  .clearfix
95
95
  .bootstrap-twitter
96
- = label_tag 'user_document_account', t('projects.backers.review.form.labels.document')
96
+ = label_tag 'user_document_account', t('projects.contributions.review.form.labels.document')
97
97
  = text_field_tag 'user_document_account', nil, { autocomplete: 'off' }
98
- = label_tag :account, t('projects.backers.review.form.labels.select_account')
98
+ = label_tag :account, t('projects.contributions.review.form.labels.select_account')
99
99
  = select_tag :account, options_for_select([['Banco do Brasil', 'BancoDoBrasil'], ['Bradesco'], ['Banrisul'], ['Itaú', 'Itau'] ]), :include_blank => true
100
100
  .loader.hide= image_tag('loading.gif')
101
- = submit_tag t('projects.backers.review.form.labels.submit'), :class => 'btn btn-primary btn-large', :id => "build_account_link", :disabled => true
102
- p.subtitle.hide= t('projects.backers.review.form.labels.select_account')
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
103
  .link_content
104
104
 
105
105
 
@@ -1,5 +1,5 @@
1
1
  begin
2
- PaymentEngines.register({name: 'moip', review_path: ->(backer){ CatarseMoip::Engine.routes.url_helpers.review_moip_path(backer) }, locale: 'pt'})
2
+ PaymentEngines.register({name: 'moip', review_path: ->(contribution){ CatarseMoip::Engine.routes.url_helpers.review_moip_path(contribution) }, locale: 'pt'})
3
3
  rescue Exception => e
4
4
  puts "Error while registering payment engine: #{e}"
5
5
  end
@@ -1,6 +1,6 @@
1
1
  en:
2
2
  projects:
3
- backers:
3
+ contributions:
4
4
  review:
5
5
  moip: 'Payments from Brazil'
6
6
  checkout:
@@ -1,6 +1,6 @@
1
1
  pt:
2
2
  projects:
3
- backers:
3
+ contributions:
4
4
  review:
5
5
  moip: 'Pagamento nacional'
6
6
  form:
@@ -1,3 +1,3 @@
1
1
  module CatarseMoip
2
- VERSION = "2.2.1"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -5,9 +5,9 @@ describe CatarseMoip::MoipController do
5
5
  subject{ response }
6
6
 
7
7
  let(:get_token_response){{:status=>:fail, :code=>"171", :message=>"TelefoneFixo do endereço deverá ser enviado obrigatorio", :id=>"201210192052439150000024698931"}}
8
- let(:backer){ double('backer', {
8
+ let(:contribution){ double('contribution', {
9
9
  id: 1,
10
- key: 'backer key',
10
+ key: 'contribution key',
11
11
  payment_id: 'payment id',
12
12
  project: project,
13
13
  pending?: false,
@@ -34,7 +34,7 @@ describe CatarseMoip::MoipController do
34
34
 
35
35
  let(:user){ double('user', id: 1) }
36
36
  let(:project){ double('project', id: 1, name: 'test project') }
37
- let(:extra_data){ {"id_transacao"=>backer.key, "valor"=>"2190", "cod_moip"=>"12345123", "forma_pagamento"=>"1", "tipo_pagamento"=>"CartaoDeCredito", "email_consumidor"=>"some@email.com", "controller"=>"catarse_moip/payment/notifications", "action"=>"create"} }
37
+ let(:extra_data){ {"id_transacao"=>contribution.key, "valor"=>"2190", "cod_moip"=>"12345123", "forma_pagamento"=>"1", "tipo_pagamento"=>"CartaoDeCredito", "email_consumidor"=>"some@email.com", "controller"=>"catarse_moip/payment/notifications", "action"=>"create"} }
38
38
 
39
39
  before do
40
40
  controller.stub(:current_user).and_return(user)
@@ -42,107 +42,107 @@ describe CatarseMoip::MoipController do
42
42
  ::MoipTransparente::Checkout.any_instance.stub(:moip_widget_tag).and_return('<div>')
43
43
  ::MoipTransparente::Checkout.any_instance.stub(:moip_javascript_tag).and_return('<script>')
44
44
  ::MoipTransparente::Checkout.any_instance.stub(:as_json).and_return('{}')
45
- PaymentEngines.stub(:find_payment).and_return(backer)
45
+ PaymentEngines.stub(:find_payment).and_return(contribution)
46
46
  PaymentEngines.stub(:create_payment_notification)
47
- backer.stub(:with_lock).and_yield
47
+ contribution.stub(:with_lock).and_yield
48
48
  end
49
49
 
50
50
  describe "POST create_notification" do
51
- context "when we search for a non-existant backer" do
51
+ context "when we search for a non-existant contribution" do
52
52
  before do
53
- PaymentEngines.should_receive(:find_payment).with(key: "non-existant backer key").and_raise('error')
54
- post :create_notification, {:id_transacao => "non-existant backer key", :use_route => 'catarse_moip'}
53
+ PaymentEngines.should_receive(:find_payment).with(key: "non-existant contribution key").and_raise('error')
54
+ post :create_notification, {:id_transacao => "non-existant contribution key", :use_route => 'catarse_moip'}
55
55
  end
56
56
 
57
57
  its(:status){ should == 422 }
58
- its(:body){ should == "#<RuntimeError: error>: error recebemos: {\"id_transacao\"=>\"non-existant backer key\", \"controller\"=>\"catarse_moip/moip\", \"action\"=>\"create_notification\"}" }
58
+ its(:body){ should == "#<RuntimeError: error>: error recebemos: {\"id_transacao\"=>\"non-existant contribution key\", \"controller\"=>\"catarse_moip/moip\", \"action\"=>\"create_notification\"}" }
59
59
  end
60
60
 
61
- context "when we seach for an existing backer" do
61
+ context "when we seach for an existing contribution" do
62
62
  before do
63
- controller.stub(:params).and_return({:id_transacao =>backer.key, :controller => "catarse_moip/moip", :action => "create_notification"})
64
- PaymentEngines.should_receive(:find_payment).with(key: backer.key).and_return(backer)
63
+ controller.stub(:params).and_return({:id_transacao =>contribution.key, :controller => "catarse_moip/moip", :action => "create_notification"})
64
+ PaymentEngines.should_receive(:find_payment).with(key: contribution.key).and_return(contribution)
65
65
  controller.should_receive(:process_moip_message)
66
- post :create_notification, {:id_transacao => backer.key, :use_route => 'catarse_moip'}
66
+ post :create_notification, {:id_transacao => contribution.key, :use_route => 'catarse_moip'}
67
67
  end
68
68
 
69
69
  its(:body){ should == ' ' }
70
70
  its(:status){ should == 200 }
71
- it("should assign backer"){ assigns(:backer).should == backer }
71
+ it("should assign contribution"){ assigns(:contribution).should == contribution }
72
72
  end
73
73
 
74
- context "when receive ordered notification for backer" do
74
+ context "when receive ordered notification for contribution" do
75
75
  before do
76
- controller.stub(:params).and_return({:cod_moip => 125, :id_transacao =>backer.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
77
- backer.stub(:payment_id).and_return('123')
76
+ controller.stub(:params).and_return({:cod_moip => 125, :id_transacao =>contribution.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
77
+ contribution.stub(:payment_id).and_return('123')
78
78
 
79
79
  controller.should_receive(:process_moip_message).and_call_original
80
- backer.should_receive(:update_attributes).with(payment_id: 125)
81
- post :create_notification, {:id_transacao => backer.key, :use_route => 'catarse_moip'}
80
+ contribution.should_receive(:update_attributes).with(payment_id: 125)
81
+ post :create_notification, {:id_transacao => contribution.key, :use_route => 'catarse_moip'}
82
82
  end
83
83
 
84
84
  its(:body){ should == ' ' }
85
85
  its(:status){ should == 200 }
86
- it("should assign backer"){ assigns(:backer).should == backer }
86
+ it("should assign contribution"){ assigns(:contribution).should == contribution }
87
87
  end
88
88
 
89
89
  context "when we receive a notification with the same payment id but with another status" do
90
90
  before do
91
- controller.stub(:params).and_return({:cod_moip => 123, :id_transacao =>backer.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 1})
92
- backer.stub(:payment_id).and_return('123')
91
+ controller.stub(:params).and_return({:cod_moip => 123, :id_transacao =>contribution.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 1})
92
+ contribution.stub(:payment_id).and_return('123')
93
93
 
94
94
  controller.should_receive(:process_moip_message).and_call_original
95
- backer.should_receive(:update_attributes).with(payment_id: 123)
96
- post :create_notification, {:id_transacao => backer.key, :use_route => 'catarse_moip'}
95
+ contribution.should_receive(:update_attributes).with(payment_id: 123)
96
+ post :create_notification, {:id_transacao => contribution.key, :use_route => 'catarse_moip'}
97
97
  end
98
98
 
99
99
  its(:body){ should == ' ' }
100
100
  its(:status){ should == 200 }
101
- it("should assign backer"){ assigns(:backer).should == backer }
101
+ it("should assign contribution"){ assigns(:contribution).should == contribution }
102
102
  end
103
103
 
104
- context "when receive a unordered notification for backer" do
104
+ context "when receive a unordered notification for contribution" do
105
105
  before do
106
- controller.stub(:params).and_return({:cod_moip => 122, :id_transacao =>backer.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
107
- backer.stub(:payment_id).and_return('123')
106
+ controller.stub(:params).and_return({:cod_moip => 122, :id_transacao =>contribution.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
107
+ contribution.stub(:payment_id).and_return('123')
108
108
 
109
109
  controller.should_receive(:process_moip_message).and_call_original
110
- backer.should_not_receive(:update_attributes).with(payment_id: 122)
111
- post :create_notification, {:id_transacao => backer.key, :use_route => 'catarse_moip'}
110
+ contribution.should_not_receive(:update_attributes).with(payment_id: 122)
111
+ post :create_notification, {:id_transacao => contribution.key, :use_route => 'catarse_moip'}
112
112
  end
113
113
 
114
114
  its(:body){ should == ' ' }
115
115
  its(:status){ should == 200 }
116
- it("should assign backer"){ assigns(:backer).should == backer }
116
+ it("should assign contribution"){ assigns(:contribution).should == contribution }
117
117
  end
118
118
 
119
- context "when backer payment_method is PayPal" do
119
+ context "when contribution payment_method is PayPal" do
120
120
  before do
121
- controller.stub(:params).and_return({:cod_moip => 125, :id_transacao =>backer.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
122
- backer.stub(:payment_method).and_return('PayPal')
121
+ controller.stub(:params).and_return({:cod_moip => 125, :id_transacao =>contribution.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
122
+ contribution.stub(:payment_method).and_return('PayPal')
123
123
 
124
124
  controller.should_not_receive(:process_moip_message)
125
- post :create_notification, {:id_transacao => backer.key, :use_route => 'catarse_moip'}
125
+ post :create_notification, {:id_transacao => contribution.key, :use_route => 'catarse_moip'}
126
126
  end
127
127
 
128
128
  its(:body){ should == ' ' }
129
129
  its(:status){ should == 200 }
130
- it("should assign backer"){ assigns(:backer).should == backer }
130
+ it("should assign contribution"){ assigns(:contribution).should == contribution }
131
131
  end
132
132
 
133
- context "when backer payment_id is null" do
133
+ context "when contribution payment_id is null" do
134
134
  before do
135
- controller.stub(:params).and_return({:cod_moip => 122, :id_transacao =>backer.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
136
- backer.stub(:payment_id).and_return(nil)
135
+ controller.stub(:params).and_return({:cod_moip => 122, :id_transacao =>contribution.key, :controller => "catarse_moip/moip", :action => "create_notification", :status_pagamento => 5})
136
+ contribution.stub(:payment_id).and_return(nil)
137
137
 
138
138
  controller.should_receive(:process_moip_message).and_call_original
139
- backer.should_receive(:update_attributes).with(payment_id: 122)
140
- post :create_notification, {:id_transacao => backer.key, :use_route => 'catarse_moip'}
139
+ contribution.should_receive(:update_attributes).with(payment_id: 122)
140
+ post :create_notification, {:id_transacao => contribution.key, :use_route => 'catarse_moip'}
141
141
  end
142
142
 
143
143
  its(:body){ should == ' ' }
144
144
  its(:status){ should == 200 }
145
- it("should assign backer"){ assigns(:backer).should == backer }
145
+ it("should assign contribution"){ assigns(:contribution).should == contribution }
146
146
  end
147
147
  end
148
148
 
@@ -175,8 +175,8 @@ describe CatarseMoip::MoipController do
175
175
  describe "POST moip_response" do
176
176
  let(:processor){ double('moip processor') }
177
177
  before do
178
- controller.should_receive(:first_update_backer)
179
- post :moip_response, id: backer.id, response: {StatusPagamento: 'Sucesso'}, use_route: 'catarse_moip'
178
+ controller.should_receive(:first_update_contribution)
179
+ post :moip_response, id: contribution.id, response: {StatusPagamento: 'Sucesso'}, use_route: 'catarse_moip'
180
180
  end
181
181
 
182
182
  its(:status){ should == 200 }
@@ -184,26 +184,26 @@ describe CatarseMoip::MoipController do
184
184
 
185
185
  describe "POST get_moip_token" do
186
186
  before do
187
- post :get_moip_token, :id => backer.id, :use_route => 'catarse_moip'
187
+ post :get_moip_token, :id => contribution.id, :use_route => 'catarse_moip'
188
188
  end
189
189
 
190
190
  its(:status){ should == 200 }
191
191
  its(:body){ should == "{\"get_token_response\":{\"status\":\"fail\",\"code\":\"171\",\"message\":\"TelefoneFixo do endereço deverá ser enviado obrigatorio\",\"id\":\"201210192052439150000024698931\"},\"moip\":\"{}\",\"widget_tag\":{\"tag_id\":\"MoipWidget\",\"token\":null,\"callback_success\":\"checkoutSuccessful\",\"callback_error\":\"checkoutFailure\"}}" }
192
192
  end
193
193
 
194
- describe "#first_update_backer" do
194
+ describe "#first_update_contribution" do
195
195
  before do
196
- controller.stub(:backer).and_return(backer)
197
- backer.stub(:payment_token).and_return('token')
196
+ controller.stub(:contribution).and_return(contribution)
197
+ contribution.stub(:payment_token).and_return('token')
198
198
  end
199
199
 
200
200
  context "with no response from moip" do
201
201
  let(:moip_query_response) { nil }
202
202
  before do
203
- MoIP.should_receive(:query).with(backer.payment_token).and_return(moip_query_response)
204
- backer.should_not_receive(:update_attributes)
203
+ MoIP.should_receive(:query).with(contribution.payment_token).and_return(moip_query_response)
204
+ contribution.should_not_receive(:update_attributes)
205
205
  end
206
- it("should never call update attributes"){ controller.first_update_backer }
206
+ it("should never call update attributes"){ controller.first_update_contribution }
207
207
  end
208
208
 
209
209
  context "with an incomplete transaction" do
@@ -211,10 +211,10 @@ describe CatarseMoip::MoipController do
211
211
  {"ID"=>"201210191926185570000024694351", "Status"=>"Sucesso"}
212
212
  end
213
213
  before do
214
- MoIP.should_receive(:query).with(backer.payment_token).and_return(moip_query_response)
215
- backer.should_not_receive(:update_attributes)
214
+ MoIP.should_receive(:query).with(contribution.payment_token).and_return(moip_query_response)
215
+ contribution.should_not_receive(:update_attributes)
216
216
  end
217
- it("should never call update attributes"){ controller.first_update_backer }
217
+ it("should never call update attributes"){ controller.first_update_contribution }
218
218
  end
219
219
 
220
220
  context "with a real data set that works for some cases" do
@@ -222,34 +222,34 @@ describe CatarseMoip::MoipController do
222
222
  {"ID"=>"201210191926185570000024694351", "Status"=>"Sucesso", "Autorizacao"=>{"Pagador"=>{"Nome"=>"juliana.giopato@hotmail.com", "Email"=>"juliana.giopato@hotmail.com"}, "EnderecoCobranca"=>{"Logradouro"=>"Rua sócrates abraão ", "Numero"=>"16.0", "Complemento"=>"casa 19", "Bairro"=>"Campo Limpo", "CEP"=>"05782-470", "Cidade"=>"São Paulo", "Estado"=>"SP", "Pais"=>"BRA", "TelefoneFixo"=>"1184719963"}, "Recebedor"=>{"Nome"=>"Catarse", "Email"=>"financeiro@catarse.me"}, "Pagamento"=>[{"Data"=>"2012-10-17T13:06:07.000-03:00", "DataCredito"=>"2012-10-19T00:00:00.000-03:00", "TotalPago"=>"50.00", "TaxaParaPagador"=>"0.00", "TaxaMoIP"=>"1.34", "ValorLiquido"=>"48.66", "FormaPagamento"=>"BoletoBancario", "InstituicaoPagamento"=>"Bradesco", "Status"=>"Autorizado", "Parcela"=>{"TotalParcelas"=>"1"}, "CodigoMoIP"=>"0000.1325.5258"}, {"Data"=>"2012-10-17T13:05:49.000-03:00", "TotalPago"=>"50.00", "TaxaParaPagador"=>"0.00", "TaxaMoIP"=>"3.09", "ValorLiquido"=>"46.91", "FormaPagamento"=>"CartaoDebito", "InstituicaoPagamento"=>"Visa", "Status"=>"Iniciado", "Parcela"=>{"TotalParcelas"=>"1"}, "CodigoMoIP"=>"0000.1325.5248"}]}}
223
223
  end
224
224
  before do
225
- MoIP.should_receive(:query).with(backer.payment_token).and_return(moip_query_response)
225
+ MoIP.should_receive(:query).with(contribution.payment_token).and_return(moip_query_response)
226
226
  payment = moip_query_response["Autorizacao"]["Pagamento"].first
227
- backer.should_receive(:confirm!)
228
- backer.should_receive(:update_attributes).with({
227
+ contribution.should_receive(:confirm!)
228
+ contribution.should_receive(:update_attributes).with({
229
229
  payment_id: payment["CodigoMoIP"],
230
230
  payment_choice: payment["FormaPagamento"],
231
231
  payment_method: 'MoIP',
232
232
  payment_service_fee: payment["TaxaMoIP"]
233
233
  })
234
234
  end
235
- it("should call update attributes"){ controller.first_update_backer }
235
+ it("should call update attributes"){ controller.first_update_contribution }
236
236
  end
237
237
  end
238
238
 
239
239
  describe "#process_moip_message" do
240
240
  before do
241
- controller.stub(:backer).and_return(backer)
242
- backer.stub(:confirmed?).and_return(false)
243
- backer.stub(:confirm!)
244
- controller.stub(:update_backer)
241
+ controller.stub(:contribution).and_return(contribution)
242
+ contribution.stub(:confirmed?).and_return(false)
243
+ contribution.stub(:confirm!)
244
+ controller.stub(:update_contribution)
245
245
  end
246
246
 
247
- context "when there is a written back request and backer is not refunded" do
247
+ context "when there is a written back request and contribution is not refunded" do
248
248
  before do
249
- controller.stub(:params).and_return(post_moip_params.merge!({:id_transacao => backer.key, :status_pagamento => CatarseMoip::MoipController::TransactionStatus::WRITTEN_BACK}))
250
- backer.stub(:refunded?).and_return(false)
251
- backer.should_receive(:refund!)
252
- backer.should_receive(:update_attributes)
249
+ controller.stub(:params).and_return(post_moip_params.merge!({:id_transacao => contribution.key, :status_pagamento => CatarseMoip::MoipController::TransactionStatus::WRITTEN_BACK}))
250
+ contribution.stub(:refunded?).and_return(false)
251
+ contribution.should_receive(:refund!)
252
+ contribution.should_receive(:update_attributes)
253
253
  end
254
254
 
255
255
  it 'should call refund!' do
@@ -259,9 +259,9 @@ describe CatarseMoip::MoipController do
259
259
 
260
260
  context "when there is an authorized request" do
261
261
  before do
262
- controller.stub(:params).and_return(post_moip_params.merge!({:id_transacao => backer.key, :status_pagamento => CatarseMoip::MoipController::TransactionStatus::AUTHORIZED}))
263
- backer.should_receive(:confirm!)
264
- backer.should_receive(:update_attributes)
262
+ controller.stub(:params).and_return(post_moip_params.merge!({:id_transacao => contribution.key, :status_pagamento => CatarseMoip::MoipController::TransactionStatus::AUTHORIZED}))
263
+ contribution.should_receive(:confirm!)
264
+ contribution.should_receive(:update_attributes)
265
265
  end
266
266
 
267
267
  it 'should call confirm!' do
@@ -271,10 +271,10 @@ describe CatarseMoip::MoipController do
271
271
 
272
272
  context "when there is a refund request" do
273
273
  before do
274
- controller.stub(:params).and_return(post_moip_params.merge!({:id_transacao => backer.key, :status_pagamento => CatarseMoip::MoipController::TransactionStatus::REFUNDED}))
275
- backer.stub(:refunded?).and_return(false)
276
- backer.should_receive(:refund!)
277
- backer.should_receive(:update_attributes)
274
+ controller.stub(:params).and_return(post_moip_params.merge!({:id_transacao => contribution.key, :status_pagamento => CatarseMoip::MoipController::TransactionStatus::REFUNDED}))
275
+ contribution.stub(:refunded?).and_return(false)
276
+ contribution.should_receive(:refund!)
277
+ contribution.should_receive(:update_attributes)
278
278
  end
279
279
 
280
280
  it 'should mark refunded to true' do
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catarse_moip
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Antônio Roberto Silva
@@ -10,90 +11,102 @@ authors:
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2014-01-16 00:00:00.000000000 Z
14
+ date: 2014-01-23 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
17
  name: rails
17
18
  requirement: !ruby/object:Gem::Requirement
19
+ none: false
18
20
  requirements:
19
- - - "~>"
21
+ - - ~>
20
22
  - !ruby/object:Gem::Version
21
23
  version: '4.0'
22
24
  type: :runtime
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
27
+ none: false
25
28
  requirements:
26
- - - "~>"
29
+ - - ~>
27
30
  - !ruby/object:Gem::Version
28
31
  version: '4.0'
29
32
  - !ruby/object:Gem::Dependency
30
33
  name: libxml-ruby
31
34
  requirement: !ruby/object:Gem::Requirement
35
+ none: false
32
36
  requirements:
33
- - - "~>"
37
+ - - ~>
34
38
  - !ruby/object:Gem::Version
35
39
  version: 2.6.0
36
40
  type: :runtime
37
41
  prerelease: false
38
42
  version_requirements: !ruby/object:Gem::Requirement
43
+ none: false
39
44
  requirements:
40
- - - "~>"
45
+ - - ~>
41
46
  - !ruby/object:Gem::Version
42
47
  version: 2.6.0
43
48
  - !ruby/object:Gem::Dependency
44
49
  name: enumerate_it
45
50
  requirement: !ruby/object:Gem::Requirement
51
+ none: false
46
52
  requirements:
47
- - - ">="
53
+ - - ! '>='
48
54
  - !ruby/object:Gem::Version
49
55
  version: '0'
50
56
  type: :runtime
51
57
  prerelease: false
52
58
  version_requirements: !ruby/object:Gem::Requirement
59
+ none: false
53
60
  requirements:
54
- - - ">="
61
+ - - ! '>='
55
62
  - !ruby/object:Gem::Version
56
63
  version: '0'
57
64
  - !ruby/object:Gem::Dependency
58
65
  name: rspec-rails
59
66
  requirement: !ruby/object:Gem::Requirement
67
+ none: false
60
68
  requirements:
61
- - - "~>"
69
+ - - ~>
62
70
  - !ruby/object:Gem::Version
63
71
  version: 2.14.0
64
72
  type: :development
65
73
  prerelease: false
66
74
  version_requirements: !ruby/object:Gem::Requirement
75
+ none: false
67
76
  requirements:
68
- - - "~>"
77
+ - - ~>
69
78
  - !ruby/object:Gem::Version
70
79
  version: 2.14.0
71
80
  - !ruby/object:Gem::Dependency
72
81
  name: factory_girl_rails
73
82
  requirement: !ruby/object:Gem::Requirement
83
+ none: false
74
84
  requirements:
75
- - - ">="
85
+ - - ! '>='
76
86
  - !ruby/object:Gem::Version
77
87
  version: '0'
78
88
  type: :development
79
89
  prerelease: false
80
90
  version_requirements: !ruby/object:Gem::Requirement
91
+ none: false
81
92
  requirements:
82
- - - ">="
93
+ - - ! '>='
83
94
  - !ruby/object:Gem::Version
84
95
  version: '0'
85
96
  - !ruby/object:Gem::Dependency
86
97
  name: database_cleaner
87
98
  requirement: !ruby/object:Gem::Requirement
99
+ none: false
88
100
  requirements:
89
- - - ">="
101
+ - - ! '>='
90
102
  - !ruby/object:Gem::Version
91
103
  version: '0'
92
104
  type: :development
93
105
  prerelease: false
94
106
  version_requirements: !ruby/object:Gem::Requirement
107
+ none: false
95
108
  requirements:
96
- - - ">="
109
+ - - ! '>='
97
110
  - !ruby/object:Gem::Version
98
111
  version: '0'
99
112
  description: MoIP integration with Catarse crowdfunding platform
@@ -105,9 +118,9 @@ executables: []
105
118
  extensions: []
106
119
  extra_rdoc_files: []
107
120
  files:
108
- - ".gitignore"
109
- - ".rspec"
110
- - ".travis.yml"
121
+ - .gitignore
122
+ - .rspec
123
+ - .travis.yml
111
124
  - Gemfile
112
125
  - Gemfile.lock
113
126
  - MIT-LICENSE
@@ -181,26 +194,27 @@ files:
181
194
  - test/dummy/script/rails
182
195
  homepage: http://github.com/catarse/catarse_moip
183
196
  licenses: []
184
- metadata: {}
185
197
  post_install_message:
186
198
  rdoc_options: []
187
199
  require_paths:
188
200
  - lib
189
201
  required_ruby_version: !ruby/object:Gem::Requirement
202
+ none: false
190
203
  requirements:
191
- - - ">="
204
+ - - ! '>='
192
205
  - !ruby/object:Gem::Version
193
206
  version: '0'
194
207
  required_rubygems_version: !ruby/object:Gem::Requirement
208
+ none: false
195
209
  requirements:
196
- - - ">="
210
+ - - ! '>='
197
211
  - !ruby/object:Gem::Version
198
212
  version: '0'
199
213
  requirements: []
200
214
  rubyforge_project:
201
- rubygems_version: 2.2.0
215
+ rubygems_version: 1.8.25
202
216
  signing_key:
203
- specification_version: 4
217
+ specification_version: 3
204
218
  summary: MoIP integration with Catarse
205
219
  test_files:
206
220
  - spec/controllers/catarse_moip/moip_controller_spec.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: bf2d975f99e194636ca2089fca03c7aa785baf0a
4
- data.tar.gz: d966f3cedfcb618b6d1d518fd33a69a86fc64d03
5
- SHA512:
6
- metadata.gz: 7b7dd1e59ac69a094de99ce6bbc1b9d6b098b471991046fad4d8f5cba2014feb22f8b509e1dd357f65d0ba24c95f2f8fa355358368e1e9a06ac83708e4859d53
7
- data.tar.gz: 3b9049ca91ab1c5ff034f6cfa127979e529c81776a050657b332d72f5f643edaba488c5d79a7bfa10e380271aa2a9e9afef6222c6c9bbd1fd3093c92afc2dd7c