klarna-checkout-v3 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5649d67a60cbdbdbd67792a8a208dc268f7f3b347b148a6e5cb8ee2286457263
4
- data.tar.gz: 8c188aa00537c895fc28ec62dc9faf3e2265b83f1c7611d3bfce376f297caf53
3
+ metadata.gz: '0183f6708023bac6ff4aeea23c736aece5975988d3b9a58f3fd93392abb9371d'
4
+ data.tar.gz: 49a037fb1cd242ba6fb6ab8bfd3d744ea63f9aec8efc3a9103b91b53dac4a9eb
5
5
  SHA512:
6
- metadata.gz: 7eeaa5a1308e6289482312b50250de698c97ffd0e13f45fd367edc51093b1f4198ab81049ec5c085bf9657e2dbcef832c427d41af327745f7604b2bdc6cc80c6
7
- data.tar.gz: a75f491c07c97d18416bc0ea86befa005f93e46dadf01ed5a56fb3a48a5698fb2b2b0e255cea57f0abc7f82695bb7e2c9ce22686a83fdca5a3d15eb95e5f7800
6
+ metadata.gz: 657c8ddaf3d94e64d1dd7676aa9e224b9dd1f85a4aaa1b1d401cc7919a5953b9edc2d0f62c2cef067cfe1e2109fe583940532006b5d2421259a3a31a3f970d56
7
+ data.tar.gz: a04dada24af5c3b889ef53886b6a92273c482ae8a50b1c1d867adff3255951e647ba84a0721945f6ca3888d8304cff5ca87c8c99340beed2e7cd65d7c3fd27c4
data/Gemfile CHANGED
@@ -5,14 +5,14 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in klarna.gemspec
6
6
  gemspec
7
7
 
8
- gem 'faraday', '< 2.0'
8
+ gem 'faraday', '< 3.0'
9
9
  gem 'rake', '< 14.0'
10
10
  gem 'rspec', '< 4.0'
11
11
  gem 'vcr', '< 7.0'
12
12
  gem 'webmock', '< 4.0'
13
13
 
14
14
  group :development, :test do
15
- gem 'pry', '< 1.0'
15
+ gem 'pry'
16
16
  gem 'pry-byebug'
17
17
  gem 'rubocop', require: false
18
18
  end
data/Gemfile.lock CHANGED
@@ -1,67 +1,72 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- klarna-checkout (0.1.1)
4
+ klarna-checkout-v3 (0.1.4)
5
5
  faraday
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- addressable (2.7.0)
11
- public_suffix (>= 2.0.2, < 5.0)
12
- ast (2.4.1)
10
+ addressable (2.8.4)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ ast (2.4.2)
13
13
  byebug (11.1.3)
14
14
  coderay (1.1.3)
15
- crack (0.4.4)
16
- diff-lcs (1.4.4)
17
- faraday (1.0.1)
18
- multipart-post (>= 1.2, < 3)
15
+ crack (0.4.5)
16
+ rexml
17
+ diff-lcs (1.5.0)
18
+ faraday (2.7.5)
19
+ faraday-net_http (>= 2.0, < 3.1)
20
+ ruby2_keywords (>= 0.0.4)
21
+ faraday-net_http (3.0.2)
19
22
  hashdiff (1.0.1)
23
+ json (2.6.3)
20
24
  method_source (1.0.0)
21
- multipart-post (2.1.1)
22
- parallel (1.19.2)
23
- parser (2.7.1.5)
25
+ parallel (1.23.0)
26
+ parser (3.2.2.1)
24
27
  ast (~> 2.4.1)
25
- pry (0.13.1)
28
+ pry (0.14.2)
26
29
  coderay (~> 1.1)
27
30
  method_source (~> 1.0)
28
- pry-byebug (3.9.0)
31
+ pry-byebug (3.10.1)
29
32
  byebug (~> 11.0)
30
- pry (~> 0.13.0)
31
- public_suffix (4.0.6)
32
- rainbow (3.0.0)
33
- rake (13.0.1)
34
- regexp_parser (1.8.1)
35
- rexml (3.2.4)
36
- rspec (3.9.0)
37
- rspec-core (~> 3.9.0)
38
- rspec-expectations (~> 3.9.0)
39
- rspec-mocks (~> 3.9.0)
40
- rspec-core (3.9.3)
41
- rspec-support (~> 3.9.3)
42
- rspec-expectations (3.9.2)
33
+ pry (>= 0.13, < 0.15)
34
+ public_suffix (5.0.1)
35
+ rainbow (3.1.1)
36
+ rake (13.0.6)
37
+ regexp_parser (2.8.0)
38
+ rexml (3.2.5)
39
+ rspec (3.12.0)
40
+ rspec-core (~> 3.12.0)
41
+ rspec-expectations (~> 3.12.0)
42
+ rspec-mocks (~> 3.12.0)
43
+ rspec-core (3.12.2)
44
+ rspec-support (~> 3.12.0)
45
+ rspec-expectations (3.12.3)
43
46
  diff-lcs (>= 1.2.0, < 2.0)
44
- rspec-support (~> 3.9.0)
45
- rspec-mocks (3.9.1)
47
+ rspec-support (~> 3.12.0)
48
+ rspec-mocks (3.12.5)
46
49
  diff-lcs (>= 1.2.0, < 2.0)
47
- rspec-support (~> 3.9.0)
48
- rspec-support (3.9.3)
49
- rubocop (0.92.0)
50
+ rspec-support (~> 3.12.0)
51
+ rspec-support (3.12.0)
52
+ rubocop (1.52.0)
53
+ json (~> 2.3)
50
54
  parallel (~> 1.10)
51
- parser (>= 2.7.1.5)
55
+ parser (>= 3.2.0.0)
52
56
  rainbow (>= 2.2.2, < 4.0)
53
- regexp_parser (>= 1.7)
54
- rexml
55
- rubocop-ast (>= 0.5.0)
57
+ regexp_parser (>= 1.8, < 3.0)
58
+ rexml (>= 3.2.5, < 4.0)
59
+ rubocop-ast (>= 1.28.0, < 2.0)
56
60
  ruby-progressbar (~> 1.7)
57
- unicode-display_width (>= 1.4.0, < 2.0)
58
- rubocop-ast (0.7.1)
59
- parser (>= 2.7.1.5)
60
- ruby-progressbar (1.10.1)
61
- unicode-display_width (1.7.0)
62
- vcr (6.0.0)
63
- webmock (3.9.1)
64
- addressable (>= 2.3.6)
61
+ unicode-display_width (>= 2.4.0, < 3.0)
62
+ rubocop-ast (1.29.0)
63
+ parser (>= 3.2.1.0)
64
+ ruby-progressbar (1.13.0)
65
+ ruby2_keywords (0.0.5)
66
+ unicode-display_width (2.4.2)
67
+ vcr (6.1.0)
68
+ webmock (3.18.1)
69
+ addressable (>= 2.8.0)
65
70
  crack (>= 0.3.2)
66
71
  hashdiff (>= 0.4.0, < 2.0.0)
67
72
 
@@ -69,9 +74,9 @@ PLATFORMS
69
74
  ruby
70
75
 
71
76
  DEPENDENCIES
72
- faraday (< 2.0)
73
- klarna-checkout!
74
- pry (< 1.0)
77
+ faraday (< 3.0)
78
+ klarna-checkout-v3!
79
+ pry
75
80
  pry-byebug
76
81
  rake (< 14.0)
77
82
  rspec (< 4.0)
@@ -17,8 +17,8 @@ Gem::Specification.new do |spec|
17
17
  # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
18
18
 
19
19
  spec.metadata['homepage_uri'] = spec.homepage
20
- spec.metadata['source_code_uri'] = 'https://gitlab.com/qyre-ab/klarna-checkout-v3'
21
- spec.metadata['changelog_uri'] = 'https://gitlab.com/qyre-ab/klarna-checkout-v3/CHANGELOG.md'
20
+ spec.metadata['source_code_uri'] = 'https://gitlab.com/allabrf/klarna-checkout-v3'
21
+ spec.metadata['changelog_uri'] = 'https://gitlab.com/allabrf/klarna-checkout-v3/CHANGELOG.md'
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -31,6 +31,6 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  spec.add_dependency 'faraday'
33
33
 
34
- spec.add_development_dependency 'pry', '~> 0.13.1'
35
- spec.add_development_dependency 'rspec', '~> 3.2'
34
+ spec.add_development_dependency 'pry'
35
+ spec.add_development_dependency 'rspec', '< 4'
36
36
  end
@@ -4,19 +4,17 @@ module Klarna
4
4
  module Checkout
5
5
  module Operations
6
6
  module CreateRecurring
7
- # args contain the following:
8
- # [{order_lines}], order_amount, order_tax_amount, purchase_currency, locale, recurring_token
9
- def create_recurring_order(**args)
7
+ def create_recurring_order(locale:, order_lines:, order_amount:, order_tax_amount:, purchase_currency:, recurring_token:)
10
8
  payload = {
11
- 'locale': args[:locale],
12
- 'order_lines': args[:order_lines],
13
- 'order_amount': args[:order_amount],
14
- 'order_tax_amount': args[:order_tax_amount],
15
- 'purchase_currency': args[:purchase_currency],
16
- 'auto_capture': true
9
+ locale: locale,
10
+ order_lines: order_lines,
11
+ order_amount: order_amount,
12
+ order_tax_amount: order_tax_amount,
13
+ purchase_currency: purchase_currency,
14
+ auto_capture: true
17
15
  }
18
16
 
19
- JSON.parse(request(payload.to_json, args[:recurring_token]))
17
+ JSON.parse(request(payload.to_json, recurring_token))
20
18
  end
21
19
 
22
20
  private
@@ -4,8 +4,8 @@ module Klarna
4
4
  module Checkout
5
5
  module Operations
6
6
  module Refund
7
- def refund_order(amount = nil)
8
- response = execute_refund_request(amount)
7
+ def refund_order(amount: nil, description: nil)
8
+ response = execute_refund_request(amount, description)
9
9
 
10
10
  unless response.status == 201
11
11
  raise Klarna::Checkout::Errors::OrderRefundError.new(@status, 'refund_not_allowed')
@@ -17,7 +17,7 @@ module Klarna
17
17
 
18
18
  private
19
19
 
20
- def execute_refund_request(amount)
20
+ def execute_refund_request(amount, description = nil)
21
21
  https_connection.post do |req|
22
22
  req.url "/ordermanagement/v1/orders/#{@reference}/refunds"
23
23
  req.options.timeout = 10
@@ -26,6 +26,7 @@ module Klarna
26
26
  req.headers['Content-Type'] = 'application/json'
27
27
  req.body = {
28
28
  'refunded_amount': amount.nil? ? @klarna_response['order_amount'] : amount,
29
+ 'description': description.nil? ? '' : description,
29
30
  'order_lines': @items
30
31
  }.to_json
31
32
  end
@@ -26,12 +26,19 @@ module Klarna
26
26
  end
27
27
 
28
28
  # For creating an order, using a recurring_token
29
- def self.create_recurring(**args)
30
- if args[:recurring_token].nil?
29
+ def self.create_recurring(locale:, order_lines:, order_amount:, order_tax_amount:, purchase_currency:, recurring_token:)
30
+ if recurring_token.nil?
31
31
  raise Klarna::Checkout::Errors::OrderValidationError.new('Argument missing', 'missing_recurring_token')
32
32
  end
33
33
 
34
- create_recurring_order(args)
34
+ create_recurring_order(
35
+ locale: locale,
36
+ order_lines: order_lines,
37
+ order_amount: order_amount,
38
+ order_tax_amount: order_tax_amount,
39
+ purchase_currency: purchase_currency,
40
+ recurring_token: recurring_token
41
+ )
35
42
  end
36
43
 
37
44
  # Returns an instance of the order
@@ -44,14 +51,14 @@ module Klarna
44
51
  fetch_checkout_order(ref)
45
52
  end
46
53
 
47
- def initialize(header:, items:, recurring: false, **args)
48
- @header = header
49
- @items = items
50
- @recurring = recurring
51
- @customer = args[:customer].nil? ? {} : args[:customer]
52
- @options = args[:options]
53
- @checkout_url = args[:checkout_url].nil? ? Klarna::Checkout.configuration.checkout_uri : args[:checkout_url]
54
- @terms_url = args[:terms_url].nil? ? Klarna::Checkout.configuration.terms_uri : args[:terms_url]
54
+ def initialize(header:, items:, options: {}, recurring: false, customer: {}, checkout_url: nil, terms_url: nil)
55
+ @header = header
56
+ @items = items
57
+ @recurring = recurring
58
+ @customer = customer
59
+ @options = options
60
+ @checkout_url = checkout_url || Klarna::Checkout.configuration.checkout_uri
61
+ @terms_url = terms_url || Klarna::Checkout.configuration.terms_uri
55
62
  end
56
63
 
57
64
  # Creates an order
@@ -86,10 +93,10 @@ module Klarna
86
93
  end
87
94
 
88
95
  # Refunds the order through Klarna API
89
- def refund
96
+ def refund(amount: nil, description: nil)
90
97
  raise Klarna::Checkout::Errors::OrderRefundError.new(@status, 'refund_not_allowed') unless @status == 'CAPTURED'
91
98
 
92
- refund_order
99
+ refund_order(amount: amount, description: description)
93
100
  end
94
101
 
95
102
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Klarna
4
4
  module Checkout
5
- VERSION = '0.1.2'
5
+ VERSION = '0.1.4'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klarna-checkout-v3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sverrir Steindorsson
8
8
  - Mike Eyrikh
9
- autorequire:
9
+ autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-05-05 00:00:00.000000000 Z
12
+ date: 2023-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -29,30 +29,30 @@ dependencies:
29
29
  name: pry
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: 0.13.1
34
+ version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: 0.13.1
41
+ version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - "<"
47
47
  - !ruby/object:Gem::Version
48
- version: '3.2'
48
+ version: '4'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - "<"
54
54
  - !ruby/object:Gem::Version
55
- version: '3.2'
55
+ version: '4'
56
56
  description: The gem provides methods to fetch, create, capture, cancel and refund
57
57
  Klarna orders.
58
58
  email:
@@ -102,9 +102,9 @@ licenses:
102
102
  - MIT
103
103
  metadata:
104
104
  homepage_uri: https://www.rubygems.org/gems/klarna-checkout-v3
105
- source_code_uri: https://gitlab.com/qyre-ab/klarna-checkout-v3
106
- changelog_uri: https://gitlab.com/qyre-ab/klarna-checkout-v3/CHANGELOG.md
107
- post_install_message:
105
+ source_code_uri: https://gitlab.com/allabrf/klarna-checkout-v3
106
+ changelog_uri: https://gitlab.com/allabrf/klarna-checkout-v3/CHANGELOG.md
107
+ post_install_message:
108
108
  rdoc_options: []
109
109
  require_paths:
110
110
  - lib
@@ -119,8 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubygems_version: 3.0.3
123
- signing_key:
122
+ rubygems_version: 3.4.13
123
+ signing_key:
124
124
  specification_version: 4
125
125
  summary: A Ruby wrapper for the Klarna Checkout API.
126
126
  test_files: []