Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #14 from verlinden/adyen

---

Hi,

This change makes possible to configure the payment flow selection (select.shmtl, pay.shtml, details.shtml). See Adyen Merchant Integration Manual, section "Payment Flow Selection"

Usage:

Adyen.configuration.payment_flow = pay.shtml

Thanks,
Steve
  • Loading branch information...
commit 4366f0c043b68874c7edaa18d68a921076b18006 2 parents 462d89c + 13b32f2
@wvanbergen wvanbergen authored
View
13 lib/adyen/configuration.rb
@@ -4,6 +4,7 @@ def initialize
@default_api_params = {}
@default_form_params = {}
@form_skins = {}
+ @payment_flow = :select
end
# The Rails environment for which to use to Adyen "live" environment.
@@ -38,7 +39,17 @@ def autodetect_environment
LIVE_RAILS_ENVIRONMENTS.include?(rails_env) ? 'live' : 'test'
end
-
+
+ # The payment flow URL that’s used to choose the payement process
+ #
+ # @example
+ # Adyen.configuration.payment_flow = :select
+ # Adyen.configuration.payment_flow = :pay
+ # Adyen.configuration.payment_flow = :details
+ #
+ # @return [String]
+ attr_accessor :payment_flow
+
# The username that’s used to authenticate for the Adyen SOAP services. It should look
# something like ‘+ws@AndyInc.SuperShop+’
#
View
11 lib/adyen/form.rb
@@ -28,8 +28,8 @@ module Form
######################################################
# The URL of the Adyen payment system that still requires the current
- # Adyen enviroment to be filled in.
- ACTION_URL = "https://%s.adyen.com/hpp/select.shtml"
+ # Adyen enviroment and payment flow to be filled.
+ ACTION_URL = "https://%s.adyen.com/hpp/%s.shtml"
# Returns the URL of the Adyen payment system, adjusted for an Adyen environment.
#
@@ -39,9 +39,10 @@ module Form
# for payment forms or redirects.
# @see Adyen::Form.environment
# @see Adyen::Form.redirect_url
- def url(environment = nil)
- environment ||= Adyen.configuration.environment
- Adyen::Form::ACTION_URL % environment.to_s
+ def url(environment = nil, payment_flow = nil)
+ environment ||= Adyen.configuration.environment
+ payment_flow ||= Adyen.configuration.payment_flow
+ Adyen::Form::ACTION_URL % [environment.to_s, payment_flow.to_s]
end
######################################################
View
21 spec/form_spec.rb
@@ -17,11 +17,11 @@
Adyen.configuration.environment = nil
end
- it "should generate correct the testing url" do
+ it "should generate correct testing url" do
Adyen::Form.url.should == 'https://test.adyen.com/hpp/select.shtml'
end
- it "should generate a live url if the environemtn is set top live" do
+ it "should generate a live url if the environment is set to live" do
Adyen.configuration.environment = :live
Adyen::Form.url.should == 'https://live.adyen.com/hpp/select.shtml'
end
@@ -34,6 +34,21 @@
it "should generate correct live url if explicitely asked for" do
Adyen::Form.url(:live).should == 'https://live.adyen.com/hpp/select.shtml'
end
+
+ it "should generate correct testing url if the payment flow selection is set to select" do
+ Adyen.configuration.payment_flow = :select
+ Adyen::Form.url.should == 'https://test.adyen.com/hpp/select.shtml'
+ end
+
+ it "should generate correct testing url if the payment flow selection is set to pay" do
+ Adyen.configuration.payment_flow = :pay
+ Adyen::Form.url.should == 'https://test.adyen.com/hpp/pay.shtml'
+ end
+
+ it "should generate correct testing url if the payment flow selection is set to details" do
+ Adyen.configuration.payment_flow = :details
+ Adyen::Form.url.should == 'https://test.adyen.com/hpp/details.shtml'
+ end
end
describe 'redirect signature check' do
@@ -153,4 +168,4 @@
signature.should == 'F2BQEYbE+EUhiRGuPtcD16Gm7JY='
end
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.