Skip to content

Commit 3168673

Browse files
author
Colin Rood
authored
Merge pull request #56 from Adyen/develop
4.0.2 - Mask PCI data, paymentLinks endpoint
2 parents d3e8b9a + 67dcedf commit 3168673

File tree

14 files changed

+202
-9
lines changed

14 files changed

+202
-9
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @crrood @hbkwong @KadoBOT @Aleffio @rikterbeek

CODE_OF_CONDUCT.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as
6+
contributors and maintainers pledge to making participation in our project and
7+
our community a harassment-free experience for everyone, regardless of age, body
8+
size, disability, ethnicity, sex characteristics, gender identity and expression,
9+
level of experience, education, socio-economic status, nationality, personal
10+
appearance, race, religion, or sexual identity and orientation.
11+
12+
## Our Standards
13+
14+
Examples of behavior that contributes to creating a positive environment
15+
include:
16+
17+
* Using welcoming and inclusive language
18+
* Being respectful of differing viewpoints and experiences
19+
* Gracefully accepting constructive criticism
20+
* Focusing on what is best for the community
21+
* Showing empathy towards other community members
22+
23+
Examples of unacceptable behavior by participants include:
24+
25+
* The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
* Trolling, insulting/derogatory comments, and personal or political attacks
28+
* Public or private harassment
29+
* Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
* Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
33+
34+
## Our Responsibilities
35+
36+
Project maintainers are responsible for clarifying the standards of acceptable
37+
behavior and are expected to take appropriate and fair corrective action in
38+
response to any instances of unacceptable behavior.
39+
40+
Project maintainers have the right and responsibility to remove, edit, or
41+
reject comments, commits, code, wiki edits, issues, and other contributions
42+
that are not aligned to this Code of Conduct, or to ban temporarily or
43+
permanently any contributor for other behaviors that they deem inappropriate,
44+
threatening, offensive, or harmful.
45+
46+
## Scope
47+
48+
This Code of Conduct applies both within project spaces and in public spaces
49+
when an individual is representing the project or its community. Examples of
50+
representing a project or community include using an official project e-mail
51+
address, posting via an official social media account, or acting as an appointed
52+
representative at an online or offline event. Representation of a project may be
53+
further defined and clarified by project maintainers.
54+
55+
## Enforcement
56+
57+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
58+
reported by contacting the project team at [email protected]. All
59+
complaints will be reviewed and investigated and will result in a response that
60+
is deemed necessary and appropriate to the circumstances. The project team is
61+
obligated to maintain confidentiality with regard to the reporter of an incident.
62+
Further details of specific enforcement policies may be posted separately.
63+
64+
Project maintainers who do not follow or enforce the Code of Conduct in good
65+
faith may face temporary or permanent repercussions as determined by other
66+
members of the project's leadership.
67+
68+
## Attribution
69+
70+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71+
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72+
73+
[homepage]: https://www.contributor-covenant.org
74+
75+
For answers to common questions about this code of conduct, see
76+
https://www.contributor-covenant.org/faq

Gemfile

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

33
source "https://rubygems.org"
44

5-
ruby "> 2.1.0"
5+
ruby ">= 2.1.0"
66

77
gem "faraday"
88

99
gem "bundler", :group => :development
1010
gem "webmock", :group => :development
1111
gem "rspec", :group => :development
12-
gem "activesupport", :group => :development
12+
gem "activesupport", :group => :development

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ adyen.checkout.version = 50
7777
- payment_methods
7878
- payments
7979
- payments.details
80+
- payment_links
8081

8182
**checkout utility:**
8283
- origin_keys

docs/checkout.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ <h2 id="availablemethods">Available methods</h2>
4141
<li>payments</li>
4242

4343
<li>payments.details</li>
44+
45+
<li>payment_links</li>
4446
</ul>
4547

4648
<h2 id="authentication">Authentication</h2>
@@ -99,7 +101,22 @@ <h2 id="usagecheckoutapi">Usage - Checkout API</h2>
99101

100102
<p>A successful call to payment_methods will return a list of supported payment methods along with redirect URL's so that you can send your shoppers directly to the issuer's site without losing control of front-end styling / logic.</p>
101103

104+
You can also create a link to Adyen's hosted payment form:
105+
106+
<pre><code class="ruby language-ruby">response = adyen.checkout.payment_links('{
107+
"amount": {
108+
"value": 1500,
109+
"currency": "EUR"
110+
},
111+
"countryCode": "US",
112+
"merchantAccount": "YOUR_MERCHANT_ACCOUNT",
113+
"reference": "YOUR_REFERENCE"
114+
}')</code></pre>
115+
116+
<p>A successful call to payment_links will return a url, which directs a user to Adyen's hosted payment form.</p>
102117
</section>
118+
119+
103120
<footer>
104121
<p>This project is maintained by <a href="https://github.com/Adyen">Adyen</a></p>
105122
<p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>

lib/adyen/errors.rb

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,61 @@ class AdyenError < StandardError
33
attr_reader :code, :response, :request, :msg
44

55
def initialize(request = nil, response = nil, msg = nil, code = nil)
6+
mask_fields(request)
7+
8+
# components of formatted error message
69
attributes = {
710
code: code,
11+
msg: msg,
812
request: request,
9-
response: response,
10-
msg: msg
13+
response: response
1114
}.select { |_k, v| v }.map { |k, v| "#{k}:#{v}" }.join(', ')
1215
message = "#{self.class.name} #{attributes}"
1316
super(message)
17+
18+
# internal variables
1419
@code = code
1520
@response = response
1621
@request = request
1722
@msg = msg
1823
end
24+
25+
# mask PCI data in request
26+
def mask_fields(request)
27+
return if request.nil?
28+
29+
# sensitive fields
30+
fields_to_mask = [
31+
:expiryMonth,
32+
:expiryYear,
33+
:encryptedCardNumber,
34+
:encryptedExpiryMonth,
35+
:encryptedExpiryYear,
36+
:encryptedSecurityCode
37+
]
38+
39+
# convert to hash if necessary
40+
request = request.is_a?(Hash) ? request : JSON.parse(request)
41+
42+
# iterate through request to find fields to mask
43+
request.each do |k, v|
44+
if request[k].is_a?(Hash)
45+
# recursively traverse multi-level hashes
46+
mask_fields(request[k])
47+
else
48+
if k == :number
49+
# show first 6 and last 4 for cards
50+
request[k] = "#{v[0,6]}******#{v[12,16]}"
51+
elsif k == :cvc
52+
# show length of cvc for debugging
53+
request[k] = "*" * v.length
54+
elsif fields_to_mask.include? k
55+
# generic mask for other fields
56+
request[k] = "***"
57+
end
58+
end
59+
end
60+
end
1961
end
2062

2163
class AuthenticationError < AdyenError

lib/adyen/services/checkout.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ def initialize(client, version = DEFAULT_VERSION)
88
service = 'Checkout'
99
method_names = [
1010
:payment_methods,
11-
:payment_session
11+
:payment_session,
12+
:payment_links
1213
]
1314

1415
super(client, version, service, method_names)

lib/adyen/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module Adyen
22
NAME = "adyen-ruby-api-library"
3-
VERSION = "4.0.1".freeze
3+
VERSION = "4.0.2".freeze
44
end

renovate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"config:base"
4+
]
5+
}

spec/checkout_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
# format is defined in spec_helper
111111
test_sets = [
112112
["payment_session", "publicKeyToken", "8115054323780109"],
113+
["payment_links", "url", "https://checkoutshopper-test.adyen.com"],
113114
["payments", "resultCode", "Authorised"]
114115
]
115116

0 commit comments

Comments
 (0)