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 +4 -4
- data/README.md +2 -2
- data/lib/klarna/checkout/validations/order_validations.rb +4 -4
- data/lib/klarna/checkout/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5649d67a60cbdbdbd67792a8a208dc268f7f3b347b148a6e5cb8ee2286457263
|
4
|
+
data.tar.gz: 8c188aa00537c895fc28ec62dc9faf3e2265b83f1c7611d3bfce376f297caf53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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'
|
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.
|
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-
|
12
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|