spree_pxpay_paymentmethod 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- data/app/controllers/checkout_controller_decorator.rb +0 -46
- data/app/controllers/px_pay_gateway_callback_controller.rb +39 -0
- data/app/models/spree/gateway/px_pay.rb +1 -1
- data/config/routes.rb +1 -1
- data/lib/spree_pxpay_paymentmethod/version.rb +1 -1
- data/spree_pxpay_paymentmethod.gemspec +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0ed69196f2d762ffc7af8d7713c2ccff87f75ea
|
4
|
+
data.tar.gz: 41b316335c8dc8c4d0d291b31b35fd84154a0845
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94100f96e04359d35946de612f7bf6f0fc3e1d46ae39386ec9c116977479be9161e1859bf0ffa48d39e9ceac1ed4c0cdaa8ac976615764b5365caab9ac52cdf1
|
7
|
+
data.tar.gz: 9e480e8474e2423f4074d99ca9eb4fb4986126871c5868b33d4a52e1897d37ef20b5e7bcddfd17e3414e30443ac8eaa95839f3ad8bb53d3724ba630e6fab725c
|
data/README.md
CHANGED
@@ -1,51 +1,5 @@
|
|
1
1
|
Spree::CheckoutController.class_eval do
|
2
2
|
|
3
|
-
skip_before_filter :verify_authenticity_token, :only => [:dps_callback]
|
4
|
-
skip_before_filter :load_order, :only => :px_pay_callback
|
5
|
-
skip_before_filter :ensure_order_not_completed, :only => :px_pay_callback
|
6
|
-
skip_before_filter :ensure_checkout_allowed , :only => :px_pay_callback
|
7
|
-
skip_before_filter :ensure_sufficient_stock_lines, :only => :px_pay_callback
|
8
|
-
skip_before_filter :ensure_valid_state , :only => :px_pay_callback
|
9
|
-
|
10
|
-
skip_before_filter :associate_user , :only => :px_pay_callback
|
11
|
-
skip_before_filter :check_authorization , :only => :px_pay_callback
|
12
|
-
skip_before_filter :apply_coupon_code , :only => :px_pay_callback
|
13
|
-
skip_before_filter :setup_for_current_state , :only => :px_pay_callback
|
14
|
-
|
15
|
-
# Handles the response from PxPay (success or failure) and updates the
|
16
|
-
# relevant Payment record. works with spree 2.1.7
|
17
|
-
def px_pay_callback
|
18
|
-
response = Pxpay::Response.new(params).response.to_hash
|
19
|
-
|
20
|
-
payment = Spree::Payment.find(response[:merchant_reference])
|
21
|
-
if payment
|
22
|
-
|
23
|
-
if response[:success] == '1'
|
24
|
-
payment.process!
|
25
|
-
payment.response_code = response[:auth_code]
|
26
|
-
payment.save
|
27
|
-
payment.complete
|
28
|
-
|
29
|
-
order = payment.order
|
30
|
-
order.state = 'complete'
|
31
|
-
order.completed_at = Time.now
|
32
|
-
order.save
|
33
|
-
|
34
|
-
order.deliver_order_confirmation_email
|
35
|
-
|
36
|
-
flash.notice = Spree.t(:order_processed_successfully)
|
37
|
-
redirect_to order_path(order, :token => order.token)
|
38
|
-
else
|
39
|
-
payment.void
|
40
|
-
redirect_to cart_path, :notice => 'Your credit card details were declined. Please check your details and try again.'
|
41
|
-
end
|
42
|
-
|
43
|
-
else
|
44
|
-
raise Spree::Core::GatewayError, "Unknown merchant_reference: #{response[:merchant_reference]}"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
3
|
private
|
50
4
|
|
51
5
|
alias :before_payment_without_px_pay_redirection :before_payment
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class PxPayGatewayCallbackController < ActionController::Base
|
2
|
+
|
3
|
+
include Spree::Core::Engine.routes.url_helpers
|
4
|
+
|
5
|
+
# Handles the response from PxPay (success or failure) and updates the
|
6
|
+
# relevant Payment record. works with spree 2.1.7
|
7
|
+
def callback
|
8
|
+
response = Pxpay::Response.new(params).response.to_hash
|
9
|
+
|
10
|
+
payment = Spree::Payment.find(response[:merchant_reference])
|
11
|
+
order = payment.order
|
12
|
+
|
13
|
+
if payment.checkout?
|
14
|
+
|
15
|
+
if response[:success] == '1'
|
16
|
+
payment.process!
|
17
|
+
payment.response_code = response[:auth_code]
|
18
|
+
payment.save
|
19
|
+
payment.complete
|
20
|
+
|
21
|
+
order.state = 'complete'
|
22
|
+
order.completed_at = Time.now
|
23
|
+
order.save
|
24
|
+
|
25
|
+
order.deliver_order_confirmation_email
|
26
|
+
else
|
27
|
+
payment.void
|
28
|
+
redirect_to cart_path, :notice => 'Your credit card details were declined. Please check your details and try again.'
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
flash.notice = Spree.t(:order_processed_successfully)
|
35
|
+
redirect_to order_path(order, :token => order.token)
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
@@ -57,7 +57,7 @@ private
|
|
57
57
|
|
58
58
|
# Calculates the url to return to after the PxPay process completes
|
59
59
|
def callback_url(host, protocol, port)
|
60
|
-
url_for(:controller => '
|
60
|
+
url_for(:controller => 'px_pay_gateway_callback', :action => 'callback', :only_path => false, :host => host, :protocol => protocol, :port => port)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/config/routes.rb
CHANGED
@@ -5,7 +5,7 @@ require 'spree_pxpay_paymentmethod/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'spree_pxpay_paymentmethod'
|
7
7
|
s.version = SpreePxpayPaymentmethod::VERSION
|
8
|
-
s.authors = ['
|
8
|
+
s.authors = ['The Foundry']
|
9
9
|
s.email = ['gems@foundryhq.com']
|
10
10
|
s.homepage = 'https://github.com/localist/spree_pxpay_paymentmethod'
|
11
11
|
s.summary = 'Spree PXPay payment method'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_pxpay_paymentmethod
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- The Foundry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_core
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- README.md
|
52
52
|
- Rakefile
|
53
53
|
- app/controllers/checkout_controller_decorator.rb
|
54
|
+
- app/controllers/px_pay_gateway_callback_controller.rb
|
54
55
|
- app/models/spree/gateway/px_pay.rb
|
55
56
|
- app/views/spree/admin/payments/source_views/_pxpay.html.erb
|
56
57
|
- config/routes.rb
|