easypay 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/app/controllers/easypay/notifications_controller.rb +4 -2
- data/app/models/easypay/payment_reference.rb +8 -4
- data/app/views/easypay/notifications/{notification_from_mb_payment.xml.builder → notification_from_payment.xml.builder} +0 -0
- data/app/views/easypay/notifications/simple_notification.xml.builder +23 -22
- data/easypay.gemspec +1 -1
- data/lib/acts_as_payable/base.rb +5 -3
- data/lib/easypay/client.rb +1 -5
- data/lib/rails/generators/easypay/templates/migration.rb +2 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
1.0.0
|
@@ -8,7 +8,7 @@ module Easypay
|
|
8
8
|
def simple_notification
|
9
9
|
# c=PT&e=10611&r=810302231&v=7&l=PT&t_key=
|
10
10
|
@payment_reference = PaymentReference.find_by_ep_reference_and_ep_value(params[:r], params[:v])
|
11
|
-
|
11
|
+
@atts = params
|
12
12
|
respond_to do |format|
|
13
13
|
format.xml
|
14
14
|
end
|
@@ -18,13 +18,15 @@ module Easypay
|
|
18
18
|
# e=10611&r=810302231&v=7&s=ok&k=C36D4995CBF3574ADD8664BA26514181C9EA8737&t_key=CCCSOKCSO
|
19
19
|
payment_reference = PaymentReference.find_by_ep_reference_and_ep_key(params[:r], params[:t_key])
|
20
20
|
|
21
|
-
if params[:s].starts_with? "ok" and params[:k].present?
|
21
|
+
if params[:s].starts_with? "ok" and params[:k].present? and payment_reference.present?
|
22
22
|
payment_reference.update_attribute(:o_key, params[:k]) unless payment_reference.nil?
|
23
23
|
|
24
24
|
payment_detail = Easypay::Client.new.request_payment(params[:e], params[:r], params[:v], params[:k])
|
25
25
|
|
26
26
|
payment_reference.update_attributes(:ep_last_status => payment_detail[:ep_status],
|
27
27
|
:ep_message => payment_detail[:ep_message]) unless payment_reference.nil?
|
28
|
+
elsif payment_reference.present?
|
29
|
+
payment_reference.update_attribute(:ep_last_status, params[:s])
|
28
30
|
end
|
29
31
|
|
30
32
|
redirect_to payment_redirect_url(:status => params[:s], :ep_key => params[:t_key])
|
@@ -4,13 +4,13 @@ module Easypay
|
|
4
4
|
|
5
5
|
attr_protected
|
6
6
|
|
7
|
-
def process(object)
|
7
|
+
def process(object, options = {})
|
8
8
|
@object = object
|
9
9
|
|
10
10
|
if compliant?
|
11
11
|
self.update_attributes(handle_model_methods)
|
12
12
|
|
13
|
-
payment_reference = Easypay::Client.new.create_reference(self)
|
13
|
+
payment_reference = Easypay::Client.new(options).create_reference(self)
|
14
14
|
|
15
15
|
self.update_attributes( :ep_message => payment_reference[:ep_message],
|
16
16
|
:ep_reference => payment_reference[:ep_reference],
|
@@ -19,7 +19,9 @@ module Easypay
|
|
19
19
|
:ep_entity => payment_reference[:ep_entity],
|
20
20
|
:ep_link => payment_reference[:payment_link],
|
21
21
|
:ep_last_status => payment_reference[:ep_status],
|
22
|
-
:request_log => payment_reference[:raw]
|
22
|
+
:request_log => payment_reference[:raw],
|
23
|
+
:item_description => payment_reference[:item_description],
|
24
|
+
:item_quantity => payment_reference[:item_quantity])
|
23
25
|
|
24
26
|
return payment_reference
|
25
27
|
else
|
@@ -51,7 +53,9 @@ module Easypay
|
|
51
53
|
:o_description => @object.easypay_options[:o_description],
|
52
54
|
:o_obs => @object.easypay_options[:o_obs],
|
53
55
|
:o_email => @object.easypay_options[:o_email],
|
54
|
-
:o_mobile => @object.easypay_options[:o_mobile]
|
56
|
+
:o_mobile => @object.easypay_options[:o_mobile],
|
57
|
+
:item_description => @object.easypay_options[:item_description],
|
58
|
+
:item_quantity => @object.easypay_options[:item_quantity]
|
55
59
|
}
|
56
60
|
end
|
57
61
|
|
File without changes
|
@@ -3,9 +3,9 @@ xml.get_detail do
|
|
3
3
|
if @payment_reference.nil?
|
4
4
|
xml.ep_status "err"
|
5
5
|
xml.ep_message "error mensage"
|
6
|
-
xml.ep_entity
|
7
|
-
xml.ep_ref
|
8
|
-
xml.ep_value
|
6
|
+
xml.ep_entity @atts[:e] if @atts[:e].present?
|
7
|
+
xml.ep_ref @atts[:r] if @atts[:r].present?
|
8
|
+
xml.ep_value @atts[:v] if @atts[:v].present?
|
9
9
|
else
|
10
10
|
xml.ep_status "ok"
|
11
11
|
xml.ep_message "success message"
|
@@ -13,30 +13,31 @@ xml.get_detail do
|
|
13
13
|
xml.ep_reference @payment_reference.ep_reference
|
14
14
|
xml.ep_value @payment_reference.ep_value
|
15
15
|
xml.t_key @payment_reference.ep_key
|
16
|
+
|
16
17
|
xml.order_info do
|
17
|
-
xml.total_taxes "
|
18
|
+
# xml.total_taxes " "
|
18
19
|
xml.total_including_taxes @payment_reference.ep_value
|
19
|
-
|
20
|
-
xml.bill_fiscal_number "
|
21
|
-
xml.bill_name "
|
22
|
-
xml.bill_address_1 "
|
23
|
-
xml.bill_address_2 "
|
24
|
-
xml.bill_city "
|
25
|
-
xml.bill_zip_code "
|
26
|
-
xml.bill_country "
|
27
|
-
|
28
|
-
xml.ship_fiscal_number "
|
29
|
-
xml.shipp_name "
|
30
|
-
xml.shipp_address_1 "
|
31
|
-
xml.shipp_address_2 "
|
32
|
-
xml.shipp_city "
|
33
|
-
xml.shipp_zip_code "
|
34
|
-
xml.shipp_country "
|
20
|
+
# TODO - Include this information in future
|
21
|
+
# xml.bill_fiscal_number " "
|
22
|
+
# xml.bill_name " "
|
23
|
+
# xml.bill_address_1 " "
|
24
|
+
# xml.bill_address_2 " "
|
25
|
+
# xml.bill_city " "
|
26
|
+
# xml.bill_zip_code " "
|
27
|
+
# xml.bill_country " "
|
28
|
+
#
|
29
|
+
# xml.ship_fiscal_number " "
|
30
|
+
# xml.shipp_name " "
|
31
|
+
# xml.shipp_address_1 " "
|
32
|
+
# xml.shipp_address_2 " "
|
33
|
+
# xml.shipp_city " "
|
34
|
+
# xml.shipp_zip_code " "
|
35
|
+
# xml.shipp_country " "
|
35
36
|
end
|
36
37
|
xml.order_detail do
|
37
38
|
xml.item do
|
38
|
-
xml.item_description
|
39
|
-
xml.item_quantity
|
39
|
+
xml.item_description @payment_reference.item_description
|
40
|
+
xml.item_quantity @payment_reference.item_quantity
|
40
41
|
xml.item_total @payment_reference.ep_value
|
41
42
|
end
|
42
43
|
end
|
data/easypay.gemspec
CHANGED
data/lib/acts_as_payable/base.rb
CHANGED
@@ -22,7 +22,9 @@ module Easypay
|
|
22
22
|
:o_description => args[:description] || "description",
|
23
23
|
:o_obs => args[:obs] || "obs",
|
24
24
|
:o_email => args[:email] || "email",
|
25
|
-
:o_mobile
|
25
|
+
:o_mobile => args[:mobile] || "mobile",
|
26
|
+
:item_description => args[:item_description] || "item_description",
|
27
|
+
:item_quantity => args[:item_quantity] || "item_quantity"
|
26
28
|
}
|
27
29
|
end
|
28
30
|
|
@@ -32,8 +34,8 @@ module Easypay
|
|
32
34
|
|
33
35
|
module InstanceMethods
|
34
36
|
|
35
|
-
def create_payment_reference
|
36
|
-
Easypay::PaymentReference.new.process(self)
|
37
|
+
def create_payment_reference(options={})
|
38
|
+
Easypay::PaymentReference.new.process(self, options)
|
37
39
|
end
|
38
40
|
|
39
41
|
end # InstanceMethods
|
data/lib/easypay/client.rb
CHANGED
@@ -32,9 +32,7 @@ module Easypay
|
|
32
32
|
|
33
33
|
# API methods
|
34
34
|
|
35
|
-
# def create_reference(token, value, lang, client_name=nil, client_mobile=nil, client_email=nil, client_observation=nil, item_description=nil)
|
36
35
|
def create_reference(object)
|
37
|
-
|
38
36
|
get "01BG",
|
39
37
|
:t_key => object.ep_key,
|
40
38
|
:t_value => object.ep_value,
|
@@ -142,13 +140,11 @@ module Easypay
|
|
142
140
|
result[:payment_link] = doc.at("ep_link").text unless doc.at("ep_link").nil?
|
143
141
|
result[:ep_reference] = doc.at("ep_reference").text unless doc.at("ep_reference").nil?
|
144
142
|
end
|
145
|
-
|
143
|
+
# TODO - ugly i know - must create decent Parser
|
146
144
|
result[:ep_status] = doc.at("ep_status").text unless doc.at("ep_status").nil?
|
147
145
|
result[:ep_cin] = doc.at("ep_cin").text unless doc.at("ep_cin").nil?
|
148
146
|
result[:ep_user] = doc.at("ep_user").text unless doc.at("ep_user").nil?
|
149
147
|
result[:ep_entity] = doc.at("ep_entity").text unless doc.at("ep_entity").nil?
|
150
|
-
|
151
|
-
|
152
148
|
result[:t_key] = doc.at("t_key").text unless doc.at("t_key").nil?
|
153
149
|
result[:ep_doc] = doc.at("ep_doc").text unless doc.at("ep_doc").nil?
|
154
150
|
result[:ep_payment_type] = doc.at("ep_payment_type").text unless doc.at("ep_payment_type").nil?
|
metadata
CHANGED
@@ -4,10 +4,10 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.4
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Guilherme Pereira
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- app/controllers/easypay/payments_controller.rb
|
51
51
|
- app/models/easypay/log.rb
|
52
52
|
- app/models/easypay/payment_reference.rb
|
53
|
-
- app/views/easypay/notifications/
|
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
56
|
- config/routes.rb
|