justifi 0.5.0 → 0.5.1

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: 3c34231d16ea73027351523d6309369021705f687926de6467fd4e81d1ff122f
4
- data.tar.gz: 8c0009bd8453cf885113b081c3527ce6f074c08b0ba7086ba82348d89f8ce09e
3
+ metadata.gz: db211cc27d14f3a8c481e942c147da0d3991d00dfdf4f0c01a2b81918a36592b
4
+ data.tar.gz: e91acbe0e30fc8ca4f8d0982c6aa15a2f332b3af836458f4074361503081b2c4
5
5
  SHA512:
6
- metadata.gz: ce6dc69cbc087eaa57536791686380791ba816ef7acebad501ad5f6133567dd37c1475ef0ada32d666282f1d556dae668950fd3806297392b95e42703d6d1c61
7
- data.tar.gz: fff1e3c1f3d49da9dd15a248f43ee1f2330860a7ab0d492bdfd223f1ce80d77c1ea4088511bc577f7ca761c99aeaafd60377ee19bdcb9e97c71716cf2ca76d4c
6
+ metadata.gz: f2f14ebba685f687c554d39ed43b9a6291ef540c4d4bca463825dd726fb7829bee152f38186c26d176082775232c42e516e3fb3cec7f6dd12e755b5c3af5382f
7
+ data.tar.gz: 3afc707b5e171126379f0b011e9cf285976212db354d00e6a8e0e376a57ff1c0fc0a055f8371abec48897329dc595b107f5a66fb581432a767b397cbce1011fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- justifi (0.5.0)
4
+ justifi (0.5.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -22,7 +22,7 @@ GEM
22
22
  public_suffix (4.0.7)
23
23
  rainbow (3.1.1)
24
24
  rake (13.0.6)
25
- regexp_parser (2.3.0)
25
+ regexp_parser (2.3.1)
26
26
  repo-small-badge (0.2.7)
27
27
  victor (~> 0.2.8)
28
28
  rexml (3.2.5)
@@ -39,13 +39,13 @@ GEM
39
39
  diff-lcs (>= 1.2.0, < 2.0)
40
40
  rspec-support (~> 3.11.0)
41
41
  rspec-support (3.11.0)
42
- rubocop (1.27.0)
42
+ rubocop (1.28.2)
43
43
  parallel (~> 1.10)
44
44
  parser (>= 3.1.0.0)
45
45
  rainbow (>= 2.2.2, < 4.0)
46
46
  regexp_parser (>= 1.8, < 3.0)
47
47
  rexml
48
- rubocop-ast (>= 1.16.0, < 2.0)
48
+ rubocop-ast (>= 1.17.0, < 2.0)
49
49
  ruby-progressbar (~> 1.7)
50
50
  unicode-display_width (>= 1.4.0, < 3.0)
51
51
  rubocop-ast (1.17.0)
@@ -63,8 +63,8 @@ GEM
63
63
  repo-small-badge (~> 0.2.7)
64
64
  simplecov (~> 0.17)
65
65
  simplecov_json_formatter (0.1.4)
66
- standard (1.10.0)
67
- rubocop (= 1.27.0)
66
+ standard (1.11.0)
67
+ rubocop (= 1.28.2)
68
68
  rubocop-performance (= 1.13.3)
69
69
  unicode-display_width (2.1.0)
70
70
  victor (0.2.8)
data/README.md CHANGED
@@ -5,24 +5,17 @@ It includes a pre-defined set of modules and classes that are essentially wrappe
5
5
 
6
6
  ## Installation
7
7
 
8
- From the command line:
9
- ```bash
10
- gem install justifi --version "0.4.0" --source "https://rubygems.pkg.github.com/justifi-tech"
11
- ```
12
- OR
13
-
14
8
  Add these lines to your application's Gemfile:
15
9
 
16
10
  ```ruby
17
11
  source "https://rubygems.pkg.github.com/justifi-tech" do
18
- gem "justifi", "0.4.0"
12
+ gem "justifi"
19
13
  end
20
14
  ```
21
15
  And then execute:
22
16
 
23
17
  $ bundle install
24
18
 
25
-
26
19
  ## Setup
27
20
 
28
21
  The gem needs to be configured with your `client_id` and `client_secret` in order to access JustiFi API resources.
data/lib/justifi/util.rb CHANGED
@@ -78,5 +78,12 @@ module Justifi
78
78
  end
79
79
  result
80
80
  end
81
+
82
+ # Creates a computed signature that can verify the payload sent.
83
+ # Each webhook has its own signature key that can be achieved in JustiFi's platform
84
+ def self.compute_signature(received_event, timestamp, secret_key)
85
+ timestamp_payload = "#{timestamp}.#{received_event.to_json}"
86
+ OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret_key, timestamp_payload)
87
+ end
81
88
  end
82
89
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Justifi
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Justifi
4
+ module Webhook
5
+ class << self
6
+ def verify_signature(received_event:, timestamp:, secret_key:, signature:)
7
+ signature == Util.compute_signature(received_event, timestamp, secret_key)
8
+ end
9
+ end
10
+ end
11
+ end
data/lib/justifi.rb CHANGED
@@ -19,6 +19,7 @@ require "justifi/dispute"
19
19
  require "justifi/payment_method"
20
20
  require "justifi/payment_intent"
21
21
  require "justifi/in_memory_cache"
22
+ require "justifi/webhook"
22
23
 
23
24
  module Justifi
24
25
  @config = Justifi::Configuration.setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: justifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - JustiFi
@@ -177,6 +177,7 @@ files:
177
177
  - lib/justifi/refund.rb
178
178
  - lib/justifi/util.rb
179
179
  - lib/justifi/version.rb
180
+ - lib/justifi/webhook.rb
180
181
  homepage: https://justifi.ai
181
182
  licenses: []
182
183
  metadata: