klarna-checkout-v3 0.1.1 → 0.1.2

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: 728f409f890b15aabe717fca71ea5f0e41d0a4213a17b5403ca1d9b2f1c66463
4
- data.tar.gz: 07dbdbfbe243316383e61588a7028fbcdb3706349746268b9e662a156e24c6ac
3
+ metadata.gz: 5649d67a60cbdbdbd67792a8a208dc268f7f3b347b148a6e5cb8ee2286457263
4
+ data.tar.gz: 8c188aa00537c895fc28ec62dc9faf3e2265b83f1c7611d3bfce376f297caf53
5
5
  SHA512:
6
- metadata.gz: adf673682ed31c4c4cb74b5b92d992ad91d103fcb7cf7b19a464cf71930fb8b433bf36723d4835da63e2f747ef743c49b7544a20088a1ca78b56895b8ab2b84a
7
- data.tar.gz: 6bd5d8d3aa38f059ab92566008e434a4d204f910f5bf9452b072f42e976b98c832af2b458284fd82194c8f6473d767effe586df3bd2ad6eace1a4e1428bcb406
6
+ metadata.gz: 7eeaa5a1308e6289482312b50250de698c97ffd0e13f45fd367edc51093b1f4198ab81049ec5c085bf9657e2dbcef832c427d41af327745f7604b2bdc6cc80c6
7
+ data.tar.gz: a75f491c07c97d18416bc0ea86befa005f93e46dadf01ed5a56fb3a48a5698fb2b2b0e255cea57f0abc7f82695bb7e2c9ce22686a83fdca5a3d15eb95e5f7800
data/README.md CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
9
9
  Add this line to your application's Gemfile:
10
10
 
11
11
  ```ruby
12
- gem 'klarna-checkout'
12
+ gem 'klarna-checkout-v3'
13
13
  ```
14
14
 
15
15
  And then execute:
@@ -18,7 +18,7 @@ And then execute:
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install klarna-checkout
21
+ $ gem install klarna-checkout-v3
22
22
 
23
23
  ## Usage
24
24
 
@@ -28,7 +28,7 @@ module Klarna
28
28
 
29
29
  # 1. order_amount == sum of all items total_amounts
30
30
  def amount_validation
31
- return if @items.map { |i| i[:total_amount] }.sum == @header[:order_amount]
31
+ return if @items.map { |i| i[:total_amount].to_i }.sum == @header[:order_amount].to_i
32
32
 
33
33
  raise Klarna::Checkout::Errors::OrderValidationError.new(
34
34
  'inconsistent_values', 'order_amount_not_matching_total_amounts'
@@ -37,7 +37,7 @@ module Klarna
37
37
 
38
38
  # 2. order_tax_amount == sum of all items total_tax_amounts
39
39
  def tax_amount_validation
40
- return if @items.map { |i| i[:total_tax_amount] }.sum == @header[:order_tax_amount]
40
+ return if @items.map { |i| i[:total_tax_amount].to_i }.sum == @header[:order_tax_amount].to_i
41
41
 
42
42
  raise Klarna::Checkout::Errors::OrderValidationError.new(
43
43
  'inconsistent_values', 'total_tax_amount_not_matching_total_tax_amounts'
@@ -47,7 +47,7 @@ module Klarna
47
47
  # 3. [loop through all items] -> unit_price * quantity == total_amount
48
48
  def total_amount_validation
49
49
  @items.each do |i|
50
- next if i[:quantity] * (i[:unit_price] - i[:total_discount_amount].to_i) == i[:total_amount]
50
+ next if i[:quantity].to_i * (i[:unit_price].to_i - i[:total_discount_amount].to_i) == i[:total_amount].to_i
51
51
 
52
52
  raise Klarna::Checkout::Errors::OrderValidationError.new(
53
53
  'inconsistent_order_line_totals', 'total_line_amount_not_matching_qty_times_unit_price'
@@ -58,7 +58,7 @@ module Klarna
58
58
  # 4. [loop through all items] -> total_tax_amount / (total_amount - total_tax_amount) == tax_rate * 10_000
59
59
  def total_tax_amount_validation
60
60
  @items.each do |i|
61
- next if i[:total_tax_amount] * 100 / (i[:total_amount] - i[:total_tax_amount]) == i[:tax_rate] / 100
61
+ next if i[:total_tax_amount].to_i * 100 / (i[:total_amount].to_i - i[:total_tax_amount].to_i) == i[:tax_rate].to_i / 100
62
62
 
63
63
  raise Klarna::Checkout::Errors::OrderValidationError.new(
64
64
  'inconsistent_order_line_total_tax', 'line_total_tax_amount_not_matching_tax_rate'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Klarna
4
4
  module Checkout
5
- VERSION = '0.1.1'
5
+ VERSION = '0.1.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klarna-checkout-v3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sverrir Steindorsson
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-05-03 00:00:00.000000000 Z
12
+ date: 2021-05-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday