Skip to content

Commit

Permalink
Merge pull request #103 from Adyen/develop
Browse files Browse the repository at this point in the history
Release 6.1.0
  • Loading branch information
acampos1916 authored Aug 2, 2022
2 parents f05a289 + 3e46d63 commit 1ae41e4
Show file tree
Hide file tree
Showing 18 changed files with 98 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @crrood @Aleffio @wboereboom @cyattilakiss
* @crrood @wboereboom @AlexandrosMor @michaelpaul
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ If you have a feature request, or spotted a bug or a technical problem, [create
For other questions, [contact our Support Team](https://www.adyen.help/hc/en-us/requests/new?ticket_form_id=360000705420).

## Licence
This repository is available under the [MIT license](https://github.com/Adyen/adyen-ruby-api-library/blob/master/LICENSE).
This repository is available under the [MIT license](https://github.com/Adyen/adyen-ruby-api-library/blob/main/LICENSE).

## See also
* [Example integration](https://github.com/adyen-examples/adyen-rails-online-payments)
Expand Down
4 changes: 2 additions & 2 deletions docs/checkout.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h1>Adyen-ruby-api-library</h1>

<p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ <h1>Adyen-ruby-api-library</h1>
<p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>

<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/install-library.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ <h1>Adyen-ruby-api-library</h1>


<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/marketpay.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h1>Adyen-ruby-api-library</h1>

<p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/payment.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ <h1>Adyen-ruby-api-library</h1>

<p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/payout.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h1>Adyen-ruby-api-library</h1>

<p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/recurring.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h1>Adyen-ruby-api-library</h1>

<p class="view"><a href="https://github.com/Adyen/adyen-ruby-api-library">View the Project on GitHub <small>Adyen/adyen-ruby-api-library</small></a></p>
<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
4 changes: 2 additions & 2 deletions docs/using-library.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ <h1>Adyen-ruby-api-library</h1>


<ul>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/master">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/master">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/zipball/main">Download <strong>ZIP File</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library/tarball/main">Download <strong>TAR Ball</strong></a></li>
<li><a href="https://github.com/Adyen/adyen-ruby-api-library">View On <strong>GitHub</strong></a></li>
</ul>
</header>
Expand Down
10 changes: 8 additions & 2 deletions lib/adyen/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ def call_adyen_api(service, action, request_data, headers, version, with_applica
# set auth type based on service
case auth_type
when "basic"
faraday.basic_auth(@ws_user, @ws_password)
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
# for faraday 2.0 and higher
faraday.request :authorization, :basic, @ws_user, @ws_password
else
# for faraday 1.x
faraday.basic_auth(@ws_user, @ws_password)
end
when "api-key"
faraday.headers["x-api-key"] = @api_key
end
Expand Down Expand Up @@ -132,7 +138,7 @@ def call_adyen_api(service, action, request_data, headers, version, with_applica
if action.is_a?(::Hash)
if action.fetch(:method) == "get"
begin
response = conn.get
response = conn.get
rescue Faraday::ConnectionFailed => connection_error
raise connection_error, "Connection to #{url} failed"
end
Expand Down
7 changes: 5 additions & 2 deletions lib/adyen/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ class AdyenError < StandardError
attr_reader :code, :response, :request, :msg

def initialize(request = nil, response = nil, msg = nil, code = nil)
mask_fields(request)
unless request.nil?
request = request.is_a?(Hash) ? request : JSON.parse(request, symbolize_names: true)
mask_fields(request)
end

# components of formatted error message
attributes = {
Expand Down Expand Up @@ -37,7 +40,7 @@ def mask_fields(request)
]

# convert to hash if necessary
request = request.is_a?(Hash) ? request : JSON.parse(request)
request = request.is_a?(Hash) ? request : JSON.parse(request, symbolize_names: true)

# iterate through request to find fields to mask
request.each do |k, v|
Expand Down
17 changes: 17 additions & 0 deletions lib/adyen/services/checkout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def orders(*args)
@client.call_adyen_api(@service, action, args[0], args[1], @version)
end
end

def apple_pay
@apple_pay ||= Adyen::CheckoutApplePay.new(@client, @version)
end
end

class CheckoutDetail < Service
Expand Down Expand Up @@ -130,4 +134,17 @@ def cancel(request, headers = {})
@client.call_adyen_api(@service, action, request, headers, @version)
end
end

class CheckoutApplePay < Service
def initialize(client, version = DEFAULT_VERSION)
@service = "Checkout"
@client = client
@version = version
end

def sessions(request, headers = {})
action = "applePay/sessions"
@client.call_adyen_api(@service, action, request, headers, @version)
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 = "6.0.0".freeze
VERSION = "6.1.0".freeze
end
32 changes: 32 additions & 0 deletions spec/checkout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,38 @@
to eq("cancelled")
end

it "makes an applePay/sessions call" do
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/apple_pay_sessions.json"))

response_body = json_from_file("mocks/responses/Checkout/apple_pay_sessions.json")

url = @shared_values[:client].service_url(@shared_values[:service], "applePay/sessions", @shared_values[:client].checkout.version)
WebMock.stub_request(:post, url).
with(
body: request_body,
headers: {
"x-api-key" => @shared_values[:client].api_key
}
).
to_return(
body: response_body
)

result = @shared_values[:client].checkout.apple_pay.sessions(request_body)
response_hash = result.response

expect(result.status).
to eq(200)
expect(response_hash).
to eq(JSON.parse(response_body))
expect(response_hash).
to be_a Adyen::HashWithAccessors
expect(response_hash).
to be_a_kind_of Hash
expect(response_hash["data"]).
to eq("LARGE_BLOB_HERE")
end

it "makes a sessions call" do
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/sessions.json"))

Expand Down
9 changes: 9 additions & 0 deletions spec/errors_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,14 @@
it 'masks CVC when logging request in errors' do
expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
end

context 'when request is string' do
it 'masks card number when logging request in errors' do
expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message', 'code').request[:paymentMethod][:number]).to eq('411111******1111')
end
it 'masks CVC when logging request in errors' do
expect(Adyen::AdyenError.new(JSON.generate(@shared_values[:request]), 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
end
end
end
end
5 changes: 5 additions & 0 deletions spec/mocks/requests/Checkout/apple_pay_sessions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"displayName": "YOUR_MERCHANT_NAME",
"domainName": "window.location.hostname",
"merchantIdentifier": "YOUR_MERCHANT_ID"
}
3 changes: 3 additions & 0 deletions spec/mocks/responses/Checkout/apple_pay_sessions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data" : "LARGE_BLOB_HERE"
}

0 comments on commit 1ae41e4

Please sign in to comment.