Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The Library supports all APIs under the following services:
* payouts
* recurring
* marketpay
* postfmapi

## Requirements

Expand Down Expand Up @@ -137,6 +138,14 @@ adyen.checkout.version = 50
- update_notification_configuration
- delete_notification_configurations

**marketpay.hop:**
- get_onboarding_url

**postfmapi:**
- assign_terminals
- find_terminal
- get_terminals_under_account

## Support

If you have any problems, questions or suggestions, create an issue here or send your inquiry to support@adyen.com.
Expand Down
1 change: 1 addition & 0 deletions lib/adyen-ruby-api-library.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
require_relative "adyen/services/payouts"
require_relative "adyen/services/recurring"
require_relative "adyen/services/marketpay"
require_relative "adyen/services/postfmapi"
require_relative "adyen/services/service"
require_relative "adyen/hash_with_accessors"
require_relative "adyen/utils/hmac_validator"
Expand Down
11 changes: 9 additions & 2 deletions lib/adyen/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ def service_url_base(service)
when "CheckoutUtility"
url = "https://checkout-#{@env}.adyen.com/checkout"
supports_live_url_prefix = true
when "Account", "Fund", "Notification"
when "Account", "Fund", "Notification", "Hop"
url = "https://cal-#{@env}.adyen.com/cal/services"
supports_live_url_prefix = false
when "Recurring", "Payment", "Payout"
url = "https://pal-#{@env}.adyen.com/pal/servlet"
supports_live_url_prefix = true
when "Terminal"
url = "https://postfmapi-#{@env}.adyen.com/postfmapi/terminal"
supports_live_url_prefix = false
else
raise ArgumentError, "Invalid service specified"
end
Expand All @@ -66,7 +69,7 @@ def service_url_base(service)

# construct full URL from service and endpoint
def service_url(service, action, version)
if service == "Checkout" || service == "CheckoutUtility"
if service == "Checkout" || service == "CheckoutUtility" || service == "Terminal"
"#{service_url_base(service)}/v#{version}/#{action}"
else
"#{service_url_base(service)}/#{service}/v#{version}/#{action}"
Expand Down Expand Up @@ -187,5 +190,9 @@ def recurring
def marketpay
@marketpay ||= Adyen::Marketpay::Marketpay.new(self)
end

def postfmapi
@postfmapi ||= Adyen::PosTerminalManagement.new(self)
end
end
end
18 changes: 18 additions & 0 deletions lib/adyen/services/marketpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ def fund
def notification
@notification ||= Adyen::Marketpay::Notification.new(@client)
end

def hop
@hop ||= Adyen::Marketpay::Hop.new(@client)
end
end

class Account < Service
Expand Down Expand Up @@ -88,5 +92,19 @@ def initialize(client, version = DEFAULT_VERSION)
super(client, version, service, method_names)
end
end

class Hop < Service
attr_accessor :version
DEFAULT_VERSION = 1

def initialize(client, version = DEFAULT_VERSION)
service = 'Hop'
method_names = [
:get_onboarding_url
]

super(client, version, service, method_names)
end
end
end
end
19 changes: 19 additions & 0 deletions lib/adyen/services/postfmapi.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative 'service'

module Adyen
class PosTerminalManagement < Service
attr_accessor :version
DEFAULT_VERSION = 1

def initialize(client, version = DEFAULT_VERSION)
service = 'Terminal'
method_names = [
:assign_terminals,
:find_terminal,
:get_terminals_under_account
]

super(client, version, service, method_names)
end
end
end
2 changes: 1 addition & 1 deletion lib/adyen/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Adyen
NAME = "adyen-ruby-api-library"
VERSION = "4.0.2".freeze
VERSION = "4.1.0".freeze
end
14 changes: 14 additions & 0 deletions spec/hop_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require "spec_helper"

RSpec.describe Adyen::Payments, service: "marketpay hop service" do
# client instance to be used in dynamically generated tests
client = create_client(:basic)

# methods / values to test for
# format is defined in spec_helper
test_sets = [
["get_onboarding_url", "pspReference", "8815850625171183"]
]

generate_tests(client, "Hop", test_sets, client.marketpay.hop)
end
4 changes: 4 additions & 0 deletions spec/mocks/requests/Hop/get_onboarding_url.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"accountHolderCode": "YourUniqueAccountHolderCode",
"returnUrl": "https://your.return-url.com/?submerchant=123"
}
6 changes: 6 additions & 0 deletions spec/mocks/requests/Terminal/assign_terminals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"companyAccount": "TestCompany",
"merchantAccount": "TestMerchant",
"merchantInventory": false,
"terminals": ["e285-123456789"]
}
3 changes: 3 additions & 0 deletions spec/mocks/requests/Terminal/find_terminal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"terminal": "e285-123456789"
}
4 changes: 4 additions & 0 deletions spec/mocks/requests/Terminal/get_terminals_under_account.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"companyAccount" : "TestCompany",
"merchantAccount" : "TestMerchant"
}
7 changes: 7 additions & 0 deletions spec/mocks/responses/Hop/get_onboarding_url.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"pspReference": "8815850625171183",
"resultCode": "Success",
"submittedAsync": "false",
"invalidFields": [],
"redirectUrl": "https://hop-test.adyen.com/hop/view/?token=BQABAQANDBQftSiV8pqlYYFRjIZmBIhE3Ls%2FgdLQ3kcTbflt4FDPves0B9kq7aSZUqKwRciwBEN3PX23ZPqGmYXTb7QklLY5YdEXvUdEgtFnJl9uDWK09texQ3djnTPW6JKrok5svw%2FGZyGHqF1NAbuqPPPLF8o5Jzzri8AqyQKig%2BtMmEibuCuZrIvMbJjcINfDk0OBHir8bNjHgMGFiDBOXdkiww%2FB1VXP2MMqSB1yqcXiKL1o%2B12czdB9wJ5wwsQLGlcuE2Z0%2BZNIQL3MdRomkphpkIWBPFN9YmyGS0Wel6trve6ghBl4q4e1C%2B9BMQKc4P0jrC9FrkBZvhtBYoN%2BfUfrEDbgXpXjXYa1tlfU53XoD%2FsAAA1n2PuQSyfTxEf8qpwAcB9oDN%2BrbpwxYwIk42kCGztAQShTwZzx%2B4VifKpjBdtHA4bSHEqOzGPvpQ6bk4viluLn9Ealv0ylf%2FC3w%2BZCmThg8%2B2EIiABmMK8Jbfijl%2FM%2FqE43F0QN9SveJjwkN5IYGra5QbErUdAPDMfDksPjy%2FY8j%2B2XT1kMwSOLbWTCfhP%2FM%2F68Ll50RuhfJOkgfdP%2BfSxbK9i9uAmEsJ980cABWPpB4MH27asGfZ17mCM3TavaiI9d9Gs3X1HIoEZehFKWEhoaGsEaoSBQ6ut6VnZoOCCBsvssg9aqi1LJKpwwWg4CjS9Ygrw1dnSYjyFO2HeKGXf4TUS7DSCF7tpUJlBen69Xaqbwg%2BHfNfmgcCoZwSgvg%3D%3D"
}
5 changes: 5 additions & 0 deletions spec/mocks/responses/Terminal/assign_terminals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"results": {
"e285-123456789": "Done"
}
}
6 changes: 6 additions & 0 deletions spec/mocks/responses/Terminal/find_terminal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"companyAccount": "TestCompany",
"merchantAccount": "TestMerchant",
"merchantInventory": false,
"terminal": "e285-123456789"
}
11 changes: 11 additions & 0 deletions spec/mocks/responses/Terminal/get_terminals_under_account.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"companyAccount": "TestCompany",
"merchantAccounts": [
{
"merchantAccount": "TestMerchant",
"inStoreTerminals": [
"P400Plus-123456789"
]
}
]
}
16 changes: 16 additions & 0 deletions spec/postfmapi_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "spec_helper"

RSpec.describe Adyen::PosTerminalManagement, service: "POS Terminal Management service" do
# client instance to be used in dynamically generated tests
client = create_client(:basic)

# methods / values to test for
# format is defined in spec_helper
test_sets = [
["find_terminal", "merchantAccount", "TestMerchant"],
["get_terminals_under_account", "merchantAccounts", [{ "merchantAccount" => "TestMerchant", "inStoreTerminals" => ["P400Plus-123456789"] }]],
["assign_terminals", "results", { "e285-123456789" => "Done" }]
]

generate_tests(client, "Terminal", test_sets, client.postfmapi)
end
1 change: 1 addition & 0 deletions spec/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
expect(described_class.action_for_method_name(:update_account_holder)).to eq 'updateAccountHolder'
expect(described_class.action_for_method_name(:update_account_holder_state)).to eq 'updateAccountHolderState'
expect(described_class.action_for_method_name(:upload_document)).to eq 'uploadDocument'
expect(described_class.action_for_method_name(:get_onboarding_url)).to eq 'getOnboardingUrl'
end
end
end