spree_pagseguro_simple 0.9 → 1.0.alpha
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/.gitignore +1 -0
- data/README.md +14 -5
- data/app/controllers/spree/pagseguro_controller.rb +21 -12
- data/app/models/spree/pag_seguro_transaction.rb +3 -0
- data/app/views/spree/shared/_pag_seguro_info.html.erb +7 -3
- data/config/locales/pt-BR.yml +3 -0
- data/lib/spree_pagseguro_simple/gateway.rb +1 -1
- data/lib/spree_pagseguro_simple/version.rb +1 -1
- metadata +5 -6
- data/.metrics +0 -28
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2d9ecfb3fd9ce2727574bb6510b5f718b9f97c21
|
|
4
|
+
data.tar.gz: 565d3c092c7eea798344b7d83791e794c34bafd6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de149c0ac7f33d425580c06a787e9a55d7f27a0d27acc1f163ac92d54a83328750a9434cdb5e98da52e0bab083b21bcd6b33359163130f466f2ba45ac821add0
|
|
7
|
+
data.tar.gz: 833f4f9734e6fd329b7cfa98d1a4a10c4861a1c8c6906b745bd771e9863ded5f4d5590623b4d2c8760bba2c6af2712ca99ddf3e42a3e0819129cd2ee98a9a5c0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
# Spree PagSeguroSimple
|
|
1
|
+
# Spree PagSeguroSimple
|
|
2
2
|
|
|
3
3
|
[](https://codeclimate.com/github/locomotivapro/spree_pagseguro_simple)
|
|
4
|
+
[](http://badge.fury.io/rb/spree_pagseguro_simple)
|
|
4
5
|
|
|
5
6
|
Add support for Pagseguro checkout as a payment method.
|
|
6
7
|
__Only tested on Spree 3.0__
|
|
@@ -23,15 +24,23 @@ This gem approach takes in consideration that a incomplete order with an approve
|
|
|
23
24
|
|
|
24
25
|
2. Click `Create`, and enter your Store's Pagseguro Email and Token in the fields provided.
|
|
25
26
|
|
|
26
|
-
3.
|
|
27
|
+
3. By default sandbox env is activated. To allow production env you
|
|
28
|
+
shoud define ENV['PAGSEGURO_ENV'].
|
|
29
|
+
|
|
30
|
+
4. `Save` and enjoy!
|
|
27
31
|
|
|
28
32
|
4. Is important to go to general settings in spree and configure the store url for redirects and notifications
|
|
29
33
|
|
|
34
|
+
## To-Do
|
|
35
|
+
|
|
36
|
+
- Need to add test coverage to gem
|
|
37
|
+
- Configure enviroment to use payment method preference
|
|
38
|
+
- Work in notification controller action
|
|
39
|
+
- Improve view in order#show
|
|
40
|
+
|
|
30
41
|
Testing
|
|
31
42
|
-------
|
|
32
43
|
|
|
33
|
-
*Need to write lots of tests*
|
|
34
|
-
|
|
35
44
|
To make real tests register in PagSeguro sandbox and configure the payment method as test.
|
|
36
45
|
|
|
37
46
|
Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
|
|
@@ -44,4 +53,4 @@ Disclaimer
|
|
|
44
53
|
|
|
45
54
|
This gem is inspired by [João Netto gem](https://github.com/jnettome/spree_pagseguro) but updated to spree 3 and using a new approach to checkout flow.
|
|
46
55
|
|
|
47
|
-
Copyright (c) 2013-2015 [
|
|
56
|
+
Copyright (c) 2013-2015 [Locomotiva.pro](http://locomotiva.pro), released under the New BSD License
|
|
@@ -5,29 +5,38 @@ module Spree
|
|
|
5
5
|
def callback
|
|
6
6
|
@order = Spree::Order.find_by_number(params[:order])
|
|
7
7
|
|
|
8
|
-
pagseguro_transaction = Spree::
|
|
8
|
+
pagseguro_transaction = Spree::PagSeguroTransaction.find_by_order_id(@order.number)
|
|
9
9
|
pagseguro_transaction.update_attribute :state, 'waiting'
|
|
10
10
|
|
|
11
|
+
flash[:notice] = Spree.t(:pagseguro_transaction_success)
|
|
11
12
|
redirect_to spree.order_path(@order)
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
def notify
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
return unless request.post?
|
|
17
|
+
payment_method = Spree::PaymentMethod.where(type: 'Spree::PaymentMethod::Pagseguro').last
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
email = payment_method.preferred_email
|
|
20
|
+
token = payment_method.preferred_token
|
|
21
|
+
_notification_code = params[:notificationCode]
|
|
20
22
|
|
|
23
|
+
notification = PagSeguro::Notification.new(email, token, _notification_code)
|
|
21
24
|
@order = Spree::Order.find_by_number(notification.reference)
|
|
22
|
-
payment = @order.payments.where(:state => "checkout",
|
|
23
|
-
:payment_method_id => payment_method.id).last
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
payment = @order.payments.where(state: "checkout",
|
|
27
|
+
payment_method_id: payment_method.id,
|
|
28
|
+
amount: notification.gross_amount).last
|
|
29
|
+
|
|
30
|
+
if payment
|
|
31
|
+
if notification.approved?
|
|
32
|
+
payment.complete!
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
if notification.cancelled? || notification.returned?
|
|
36
|
+
payment.void!
|
|
37
|
+
end
|
|
28
38
|
else
|
|
29
|
-
|
|
30
|
-
payment.failure!
|
|
39
|
+
raise StandardError
|
|
31
40
|
end
|
|
32
41
|
|
|
33
42
|
render nothing: true, head: :ok
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<% ps_transaction = SpreePagseguroSimple::Gateway.new(payment) %>
|
|
2
2
|
<% if ps_transaction.is_not_completed? %>
|
|
3
|
-
<p>Clique no botão abaixo e realize o pagamento</p>
|
|
4
|
-
<%= link_to image_tag('btn-pagseguro.gif'), ps_transaction.payment_url
|
|
3
|
+
<p><strong>Clique no botão abaixo e realize o pagamento</strong></p>
|
|
4
|
+
<%= link_to image_tag('btn-pagseguro.gif'), ps_transaction.payment_url %>
|
|
5
5
|
<% else %>
|
|
6
|
-
|
|
6
|
+
<% if payment.completed? %>
|
|
7
|
+
<p class='label label-success'>Pagamento aprovado</p>
|
|
8
|
+
<% else %>
|
|
9
|
+
<p class="text-info">Seu pagamento foi recebido. Assim que o PagSeguro aprovar a transação seu pedido entrará em produção.</p>
|
|
10
|
+
<% end %>
|
|
7
11
|
<% end %>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_pagseguro_simple
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 1.0.alpha
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Denis Antoniazzi Tierno
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: spree_core
|
|
@@ -185,9 +185,7 @@ extensions: []
|
|
|
185
185
|
extra_rdoc_files: []
|
|
186
186
|
files:
|
|
187
187
|
- ".gitignore"
|
|
188
|
-
- ".metrics"
|
|
189
188
|
- ".rspec"
|
|
190
|
-
- ".travis.yml"
|
|
191
189
|
- Gemfile
|
|
192
190
|
- LICENSE
|
|
193
191
|
- README.md
|
|
@@ -203,6 +201,7 @@ files:
|
|
|
203
201
|
- app/views/spree/shared/_pag_seguro_info.html.erb
|
|
204
202
|
- app/views/spree/shared/_payments_with_pagseguro.html.erb
|
|
205
203
|
- config/locales/en.yml
|
|
204
|
+
- config/locales/pt-BR.yml
|
|
206
205
|
- config/routes.rb
|
|
207
206
|
- db/migrate/20150506164744_create_spree_pag_seguro_transactions.rb
|
|
208
207
|
- lib/generators/spree_pagseguro_simple/install/install_generator.rb
|
|
@@ -225,9 +224,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
225
224
|
version: 2.0.0
|
|
226
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
226
|
requirements:
|
|
228
|
-
- - "
|
|
227
|
+
- - ">"
|
|
229
228
|
- !ruby/object:Gem::Version
|
|
230
|
-
version:
|
|
229
|
+
version: 1.3.1
|
|
231
230
|
requirements:
|
|
232
231
|
- none
|
|
233
232
|
rubyforge_project:
|
data/.metrics
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
MetricFu::Configuration.run do |config|
|
|
3
|
-
config.configure_metrics.each do |metric|
|
|
4
|
-
metric.enabled = false
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
config.configure_metric(:rcov) do |rcov|
|
|
8
|
-
rcov.enabled = true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
config.configure_metric(:cane) do |cane|
|
|
12
|
-
cane.enabled = true
|
|
13
|
-
cane.abc_max = 15
|
|
14
|
-
cane.line_length = 90
|
|
15
|
-
cane.no_doc = 'y'
|
|
16
|
-
cane.no_readme = 'y'
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
config.configure_metric(:flay) do |flay|
|
|
20
|
-
flay.enabled = true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
config.configure_metric(:flog) do |flog|
|
|
24
|
-
flog.enabled = true
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
config.configure_formatter(:html)
|
|
28
|
-
end
|