adyen-ruby-api-library 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 50ac4158ef06b200711ce1b69d7b6c12cad0df4b
4
- data.tar.gz: 338fbfd9fed83cd6a3569dd1f706fdf439e259c1
2
+ SHA256:
3
+ metadata.gz: 9e1e891caf5313d525a5cc00bfa709e032684bb84383944357c9ed709b7c517d
4
+ data.tar.gz: 6fe18663705bb0ca470d6d9ed0e506a59c5521ccbd7ec9637c653e4b39ea5223
5
5
  SHA512:
6
- metadata.gz: c71dfcff2e34dd0244abdd56da08a0ab430b608de4fc095a472711a69269c416ffcee0b6021ed0db56bff3b8a5d1fc25e1fe13bac4f0c844367a61498ad6de1b
7
- data.tar.gz: 9ea5ee2a69f6de0523ba4fff25975202583bdf3d1218a8cda8d0abe978b57e30158cccd4bb94921c928531ce40442df067089cdb74a066567a4f2cd1f526bcf5
6
+ metadata.gz: 001454cc1d12e9c6920744a9f8ae34b08f8d9dedddd99795a11372b8b2a6015047957c5f7e81eb8eed970df956fb75cdd46f3c7ca40ed26b8cb5246af0ba5ee4
7
+ data.tar.gz: 051c5988b2fd0eb10c0879465c2b67a59f1ada3b0324a02e65b91c9d56e1ff1ff28354cf748e03066a18e50bb2dbc371877c97f871f838910043792973fca3da
@@ -0,0 +1 @@
1
+ * @crrood @hbkwong @KadoBOT @Aleffio @rikterbeek
@@ -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 support@adyen.com. 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
data/Gemfile CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- ruby "> 2.1.0"
5
+ ruby ">= 2.1.0"
6
6
 
7
7
  gem "faraday"
8
8
 
9
9
  gem "bundler", :group => :development
10
10
  gem "webmock", :group => :development
11
11
  gem "rspec", :group => :development
12
- gem "activesupport", :group => :development
12
+ gem "activesupport", :group => :development
data/README.md CHANGED
@@ -77,6 +77,7 @@ adyen.checkout.version = 50
77
77
  - payment_methods
78
78
  - payments
79
79
  - payments.details
80
+ - payment_links
80
81
 
81
82
  **checkout utility:**
82
83
  - origin_keys
@@ -41,6 +41,8 @@
41
41
  <li>payments</li>
42
42
 
43
43
  <li>payments.details</li>
44
+
45
+ <li>payment_links</li>
44
46
  </ul>
45
47
 
46
48
  <h2 id="authentication">Authentication</h2>
@@ -99,7 +101,22 @@
99
101
 
100
102
  <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>
101
103
 
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>
102
117
  </section>
118
+
119
+
103
120
  <footer>
104
121
  <p>This project is maintained by <a href="https://github.com/Adyen">Adyen</a></p>
105
122
  <p><small>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
@@ -3,19 +3,61 @@ module Adyen
3
3
  attr_reader :code, :response, :request, :msg
4
4
 
5
5
  def initialize(request = nil, response = nil, msg = nil, code = nil)
6
+ mask_fields(request)
7
+
8
+ # components of formatted error message
6
9
  attributes = {
7
10
  code: code,
11
+ msg: msg,
8
12
  request: request,
9
- response: response,
10
- msg: msg
13
+ response: response
11
14
  }.select { |_k, v| v }.map { |k, v| "#{k}:#{v}" }.join(', ')
12
15
  message = "#{self.class.name} #{attributes}"
13
16
  super(message)
17
+
18
+ # internal variables
14
19
  @code = code
15
20
  @response = response
16
21
  @request = request
17
22
  @msg = msg
18
23
  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
19
61
  end
20
62
 
21
63
  class AuthenticationError < AdyenError
@@ -8,7 +8,8 @@ module Adyen
8
8
  service = 'Checkout'
9
9
  method_names = [
10
10
  :payment_methods,
11
- :payment_session
11
+ :payment_session,
12
+ :payment_links
12
13
  ]
13
14
 
14
15
  super(client, version, service, method_names)
@@ -1,4 +1,4 @@
1
1
  module Adyen
2
2
  NAME = "adyen-ruby-api-library"
3
- VERSION = "4.0.1".freeze
3
+ VERSION = "4.0.2".freeze
4
4
  end
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": [
3
+ "config:base"
4
+ ]
5
+ }
@@ -110,6 +110,7 @@ RSpec.describe Adyen::Checkout, service: "checkout" do
110
110
  # format is defined in spec_helper
111
111
  test_sets = [
112
112
  ["payment_session", "publicKeyToken", "8115054323780109"],
113
+ ["payment_links", "url", "https://checkoutshopper-test.adyen.com"],
113
114
  ["payments", "resultCode", "Authorised"]
114
115
  ]
115
116
 
@@ -3,15 +3,45 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe Adyen::AdyenError do
6
+ before(:all) do
7
+ @shared_values = {
8
+ request: {
9
+ amount: {
10
+ currency: "USD",
11
+ value: 1000
12
+ },
13
+ reference: "Your order number",
14
+ paymentMethod: {
15
+ type: "scheme",
16
+ number: "4111111111111111",
17
+ expiryMonth: "10",
18
+ expiryYear: "2020",
19
+ holderName: "John Smith",
20
+ cvc: "737"
21
+ },
22
+ returnUrl: "https://your-company.com/",
23
+ merchantAccount: "YOUR_MERCHANT_ACCOUNT"
24
+ }
25
+ }
26
+ end
27
+
6
28
  describe '#to_s' do
7
29
  it 'describes using the error properties' do
8
- expect(Adyen::AdyenError.new('request', 'response', 'message', 'code').to_s).to eq('Adyen::AdyenError code:code, request:request, response:response, msg:message')
30
+ expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').to_s).to eq("Adyen::AdyenError code:code, msg:message, request:#{@shared_values[:request]}, response:response")
9
31
  end
10
32
  it 'skips the null properties' do
11
- expect(Adyen::AdyenError.new('request', nil, nil, 'code').to_s).to eq('Adyen::AdyenError code:code, request:request')
33
+ expect(Adyen::AdyenError.new(@shared_values[:request], nil, nil, 'code').to_s).to eq("Adyen::AdyenError code:code, request:#{@shared_values[:request]}")
12
34
  end
13
35
  it 'uses the proper error class name' do
14
- expect(Adyen::PermissionError.new('a message', 'a request').to_s).to eq('Adyen::PermissionError code:403, request:a request, msg:a message')
36
+ expect(Adyen::PermissionError.new('message', @shared_values[:request]).to_s).to eq("Adyen::PermissionError code:403, msg:message, request:#{@shared_values[:request]}")
37
+ end
38
+ end
39
+ describe '#masking' do
40
+ it 'masks card number when logging request in errors' do
41
+ expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:number]).to eq('411111******1111')
42
+ end
43
+ it 'masks CVC when logging request in errors' do
44
+ expect(Adyen::AdyenError.new(@shared_values[:request], 'response', 'message', 'code').request[:paymentMethod][:cvc]).to eq('***')
15
45
  end
16
46
  end
17
47
  end
@@ -0,0 +1,9 @@
1
+ {
2
+ "amount": {
3
+ "currency": "USD",
4
+ "value": 1000
5
+ },
6
+ "countryCode": "US",
7
+ "merchantAccount": "TestMerchant",
8
+ "reference": "Merchant Reference"
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "amount": {
3
+ "currency": "USD",
4
+ "value": 1000
5
+ },
6
+ "expiresAt": "2019-12-14T10:05:29Z",
7
+ "reference": "Merchant Reference",
8
+ "url": "https://checkoutshopper-test.adyen.com"
9
+ }
@@ -26,6 +26,7 @@ RSpec.describe Adyen::Service do
26
26
  expect(described_class.action_for_method_name(:origin_keys)).to eq 'originKeys'
27
27
  expect(described_class.action_for_method_name(:payment_methods)).to eq 'paymentMethods'
28
28
  expect(described_class.action_for_method_name(:payment_session)).to eq 'paymentSession'
29
+ expect(described_class.action_for_method_name(:payment_links)).to eq 'paymentLinks'
29
30
  expect(described_class.action_for_method_name(:refund)).to eq 'refund'
30
31
  expect(described_class.action_for_method_name(:store_detail)).to eq 'storeDetail'
31
32
  expect(described_class.action_for_method_name(:store_detail_and_submit_third_party)).to eq 'storeDetailAndSubmitThirdParty'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adyen-ruby-api-library
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-09 00:00:00.000000000 Z
11
+ date: 2020-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -76,8 +76,10 @@ executables: []
76
76
  extensions: []
77
77
  extra_rdoc_files: []
78
78
  files:
79
+ - ".github/CODEOWNERS"
79
80
  - ".gitignore"
80
81
  - ".travis.yml"
82
+ - CODE_OF_CONDUCT.md
81
83
  - CONTRIBUTING.md
82
84
  - Gemfile
83
85
  - LICENSE
@@ -114,6 +116,7 @@ files:
114
116
  - lib/adyen/services/service.rb
115
117
  - lib/adyen/utils/hmac_validator.rb
116
118
  - lib/adyen/version.rb
119
+ - renovate.json
117
120
  - spec/account_spec.rb
118
121
  - spec/checkout_spec.rb
119
122
  - spec/checkout_utility_spec.rb
@@ -137,6 +140,7 @@ files:
137
140
  - spec/mocks/requests/Account/upload_document.json
138
141
  - spec/mocks/requests/Checkout/payment-details.json
139
142
  - spec/mocks/requests/Checkout/payment-result.json
143
+ - spec/mocks/requests/Checkout/payment_links.json
140
144
  - spec/mocks/requests/Checkout/payment_methods.json
141
145
  - spec/mocks/requests/Checkout/payment_session.json
142
146
  - spec/mocks/requests/Checkout/payments.json
@@ -186,6 +190,7 @@ files:
186
190
  - spec/mocks/responses/Account/upload_document.json
187
191
  - spec/mocks/responses/Checkout/payment-details.json
188
192
  - spec/mocks/responses/Checkout/payment-result.json
193
+ - spec/mocks/responses/Checkout/payment_links.json
189
194
  - spec/mocks/responses/Checkout/payment_methods.json
190
195
  - spec/mocks/responses/Checkout/payment_session.json
191
196
  - spec/mocks/responses/Checkout/payments.json
@@ -248,8 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
253
  - !ruby/object:Gem::Version
249
254
  version: '0'
250
255
  requirements: []
251
- rubyforge_project:
252
- rubygems_version: 2.2.0
256
+ rubygems_version: 3.1.2
253
257
  signing_key:
254
258
  specification_version: 4
255
259
  summary: Official Adyen Ruby API Library