easypay 1.0.0 → 1.0.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.
@@ -36,23 +36,24 @@ module Easypay
36
36
  #ep_cin=8103&ep_user=OUTITUDE&ep_doc=TESTOUTITUDE0088690520120712152503
37
37
  payment_detail = Easypay::Client.new.get_payment_detail("", params[:ep_doc])
38
38
 
39
- payment_reference = PaymentReference.find_by_ep_reference_and_ep_key(payment_detail[:ep_reference], payment_detail[:t_key])
39
+ @payment_reference = PaymentReference.find_by_ep_reference_and_ep_key(payment_detail[:ep_reference], payment_detail[:t_key])
40
40
 
41
- payment_reference.update_attributes(:ep_doc => payment_detail[:ep_doc],
42
- :ep_payment_type => payment_detail[:ep_payment_type],
43
- :ep_value_fixed => payment_detail[:ep_value_fixed],
44
- :ep_value_var => payment_detail[:ep_value_var],
45
- :ep_value_tax => payment_detail[:ep_value_tax],
46
- :ep_value_transf => payment_detail[:ep_value_transf],
47
- :ep_date_transf => payment_detail[:ep_date_transf],
48
- :ep_date_read => payment_detail[:ep_date_read],
49
- :ep_status_read => payment_detail[:ep_status_read],
50
- :o_obs => payment_detail[:o_obs],
51
- :ep_date => payment_detail[:ep_date],
52
- :ep_status => 'finalized') unless payment_reference.nil?
53
-
54
- respond_to do |format|
55
- format.xml
41
+ if @payment_reference.present? and !@payment_reference.ep_status.match('finalized')
42
+
43
+ @payment_reference.update_attributes(:ep_doc => payment_detail[:ep_doc],
44
+ :ep_payment_type => payment_detail[:ep_payment_type],
45
+ :ep_value_fixed => payment_detail[:ep_value_fixed],
46
+ :ep_value_var => payment_detail[:ep_value_var],
47
+ :ep_value_tax => payment_detail[:ep_value_tax],
48
+ :ep_value_transf => payment_detail[:ep_value_transf],
49
+ :ep_date_transf => payment_detail[:ep_date_transf],
50
+ :ep_date_read => payment_detail[:ep_date_read],
51
+ :ep_status_read => payment_detail[:ep_status_read],
52
+ :o_obs => payment_detail[:o_obs],
53
+ :ep_date => payment_detail[:ep_date],
54
+ :ep_status => 'finalized')
55
+
56
+ redirect_to payment_notify_url(:payable_id => @payment_reference.payable_id)
56
57
  end
57
58
  end
58
59
 
@@ -8,5 +8,14 @@ module Easypay
8
8
  format.html
9
9
  end
10
10
  end
11
+
12
+ def notify
13
+ # After payment success
14
+ @payment_reference = PaymentReference.find_by_payable_id(params[:payable_id])
15
+
16
+ respond_to do |format|
17
+ format.html
18
+ end
19
+ end
11
20
  end
12
21
  end
@@ -20,8 +20,13 @@ module Easypay
20
20
  :ep_link => payment_reference[:payment_link],
21
21
  :ep_last_status => payment_reference[:ep_status],
22
22
  :request_log => payment_reference[:raw],
23
- :item_description => payment_reference[:item_description],
24
- :item_quantity => payment_reference[:item_quantity])
23
+ :item_description => self.item_description,
24
+ :item_quantity => self.item_quantity,
25
+ :o_name => self.o_name,
26
+ :o_description => self.o_description,
27
+ :o_obs => self.o_obs,
28
+ :o_email => self.o_email,
29
+ :o_mobile => self.o_mobile)
25
30
 
26
31
  return payment_reference
27
32
  else
@@ -1,4 +1,14 @@
1
1
  xml.instruct! :xml, :version => "1.0", :encoding => "ISO-8859-1"
2
2
  xml.get_detail do
3
- xml.ep_status "ok"
3
+ if @payment_reference.nil?
4
+ xml.ep_status "err1"
5
+ xml.ep_message "payment reference not found"
6
+ else
7
+ xml.ep_status "ok0"
8
+ xml.ep_message "doc gerado"
9
+ xml.ep_cin @payment_reference.ep_cin
10
+ xml.ep_user @payment_reference.ep_user
11
+ xml.ep_doc @payment_reference.ep_doc
12
+ xml.ep_key @payment_reference.ep_key
13
+ end
4
14
  end
@@ -0,0 +1,3 @@
1
+ <div>
2
+ You just received payment notification, refers to this <%=@payment_reference.id%>
3
+ </div>
@@ -4,5 +4,6 @@ Rails.application.routes.draw do
4
4
  match Easypay::Engine.config.easypay_forward_path => 'easypay/notifications#notification_to_forward'
5
5
  match Easypay::Engine.config.easypay_payment_path => 'easypay/notifications#notification_from_payment'
6
6
  match Easypay::Engine.config.redirect_after_payment_path => 'easypay/payments#complete', :as => :payment_redirect
7
+ match Easypay::Engine.config.redirect_payment_notification_path => 'easypay/payments#notify', :as => :payment_notify
7
8
 
8
9
  end
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "easypay"
6
- s.version = "1.0.0"
6
+ s.version = "1.0.1"
7
7
  s.authors = ["Guilherme Pereira"]
8
8
  s.email = ["guiferrpereira@gmail.com"]
9
9
  s.homepage = ""
@@ -40,7 +40,7 @@ module Easypay
40
40
  :o_name => object.o_name.nil? ? "" : URI.escape(object.o_name),
41
41
  :o_description => object.o_description.nil? ? "" : URI.escape(object.o_description),
42
42
  :o_obs => object.o_obs.nil? ? "" : URI.escape(object.o_obs),
43
- :o_mobile => object.o_mobile.nil? ? "" : object.o_mobile,
43
+ :o_mobile => object.o_mobile.nil? ? "" : URI.escape(object.o_mobile),
44
44
  :o_email => object.o_email.nil? ? "" : URI.escape(object.o_email)
45
45
  # :ep_rec => "yes", # Reccurrence stuff
46
46
  # :ep_rec_freq => recurrence,
@@ -11,6 +11,8 @@ module Easypay
11
11
  config.easypay_forward_path = '/easypay/forwards.:format'
12
12
  config.easypay_payment_path = '/easypay/payments.:format'
13
13
  config.redirect_after_payment_path = '/easypay/completed'
14
+ config.redirect_payment_notification_path = '/easypay/payment_completed'
15
+
14
16
  config.cin = 'cin provided by Easypay'
15
17
  config.user = 'user provided by Easypay'
16
18
  config.entity = 'entity provided by Easypay'
@@ -29,6 +31,7 @@ module Easypay
29
31
  config.easypay_forward_path += '/' unless config.easypay_forward_path.last == '/'
30
32
  config.easypay_payment_path += '/' unless config.easypay_payment_path.last == '/'
31
33
  config.redirect_after_payment_path += '/' unless config.redirect_after_payment_path.last == '/'
34
+ config.redirect_payment_notification_path += '/' unless config.redirect_payment_notification_path.last == '/'
32
35
  end
33
36
 
34
37
  initializer "static assets" do |app|
@@ -5,6 +5,8 @@ module Easypay
5
5
  config.easypay_forward_path = '/easypay/forwards.:format'
6
6
  config.easypay_payment_path = '/easypay/payments.:format'
7
7
  config.redirect_after_payment_path = '/easypay/completed'
8
+ config.redirect_payment_notification_path = '/easypay/payment_completed'
9
+
8
10
  config.cin = 'cin provided by Easypay'
9
11
  config.user = 'user provided by Easypay'
10
12
  config.entity = 'entity provided by Easypay'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easypay
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Guilherme Pereira
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-12 00:00:00 Z
18
+ date: 2012-07-20 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: nokogiri
@@ -53,6 +53,7 @@ files:
53
53
  - app/views/easypay/notifications/notification_from_payment.xml.builder
54
54
  - app/views/easypay/notifications/simple_notification.xml.builder
55
55
  - app/views/easypay/payments/complete.html.erb
56
+ - app/views/easypay/payments/notify.html.erb
56
57
  - config/routes.rb
57
58
  - easypay.gemspec
58
59
  - lib/acts_as_payable/base.rb