Skip to content

Commit 0899324

Browse files
authored
Merge pull request #122 from Adyen/develop
Release 6.3.0
2 parents 3fac613 + b8e3a82 commit 0899324

19 files changed

+351
-33
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
* @crrood @wboereboom @AlexandrosMor @michaelpaul
1+
* @Adyen/api-libraries-reviewers

.github/workflows/codeql.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [ "develop", "main" ]
6+
pull_request:
7+
branches: [ "develop" ]
8+
schedule:
9+
- cron: "40 12 * * 0"
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
permissions:
16+
actions: read
17+
contents: read
18+
security-events: write
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
language: [ javascript ]
24+
25+
steps:
26+
- name: Checkout
27+
uses: actions/checkout@v3
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v2
31+
with:
32+
languages: ${{ matrix.language }}
33+
queries: +security-and-quality
34+
35+
- name: Autobuild
36+
uses: github/codeql-action/autobuild@v2
37+
38+
- name: Perform CodeQL Analysis
39+
uses: github/codeql-action/analyze@v2
40+
with:
41+
category: "/language:${{ matrix.language }}"

.github/workflows/ruby.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
ruby: [2.5, 2.6, 2.7, '3.0', head]
1313
runs-on: ${{ matrix.os }}
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v3
1616
- uses: ruby/setup-ruby@v1
1717
with:
1818
ruby-version: ${{ matrix.ruby }}

.github/workflows/rubygems_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010

1111
steps:
12-
- uses: actions/checkout@v1
12+
- uses: actions/checkout@v3
1313

1414
- name: Release Gem on RubyGems
1515
if: contains(github.ref, 'refs/tags/v')

lib/adyen/client.rb

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ def call_adyen_api(service, action, request_data, headers, version, with_applica
144144
raise connection_error, "Connection to #{url} failed"
145145
end
146146
end
147+
if action.fetch(:method) == "delete"
148+
begin
149+
response = conn.delete
150+
rescue Faraday::ConnectionFailed => connection_error
151+
raise connection_error, "Connection to #{url} failed"
152+
end
153+
end
147154
if action.fetch(:method) == "patch"
148155
begin
149156
response = conn.patch do |req|
@@ -169,11 +176,16 @@ def call_adyen_api(service, action, request_data, headers, version, with_applica
169176
when 401
170177
raise Adyen::AuthenticationError.new("Invalid API authentication; https://docs.adyen.com/user-management/how-to-get-the-api-key", request_data)
171178
when 403
172-
raise Adyen::PermissionError.new("Missing user permissions; https://docs.adyen.com/user-management/user-roles", request_data)
179+
raise Adyen::PermissionError.new("Missing user permissions; https://docs.adyen.com/user-management/user-roles", request_data, response.body)
173180
end
174-
175-
formatted_response = AdyenResult.new(response.body, response.headers, response.status)
176-
181+
182+
# delete has no response.body (unless it throws an error)
183+
if response.body == nil
184+
formatted_response = AdyenResult.new("{}", response.headers, response.status)
185+
else
186+
formatted_response = AdyenResult.new(response.body, response.headers, response.status)
187+
end
188+
177189
formatted_response
178190
end
179191

lib/adyen/errors.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ def initialize(msg, request)
7070
end
7171

7272
class PermissionError < AdyenError
73-
def initialize(msg, request)
74-
super(request, nil, msg, 403)
73+
def initialize(msg, request, response)
74+
super(request, response, msg, 403)
7575
end
7676
end
7777

lib/adyen/services/checkout.rb

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Adyen
44
class Checkout < Service
5-
DEFAULT_VERSION = 68
5+
DEFAULT_VERSION = 70
66

77
def initialize(client, version = DEFAULT_VERSION)
88
service = "Checkout"
@@ -13,7 +13,7 @@ def initialize(client, version = DEFAULT_VERSION)
1313
]
1414

1515
with_application_info = [
16-
:payment_session,
16+
:payment_session
1717
]
1818

1919
super(client, version, service, method_names, with_application_info)
@@ -42,7 +42,7 @@ def payment_links(*args)
4242
else
4343
action = "paymentLinks"
4444
args[1] ||= {} # optional headers arg
45-
@client.call_adyen_api(@service, action, args[0], args[1], @version, true)
45+
@client.call_adyen_api(@service, action, args[0], args[1], @version)
4646
end
4747
end
4848

@@ -75,6 +75,10 @@ def apple_pay
7575
def modifications
7676
@modifications ||= Adyen::Modifications.new(@client, @version)
7777
end
78+
79+
def stored_payment_methods
80+
@stored_payment_methods ||= Adyen::StoredPaymentMethods.new(@client, @version)
81+
end
7882
end
7983

8084
class CheckoutDetail < Service
@@ -93,6 +97,16 @@ def result(request, headers = {})
9397
action = "payments/result"
9498
@client.call_adyen_api(@service, action, request, headers, @version)
9599
end
100+
101+
def donations(request, headers = {})
102+
action = "donations"
103+
@client.call_adyen_api(@service, action, request, headers, @version)
104+
end
105+
106+
def card_details(request, headers = {})
107+
action = "cardDetails"
108+
@client.call_adyen_api(@service, action, request, headers, @version)
109+
end
96110
end
97111

98112
class CheckoutLink < Service
@@ -104,12 +118,12 @@ def initialize(client, version = DEFAULT_VERSION)
104118

105119
def get(linkId, headers = {})
106120
action = { method: 'get', url: "paymentLinks/" + linkId }
107-
@client.call_adyen_api(@service, action, {}, headers, @version, true)
121+
@client.call_adyen_api(@service, action, {}, headers, @version)
108122
end
109123

110124
def update(linkId, request, headers = {})
111125
action = { method: 'patch', url: "paymentLinks/" + linkId }
112-
@client.call_adyen_api(@service, action, request, headers, @version, false)
126+
@client.call_adyen_api(@service, action, request, headers, @version)
113127
end
114128
end
115129

@@ -161,12 +175,12 @@ def initialize(client, version = DEFAULT_VERSION)
161175

162176
def capture(linkId, request, headers = {})
163177
action = "payments/" + linkId + "/captures"
164-
@client.call_adyen_api(@service, action, request, headers, @version, false)
178+
@client.call_adyen_api(@service, action, request, headers, @version)
165179
end
166180

167181
def cancel(linkId, request, headers = {})
168182
action = "payments/" + linkId + "/cancels"
169-
@client.call_adyen_api(@service, action, request, headers, @version, false)
183+
@client.call_adyen_api(@service, action, request, headers, @version)
170184
end
171185

172186
def genericCancel(request, headers = {})
@@ -176,17 +190,35 @@ def genericCancel(request, headers = {})
176190

177191
def refund(linkId, request, headers = {})
178192
action = "payments/" + linkId + "/refunds"
179-
@client.call_adyen_api(@service, action, request, headers, @version, false)
193+
@client.call_adyen_api(@service, action, request, headers, @version)
180194
end
181195

182196
def reversal(linkId, request, headers = {})
183197
action = "payments/" + linkId + "/reversals"
184-
@client.call_adyen_api(@service, action, request, headers, @version, false)
198+
@client.call_adyen_api(@service, action, request, headers, @version)
185199
end
186200

187201
def amountUpdate(linkId, request, headers = {})
188202
action = "payments/" + linkId + "/amountUpdates"
189-
@client.call_adyen_api(@service, action, request, headers, @version, false)
203+
@client.call_adyen_api(@service, action, request, headers, @version)
204+
end
205+
end
206+
207+
class StoredPaymentMethods < Service
208+
def initialize(client, version = DEFAULT_VERSION)
209+
@service = "Checkout"
210+
@client = client
211+
@version = version
212+
end
213+
214+
def get(query_array={}, headers = {})
215+
action = { method: 'get', url: "storedPaymentMethods" + create_query_string(query_array)}
216+
@client.call_adyen_api(@service, action, {}, headers, @version)
217+
end
218+
219+
def delete(recurringId, query_array={}, headers = {})
220+
action = { method: 'delete', url: "storedPaymentMethods/%s" % recurringId + create_query_string(query_array)}
221+
@client.call_adyen_api(@service, action, {}, headers, @version)
190222
end
191223
end
192-
end
224+
end

lib/adyen/services/service.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@ def initialize(client, version, service, method_names, with_application_info = [
2424
end
2525
end
2626
end
27+
28+
# create query parameter from an array
29+
def create_query_string(arr)
30+
"?" + URI.encode_www_form(arr)
31+
end
2732
end
2833
end

lib/adyen/utils/hmac_validator.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,15 @@ def calculate_notification_hmac(notification_request_item, hmac_key)
2222
end
2323

2424
def data_to_sign(notification_request_item)
25-
NOTIFICATION_VALIDATION_KEYS.map { |key| fetch(notification_request_item, key).to_s }
26-
.map { |value| value.gsub('\\', '\\\\').gsub(':', '\\:') }
25+
data = NOTIFICATION_VALIDATION_KEYS.map { |key| fetch(notification_request_item, key).to_s }
2726
.join(DATA_SEPARATOR)
27+
return data
2828
end
2929

3030
private
3131

3232
def fetch(hash, keys)
3333
value = hash
34-
3534
keys.to_s.split('.').each do |key|
3635
value = if key.to_i.to_s == key
3736
value[key.to_i]

lib/adyen/version.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Adyen
22
NAME = "adyen-ruby-api-library"
3-
VERSION = "6.2.0".freeze
4-
end
3+
VERSION = "6.3.0".freeze
4+
end

0 commit comments

Comments
 (0)