e4commerce 0.6.0 → 0.6.1

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: a23f2116dc53f14dcd2be55933eeadba4e94e6d1
4
- data.tar.gz: 0ad18d07b95526b0093f42d235e503d6c047219d
3
+ metadata.gz: 32bbfad0c1b247da62e15952ff121bf6d226850f
4
+ data.tar.gz: 48f139894aa93fa7d93f7a25e5372913d7477b20
5
5
  SHA512:
6
- metadata.gz: 781ee9b4101760cf307d296c80100092c7e0ecf2c6fc9f532ec6ec3cbc8dcaf567bbfebc8332569ccd9fd9f52228fe4554836705b8c117844c04028478264a13
7
- data.tar.gz: a5e1fbfab8fd7678ff61d3141f1b37772cee59930527d6f9fec53906d73925f7a0556d34a7ebbe761c10bdcfd57915159d80edb93ea4662f0f27a35301e0a8a6
6
+ metadata.gz: 13275a3fd3163bd1d54c9a6a833a7457c4b26b44b64f507afa2318b0096650f1472af1d6adaad28ea23507a92b507d99827573c819f66d6f6a7ca37d8311d9c7
7
+ data.tar.gz: f71127fbbcea878837adae1dbf6ec8187ffcd157052c0ddbecb2b97cfa33b6ce70aded5b384650a2d74f93c8be2e6791e2285b9b6c7d89efa1034d8a72182c05
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- e4commerce (0.6.0)
4
+ e4commerce (0.6.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -0,0 +1,26 @@
1
+ class BancoBrasilBillet < BankBillet
2
+
3
+ def create_payment(client)
4
+ #Generates and returns bank billet given total price
5
+ current_time = DateTime.now
6
+
7
+ @boleto = Brcobranca::Boleto::BancoBrasil.new :cedente => client.cedente,
8
+ :documento_cedente => client.documento_cedente,
9
+ :sacado => client.sacado,
10
+ :sacado_documento => client.sacado_documento,
11
+ :valor => self.calculate_total,
12
+ :agencia => client.agencia,
13
+ :conta_corrente => client.conta_corrente,
14
+ :convenio => client.convenio,
15
+ :numero_documento => client.numero_documento,
16
+ :data_vencimento => client.data_vencimento,
17
+ :data_documento => client.data_documento,
18
+ :instrucao1 => client.instrucao1,
19
+ :instrucao2 => client.instrucao2,
20
+ :instrucao3 => client.instrucao3,
21
+ :sacado_endereco => client.sacado_endereco
22
+
23
+ send_data @boleto.to_pdf, :filename => "boletoBB.pdf"
24
+ end
25
+
26
+ end
@@ -1,27 +1,11 @@
1
1
  module E4commerce
2
+
2
3
  require "date"
3
4
  require "abstraction"
5
+ require "client"
4
6
  require "brcobranca"
5
7
 
6
8
  class BankBillet < E4CPayment
7
- attr_accessor :bank
8
-
9
- def initialize(bank)
10
-
11
- @bank = [ :itau => Brcobranca::Boleto::BancoItau.new,
12
- :bb => Brcobranca::Boleto:BancoBrasil.new
13
- :hsbc => Brcobranca::Boleto::Hsbc.new,
14
- :santander => Brcobranca::Boleto::Santander.new,
15
- :bradesco => Brcobranca::Boleto::Bradesco.new,
16
- :caixa => Brcobranca::Boleto::Caixa.new
17
- :sicredi => Brcobranca::Boleto::Sicredi.new,
18
- :sicoob => Brcobranca::Boleto::Sicoob.new,
19
- :banestes => Brcobranca::Boleto::Banestes.new
20
-
21
-
22
- ]
23
-
24
- end
25
9
 
26
10
  def calculate_total(product_list)
27
11
  # Determine total price sum of products in list
@@ -33,66 +17,10 @@ module E4commerce
33
17
  return self.total
34
18
  end
35
19
 
36
- def create_payment (bank)
37
- # Generates and returns bank billet given total price
38
- current_time = DateTime.now
39
-
40
- @boleto = @bank[bank]
41
- @boleto.cedente = "Kivanio Barbosa"
42
- @boleto.documento_cedente = "12345678912"
43
- @boleto.sacado = "Claudio Pozzebom"
44
- @boleto.sacado_documento = "12345678900"
45
- @boleto.avalista = "Kivanio Barbosa"
46
- @boleto.avalista_documento = "12345678912"
47
- @boleto.valor = self.total
48
- @boleto.agencia = "4042"
49
- @boleto.conta_corrente = "61900"
50
- @boleto.variacao = "19"
51
-
52
- case banco
53
- when :itau
54
- # ITAU
55
- # O que diferencia um tipo de boleto de outro, dentro do itáu é o tipo de carteira utilizado.
56
- @boleto.convenio = "12345"
57
- when :bb
58
- # BB
59
- # O que diferencia um tipo de boleto de outro, dentro do Banco do Brasil é a quantidade de dígitos do convênio.
60
- @boleto.convenio = "1238798"
61
- when :hsbc
62
- # HSBC
63
- # O que diferencia um tipo de boleto de outro, dentro do HSBC é a quantidade de dígitos do número do documento.
64
- @boleto.numero_documento = "102008"
65
- when :caixa
66
- # CAIXA
67
- @boleto.convenio = "100000"
68
- when :sicredi
69
- @boleto.byte_idt = "2"
70
- @boleto.posto = "18"
71
-
72
- when :sicoob
73
- @boleto.convenio = "1238798"
74
- when :banestes
75
- @boleto.variacao = "2"
76
- else
77
- @boleto.convenio = "1238798"
78
- end
79
-
80
- @boleto.numero_documento = "111"
81
- @boleto.data_vencimento = "2008-02-01".to_date
82
- @boleto.data_documento = "2008-02-01".to_date
83
- @boleto.instrucao1 = "Pagável na rede bancária até a data de vencimento."
84
- @boleto.instrucao2 = "Juros de mora de 2.0% mensal(R$ 0,09 ao dia)"
85
- @boleto.instrucao3 = "DESCONTO DE R$ 29,50 APÓS 05/11/2006 ATÉ 15/11/2006"
86
- @boleto.instrucao4 = "NÃO RECEBER APÓS 15/11/2006"
87
- @boleto.instrucao5 = "Após vencimento pagável somente nas agências do Banco do Brasil"
88
- @boleto.instrucao6 = "ACRESCER R$ 4,00 REFERENTE AO BOLETO BANCÁRIO"
89
- @boleto.sacado_endereco = "Av. Rubéns de Mendonça, 157 - 78008-000 - Cuiabá/MT"
90
-
91
- formato=params[:boleto][:formato].to_sym
92
- headers['Content-Type']=FORMATOS_SUPORTADOS[formato]
93
- send_data @boleto.to(formato), :filename => "boleto_#{banco}.#{formato}"
94
-
95
- end
20
+ def create_payment(client)
21
+
22
+ raise NotImplementedError, "Child must implement method"
23
+ end
96
24
 
97
25
  def add_product(product)
98
26
  # Adds a product or an array of products to the products list
@@ -0,0 +1,24 @@
1
+ class BradescoBillet < BankBillet
2
+ def create_payment(client)
3
+ #Generates and returns bank billet given total price
4
+ current_time = DateTime.now
5
+
6
+ @boleto = Brcobranca::Boleto::Bradesco.new :cedente => client.cedente,
7
+ :documento_cedente => client.documento_cedente,
8
+ :sacado => client.sacado,
9
+ :sacado_documento => client.sacado_documento,
10
+ :valor => self.calculate_total,
11
+ :agencia => client.agencia,
12
+ :conta_corrente => client.conta_corrente,
13
+ :convenio => client.convenio,
14
+ :numero_documento => client.numero_documento,
15
+ :data_vencimento => client.data_vencimento,
16
+ :data_documento => client.data_documento,
17
+ :instrucao1 => client.instrucao1,
18
+ :instrucao2 => client.instrucao2,
19
+ :instrucao3 => client.instrucao3,
20
+ :sacado_endereco => client.sacado_endereco
21
+
22
+ send_data @boleto.to_pdf, :filename => "boletoBradesco.pdf"
23
+ end
24
+ end
@@ -0,0 +1,39 @@
1
+ module E4commerce
2
+
3
+ class Client
4
+
5
+ attr_accessor :cedente
6
+ attr_accessor :documento_cedente
7
+ attr_accessor :sacado
8
+ attr_accessor :sacado_documento
9
+ attr_accessor :agencia
10
+ attr_accessor :conta_corrente
11
+ attr_accessor :convenio
12
+ attr_accessor :numero_documento
13
+ attr_accessor :data_vencimento
14
+ attr_accessor :data_documento
15
+ attr_accessor :instrucao1
16
+ attr_accessor :instrucao2
17
+ attr_accessor :instrucao3
18
+ attr_accessor :sacado_endereco
19
+
20
+ def initialize(cedent, documento_cedente, sacado, sacado_documento, agencia, conta_corrente,
21
+ convenio, numero_documento, data_vencimento, data_documento, instrucao1,instrucao2,instrucao3,
22
+ instrucao4, sacado_endereco)
23
+ @cedente = cedente
24
+ @documento_cedente = documento_cedente
25
+ @sacado = sacado
26
+ @sacado_documento = sacado_documento
27
+ @agencia = agencia
28
+ @conta_corrente = conta_corrente
29
+ @convenio = convenio
30
+ @numero_documento = numero_documento
31
+ @data_vencimento = data_vencimento
32
+ @data_documento = data_documento
33
+ @instrucao1 = instrucao1
34
+ @instrucao2 = instrucao2
35
+ @instrucao3 = instrucao3
36
+ @sacado_endereco = sacado_endereco
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,25 @@
1
+ class ItauBillet < BankBillet
2
+
3
+ def create_payment(client)
4
+ #Generates and returns bank billet given total price
5
+ current_time = DateTime.now
6
+
7
+ @boleto = Brcobranca::Boleto::BancoItau.new :cedente => client.cedente,
8
+ :documento_cedente => client.documento_cedente,
9
+ :sacado => client.sacado,
10
+ :sacado_documento => client.sacado_documento,
11
+ :valor => self.calculate_total,
12
+ :agencia => client.agencia,
13
+ :conta_corrente => client.conta_corrente,
14
+ :convenio => client.convenio,
15
+ :numero_documento => client.numero_documento,
16
+ :data_vencimento => client.data_vencimento,
17
+ :data_documento => client.data_documento,
18
+ :instrucao1 => client.instrucao1,
19
+ :instrucao2 => client.instrucao2,
20
+ :instrucao3 => client.instrucao3,
21
+ :sacado_endereco => client.sacado_endereco
22
+
23
+ send_data @boleto.to_pdf, :filename => "boletoItau.pdf"
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ class SantanderBillet < BankBillet
2
+ def create_payment(client)
3
+ #Generates and returns bank billet given total price
4
+ current_time = DateTime.now
5
+
6
+ @boleto = Brcobranca::Boleto::Santander.new :cedente => client.cedente,
7
+ :documento_cedente => client.documento_cedente,
8
+ :sacado => client.sacado,
9
+ :sacado_documento => client.sacado_documento,
10
+ :valor => self.calculate_total,
11
+ :agencia => client.agencia,
12
+ :conta_corrente => client.conta_corrente,
13
+ :convenio => client.convenio,
14
+ :numero_documento => client.numero_documento,
15
+ :data_vencimento => client.data_vencimento,
16
+ :data_documento => client.data_documento,
17
+ :instrucao1 => client.instrucao1,
18
+ :instrucao2 => client.instrucao2,
19
+ :instrucao3 => client.instrucao3,
20
+ :sacado_endereco => client.sacado_endereco
21
+
22
+ send_data @boleto.to_pdf, :filename => "boletoSantander.pdf"
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module E4commerce
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: e4commerce
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Pimentel
@@ -99,15 +99,17 @@ files:
99
99
  - database.db
100
100
  - e4commerce.gemspec
101
101
  - lib/e4commerce.rb
102
- - lib/e4commerce/Nike.rb
102
+ - lib/e4commerce/banco_brasil_billet.rb
103
103
  - lib/e4commerce/bank_billet.rb
104
+ - lib/e4commerce/bradesco_billet.rb
105
+ - lib/e4commerce/client.rb
106
+ - lib/e4commerce/itau_billet.rb
104
107
  - lib/e4commerce/notifications_controller.rb
105
108
  - lib/e4commerce/payment.rb
106
109
  - lib/e4commerce/product.rb
107
110
  - lib/e4commerce/ps_checkout_template.rb
111
+ - lib/e4commerce/santander_billet.rb
108
112
  - lib/e4commerce/version.rb
109
- - lib/pagseguro/checkout_controller.rb
110
- - lib/pagseguro/notifications_controller.rb
111
113
  - lib/tasks/boleto.rake
112
114
  - lib/tasks/pagseguro.rake
113
115
  - lib/tasks/product.rake
@@ -1,4 +0,0 @@
1
- class Nike < Produto
2
- validates :numero, presence: true
3
- validates :cor, presence: true
4
- end
@@ -1,48 +0,0 @@
1
- class CheckoutController < ApplicationController
2
- def create
3
- # O modo como você irá armazenar os produtos que estão sendo comprados
4
- # depende de você. Neste caso, temos um modelo Order que referência os
5
- # produtos que estão sendo comprados.
6
- order = Order.find(params[:id])
7
-
8
- payment = PagSeguro::PaymentRequest.new
9
-
10
- # Você também pode fazer o request de pagamento usando credenciais
11
- # diferentes, como no exemplo abaixo
12
-
13
- payment = PagSeguro::PaymentRequest.new(email: 'abc@email', token: 'token')
14
-
15
- payment.reference = order.id
16
- payment.notification_url = notifications_url
17
- payment.redirect_url = processing_url
18
-
19
- order.products.each do |product|
20
- payment.items << {
21
- id: product.id,
22
- description: product.title,
23
- amount: product.price,
24
- weight: product.weight
25
- }
26
- end
27
-
28
- # Caso você precise passar parâmetros para a api que ainda não foram
29
- # mapeados na gem, você pode fazer de maneira dinâmica utilizando um
30
- # simples hash.
31
- payment.extra_params << { paramName: 'paramValue' }
32
- payment.extra_params << { senderBirthDate: '07/05/1981' }
33
- payment.extra_params << { extraAmount: '-15.00' }
34
-
35
- response = payment.register
36
-
37
- # Caso o processo de checkout tenha dado errado, lança uma exceção.
38
- # Assim, um serviço de rastreamento de exceções ou até mesmo a gem
39
- # exception_notification poderá notificar sobre o ocorrido.
40
- #
41
- # Se estiver tudo certo, redireciona o comprador para o PagSeguro.
42
- if response.errors.any?
43
- raise response.errors.join("\n")
44
- else
45
- redirect_to response.url
46
- end
47
- end
48
- end
@@ -1,15 +0,0 @@
1
- class NotificationsController < ApplicationController
2
- skip_before_filter :verify_authenticity_token, only: :create
3
-
4
- def create
5
- transaction = PagSeguro::Transaction.find_by_notification_code(params[:notificationCode])
6
-
7
- if transaction.errors.empty?
8
- # Processa a notificação. A melhor maneira de se fazer isso é realizar
9
- # o processamento em background. Uma boa alternativa para isso é a
10
- # biblioteca Sidekiq.
11
- end
12
-
13
- render nothing: true, status: 200
14
- end
15
- end