Skip to content

Commit 86b9c48

Browse files
author
Colin Rood
authored
Merge pull request #5 from Adyen/develop
Fixes for checkout url generation, update rubygems name #5
2 parents b110b7e + 1fa3d97 commit 86b9c48

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
design.txt
22
/Gemfile.lock
3+
*.gem
34

45
# VSCode
56
.vs

adyen.gemspec renamed to adyen-ruby-api-client.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
require_relative "lib/adyen/version"
22

33
Gem::Specification.new do |spec|
4-
spec.name = "adyen"
4+
spec.name = "adyen-ruby-api-client"
55
spec.version = Adyen::VERSION
66
spec.authors = ["Adyen"]
77
spec.email = [""]
88

99
spec.summary = "API Library for Adyen APIs"
10-
spec.description = "Simplify Adyen API Integration"
10+
spec.description = "A ruby library from Adyen that simplifies integrating with the API, including Checkout, Marketpay, payments, recurring, and payouts. For support please reach out to [email protected]. If you'd like to contribute please submit a comment or pull request at https://github.com/Adyen/adyen-ruby-api-library."
1111
spec.homepage = "https://www.adyen.com"
1212
spec.license = "MIT"
1313

lib/adyen/client.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
module Adyen
1010
class Client
11-
attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter
11+
attr_accessor :ws_user, :ws_password, :api_key, :client, :adapter, :checkout_url_prefix
1212
attr_reader :env
1313

14-
def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001)
14+
def initialize(ws_user: nil, ws_password: nil, api_key: nil, env: :live, adapter: nil, mock_port: 3001, checkout_url_prefix: nil)
1515
@ws_user = ws_user
1616
@ws_password = ws_password
1717
@api_key = api_key
1818
@env = env
1919
@adapter = adapter || Faraday.default_adapter
2020
@mock_port = mock_port
21+
@checkout_url_prefix = checkout_url_prefix
2122
end
2223

23-
# make sure that env can only be live or test
24+
# make sure that env can only be :live, :test, or :mock
2425
def env=(value)
2526
raise ArgumentError, "Invalid value for Client.env: '#{value}'' - must be one of [:live, :test, :mock]" unless [:live, :test, :mock].include? value
2627
@env = value
@@ -33,10 +34,15 @@ def service_url_base(service)
3334
else
3435
case service
3536
when "Checkout"
36-
"https://checkout-#{@env}.adyen.com"
37+
if @env == :test
38+
"https://checkout-test.adyen.com"
39+
else
40+
raise ArgumentError, "Please set Client.checkout_url_prefix to the portion of your merchant-specific URL prior to '-checkout-live'" if @checkout_url_prefix.nil?
41+
"https://#{@checkout_url_prefix}-checkout-live.adyenpayments.com/checkout/services/PaymentSetupAndVerification"
42+
end
3743
when "Account", "Fund", "Notification"
3844
"https://cal-#{@env}.adyen.com/cal/services"
39-
when "Recurring", "Payment"
45+
when "Recurring", "Payment", "Payout"
4046
"https://pal-#{@env}.adyen.com/pal/servlet"
4147
else
4248
raise ArgumentError, "Invalid service specified"
@@ -100,7 +106,7 @@ def call_adyen_api(service, action, request_data, version)
100106

101107
# handle client errors
102108
rescue Faraday::ConnectionFailed => connection_error
103-
raise connection_error, "Please confirm that Client.env is set to the right value (:live or :test)"
109+
raise connection_error, "Connection to #{url} failed"
104110
end
105111

106112
# check for API errors

lib/adyen/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Adyen
2-
VERSION = "1.0.1".freeze
2+
VERSION = "1.0.2".freeze
33
end

0 commit comments

Comments
 (0)