spree_pxpay_paymentmethod 1.0.0 → 2.0.0
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 +7 -0
- data/README.md +10 -7
- data/app/controllers/checkout_controller_decorator.rb +28 -17
- data/app/models/spree/gateway/px_pay.rb +5 -6
- data/config/routes.rb +1 -1
- data/lib/spree_pxpay_paymentmethod/version.rb +1 -1
- data/spree_pxpay_paymentmethod.gemspec +11 -11
- metadata +49 -52
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7f645e0b00d472f1025931be9f2c0ca76db24920
|
4
|
+
data.tar.gz: 486c54536cca522fb8c59e0c3509f945f387c953
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ab938e559ca0d1c01fb4f78855bab6de175350855a79245d611b4ffb9ad8ec5c3effe439c06a1928a819554a2e11deafddc0630ea8bbef86de6c5ba9753b185
|
7
|
+
data.tar.gz: c40baf3343672e169ee7d9c85a1b58e99e2a1c0724a84b3afb5b359b7fde33928f2907929d092df662edb842a4d7ea64e53a957d0f152a94ea0cfc394c54c5e2
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Spree PxPay Gateway
|
2
2
|
|
3
|
-
This is a gem for Spree
|
3
|
+
This is a gem for Spree 2.1.7 which adds PXPay (paymentexpress.com - a NZ and
|
4
4
|
Australian Payment Processor) as a Payment Method.
|
5
5
|
|
6
6
|
This is does not use Active Merchant - this is not the version of the gateway
|
@@ -19,18 +19,21 @@ this. You can manually create payments on the back-end as per usual.
|
|
19
19
|
|
20
20
|
1. Add the gem to your Gemfile
|
21
21
|
2. `bundle install`
|
22
|
-
3. Add
|
23
|
-
4.
|
22
|
+
3. Add `Spree::Gateway::PxPay` to the spree.payment_methods Array in your Spree initializer (`config/initializers/spree.rb`)
|
23
|
+
4. Add a new Payment Method in the admin section using the `Spree::Gateway::PxPay`
|
24
|
+
5. Set the relevant configuration details
|
24
25
|
|
25
26
|
## TODO
|
26
27
|
|
27
|
-
The DPS documentation talks of being able to embed as an iframe. I'd like to
|
28
|
-
see if it is possible within Spree's checkout process somewhere. Have to look
|
29
|
-
into the states within the state machine, I imagine.
|
30
|
-
|
31
28
|
Specs, obviously ;)
|
32
29
|
|
33
30
|
## THANKS
|
34
31
|
|
35
32
|
Inspired by the [spree-hosted-gateway gem](https://github.com/joshmcarthur/spree-hosted-gateway) and the work done by
|
36
33
|
@bradleypriest who wrote the [PXPay gem](https://github.com/bradleypriest/pxpay).
|
34
|
+
|
35
|
+
## CONTRIBUTORS
|
36
|
+
|
37
|
+
@jstirk
|
38
|
+
@Michael1969
|
39
|
+
@lukes
|
@@ -1,45 +1,55 @@
|
|
1
1
|
Spree::CheckoutController.class_eval do
|
2
|
+
|
2
3
|
skip_before_filter :verify_authenticity_token, :only => [:dps_callback]
|
3
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
|
4
14
|
|
5
15
|
# Handles the response from PxPay (success or failure) and updates the
|
6
|
-
# relevant Payment record.
|
16
|
+
# relevant Payment record. works with spree 2.1.7
|
7
17
|
def px_pay_callback
|
8
18
|
response = Pxpay::Response.new(params).response.to_hash
|
9
19
|
|
10
20
|
payment = Spree::Payment.find(response[:merchant_reference])
|
21
|
+
if payment
|
11
22
|
|
12
|
-
if payment then
|
13
23
|
if response[:success] == '1'
|
14
|
-
payment.
|
24
|
+
payment.process!
|
15
25
|
payment.response_code = response[:auth_code]
|
16
26
|
payment.save
|
17
27
|
payment.complete
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
respond_with(@order, :location => checkout_state_path(@order.state))
|
29
|
-
end
|
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)
|
30
38
|
else
|
31
39
|
payment.void
|
32
40
|
redirect_to cart_path, :notice => 'Your credit card details were declined. Please check your details and try again.'
|
33
41
|
end
|
42
|
+
|
34
43
|
else
|
35
|
-
# Bad Payment!
|
36
44
|
raise Spree::Core::GatewayError, "Unknown merchant_reference: #{response[:merchant_reference]}"
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
40
|
-
|
48
|
+
|
49
|
+
private
|
41
50
|
|
42
51
|
alias :before_payment_without_px_pay_redirection :before_payment
|
52
|
+
|
43
53
|
def before_payment
|
44
54
|
before_payment_without_px_pay_redirection
|
45
55
|
redirect_to px_pay_gateway.url(@order, request)
|
@@ -48,4 +58,5 @@ private
|
|
48
58
|
def px_pay_gateway
|
49
59
|
@order.available_payment_methods.find { |x| x.is_a?(Spree::Gateway::PxPay) }
|
50
60
|
end
|
61
|
+
|
51
62
|
end
|
@@ -15,8 +15,6 @@ module Spree
|
|
15
15
|
preference :key, :string
|
16
16
|
preference :currency_input, :string, :default => 'AUD', :description => "3 digit currency code from #{Pxpay::Base.currency_types.join(' ')}"
|
17
17
|
|
18
|
-
attr_accessible :preferred_user_id, :preferred_key, :preferred_currency_input
|
19
|
-
|
20
18
|
def source_required?
|
21
19
|
false
|
22
20
|
end
|
@@ -31,14 +29,15 @@ module Spree
|
|
31
29
|
end
|
32
30
|
|
33
31
|
def url(order, request)
|
34
|
-
callback = callback_url(request.host, request.protocol)
|
32
|
+
callback = callback_url(request.host, request.protocol, request.port)
|
35
33
|
px_pay_request(payment(order), callback).url
|
36
34
|
end
|
37
35
|
|
38
36
|
private
|
39
37
|
|
40
|
-
|
38
|
+
# Finds the pending payment or creates a new one.
|
41
39
|
def payment(order)
|
40
|
+
|
42
41
|
payment = order.payments.pending.first
|
43
42
|
return payment if payment.present?
|
44
43
|
|
@@ -57,8 +56,8 @@ private
|
|
57
56
|
end
|
58
57
|
|
59
58
|
# Calculates the url to return to after the PxPay process completes
|
60
|
-
def callback_url(host, protocol)
|
61
|
-
url_for(:controller => 'spree/checkout', :action => 'px_pay_callback', :only_path => false, :host => host, :protocol => protocol)
|
59
|
+
def callback_url(host, protocol, port)
|
60
|
+
url_for(:controller => 'spree/checkout', :action => 'px_pay_callback', :only_path => false, :host => host, :protocol => protocol, :port => port)
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
data/config/routes.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'spree_pxpay_paymentmethod/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'spree_pxpay_paymentmethod'
|
7
7
|
s.version = SpreePxpayPaymentmethod::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
11
|
-
s.summary =
|
12
|
-
s.description =
|
8
|
+
s.authors = ['tuttinator']
|
9
|
+
s.email = ['gems@foundryhq.com']
|
10
|
+
s.homepage = 'https://github.com/localist/spree_pxpay_paymentmethod'
|
11
|
+
s.summary = 'Spree PXPay payment method'
|
12
|
+
s.description = 'Gem for Spree 2.1.7 which adds PXPay (paymentexpress.com - a NZ and Australian Payment Processor) as a Payment Method.'
|
13
13
|
|
14
|
-
s.rubyforge_project =
|
14
|
+
s.rubyforge_project = 'spree_pxpay_paymentmethod'
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
-
s.require_paths = [
|
19
|
+
s.require_paths = ['lib']
|
20
20
|
|
21
|
-
s.add_dependency('spree_core', '~>
|
21
|
+
s.add_dependency('spree_core', '~> 2.1.7')
|
22
22
|
s.add_dependency('pxpay', '~> 0.2.6')
|
23
23
|
end
|
metadata
CHANGED
@@ -1,50 +1,52 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_pxpay_paymentmethod
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 1.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- tuttinator
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: spree_core
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.1
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.7
|
24
20
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: pxpay
|
28
21
|
prerelease: false
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pxpay
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
34
33
|
version: 0.2.6
|
35
34
|
type: :runtime
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.2.6
|
41
|
+
description: Gem for Spree 2.1.7 which adds PXPay (paymentexpress.com - a NZ and Australian
|
42
|
+
Payment Processor) as a Payment Method.
|
43
|
+
email:
|
44
|
+
- gems@foundryhq.com
|
40
45
|
executables: []
|
41
|
-
|
42
46
|
extensions: []
|
43
|
-
|
44
47
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
|
47
|
-
- .gitignore
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
48
50
|
- Gemfile
|
49
51
|
- README.md
|
50
52
|
- Rakefile
|
@@ -55,32 +57,27 @@ files:
|
|
55
57
|
- lib/spree_pxpay_paymentmethod.rb
|
56
58
|
- lib/spree_pxpay_paymentmethod/version.rb
|
57
59
|
- spree_pxpay_paymentmethod.gemspec
|
58
|
-
homepage:
|
60
|
+
homepage: https://github.com/localist/spree_pxpay_paymentmethod
|
59
61
|
licenses: []
|
60
|
-
|
62
|
+
metadata: {}
|
61
63
|
post_install_message:
|
62
64
|
rdoc_options: []
|
63
|
-
|
64
|
-
require_paths:
|
65
|
+
require_paths:
|
65
66
|
- lib
|
66
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
-
|
68
|
-
requirements:
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
69
|
- - ">="
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version:
|
72
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
-
|
74
|
-
requirements:
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
75
74
|
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
78
77
|
requirements: []
|
79
|
-
|
80
78
|
rubyforge_project: spree_pxpay_paymentmethod
|
81
|
-
rubygems_version:
|
79
|
+
rubygems_version: 2.2.2
|
82
80
|
signing_key:
|
83
|
-
specification_version:
|
84
|
-
summary:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Spree PXPay payment method
|
85
83
|
test_files: []
|
86
|
-
|