justifi 0.5.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -9
- data/README.md +15 -10
- data/lib/justifi/balance_transaction.rb +18 -0
- data/lib/justifi/payment.rb +2 -2
- data/lib/justifi/util.rb +7 -0
- data/lib/justifi/version.rb +1 -1
- data/lib/justifi/webhook.rb +11 -0
- data/lib/justifi.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bcd2d68a4fce4e0a644aa81c8c65e9e0a11bb31991583379b86b00d5db3f79e2
|
4
|
+
data.tar.gz: 5c7edcdb32022a4f56bbd3a688b496d376838dbce1b4528ccb6201e0e2eaddf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 150f2bb84c5fba3693dbf7d4c6889963809c00314e468845c3c6dbab3a9b2eec6b2b574fde0ab85821c62a9b519b116eddeafc65280dd0cf188e9941ff052bf5
|
7
|
+
data.tar.gz: e3612d77657510b4bcadaf8fbe6a316b642a9292f3048a5c7a4925b3d3852f9da8d3a14a58e0f04b1399f50b21ee5dd2d63b9dfd3c4bd62fb4c78b913e99ea7b
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
justifi (0.
|
4
|
+
justifi (0.6.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.
|
25
|
+
regexp_parser (2.4.0)
|
26
26
|
repo-small-badge (0.2.7)
|
27
27
|
victor (~> 0.2.8)
|
28
28
|
rexml (3.2.5)
|
@@ -39,16 +39,16 @@ 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.
|
42
|
+
rubocop (1.29.1)
|
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
|
-
rexml
|
48
|
-
rubocop-ast (>= 1.
|
47
|
+
rexml (>= 3.2.5, < 4.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
|
-
rubocop-ast (1.
|
51
|
+
rubocop-ast (1.18.0)
|
52
52
|
parser (>= 3.1.1.0)
|
53
53
|
rubocop-performance (1.13.3)
|
54
54
|
rubocop (>= 1.7.0, < 2.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.
|
67
|
-
rubocop (= 1.
|
66
|
+
standard (1.12.1)
|
67
|
+
rubocop (= 1.29.1)
|
68
68
|
rubocop-performance (= 1.13.3)
|
69
69
|
unicode-display_width (2.1.0)
|
70
70
|
victor (0.2.8)
|
@@ -89,4 +89,4 @@ DEPENDENCIES
|
|
89
89
|
webmock (>= 3.8.0)
|
90
90
|
|
91
91
|
BUNDLED WITH
|
92
|
-
2.2.
|
92
|
+
2.2.15
|
data/README.md
CHANGED
@@ -5,24 +5,15 @@ 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
|
-
|
18
|
-
gem "justifi", "0.4.0"
|
19
|
-
end
|
11
|
+
gem "justifi"
|
20
12
|
```
|
21
13
|
And then execute:
|
22
14
|
|
23
15
|
$ bundle install
|
24
16
|
|
25
|
-
|
26
17
|
## Setup
|
27
18
|
|
28
19
|
The gem needs to be configured with your `client_id` and `client_secret` in order to access JustiFi API resources.
|
@@ -204,6 +195,20 @@ Justifi::PaymentIntent.create(params: payment_intent_params, seller_account_id:
|
|
204
195
|
Any API resource using the `seller_account_id` variable will include the `Seller-Account` header and be
|
205
196
|
processed as the seller account.
|
206
197
|
|
198
|
+
## Webhook Signature Verification
|
199
|
+
|
200
|
+
Webhooks are secured by signature verification. An encrypted header is sent as a POST to your API endpoint (JUSTIFI-SIGNATURE),
|
201
|
+
which will need to be decrypted and verified with the signature secret provided.
|
202
|
+
You can use the JustiFi Ruby gem to validate the signature.
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
received_event = { id: "py_..." } # JustiFi webhook event
|
206
|
+
signature = "2463896d3cb..." # justifi-signature header
|
207
|
+
timestamp = "1651076887..." # justifi-timestamp header
|
208
|
+
secret_key = "sigk_2..." # secret key used for this webhook
|
209
|
+
Justifi::Webhook.verify_signature(received_event: received_event, timestamp: timestamp, secret_key: secret_key, signature: signature) # valid or not
|
210
|
+
```
|
211
|
+
|
207
212
|
## Contributing
|
208
213
|
|
209
214
|
### Release a new version of the gem
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Justifi
|
4
|
+
module BalanceTransaction
|
5
|
+
class << self
|
6
|
+
def list(params: {}, headers: {}, seller_account_id: nil)
|
7
|
+
headers[:seller_account] = seller_account_id if seller_account_id
|
8
|
+
JustifiOperations.execute_get_request("/v1/balance_transactions", params, headers)
|
9
|
+
end
|
10
|
+
|
11
|
+
def get(id:, headers: {})
|
12
|
+
JustifiOperations.execute_get_request("/v1/balance_transactions/#{id}",
|
13
|
+
{},
|
14
|
+
headers)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/justifi/payment.rb
CHANGED
@@ -11,8 +11,8 @@ module Justifi
|
|
11
11
|
headers: headers)
|
12
12
|
end
|
13
13
|
|
14
|
-
def create_refund(amount:, payment_id:, reason: nil, description: nil)
|
15
|
-
refund_params = {amount: amount, description: description, reason: reason}
|
14
|
+
def create_refund(amount:, payment_id:, reason: nil, description: nil, metadata: nil)
|
15
|
+
refund_params = {amount: amount, description: description, reason: reason, metadata: metadata}
|
16
16
|
JustifiOperations.idempotently_request("/v1/payments/#{payment_id}/refunds",
|
17
17
|
method: :post,
|
18
18
|
params: refund_params,
|
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
|
data/lib/justifi/version.rb
CHANGED
@@ -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
@@ -15,10 +15,12 @@ require "justifi/oauth"
|
|
15
15
|
require "justifi/payment"
|
16
16
|
require "justifi/refund"
|
17
17
|
require "justifi/payout"
|
18
|
+
require "justifi/balance_transaction"
|
18
19
|
require "justifi/dispute"
|
19
20
|
require "justifi/payment_method"
|
20
21
|
require "justifi/payment_intent"
|
21
22
|
require "justifi/in_memory_cache"
|
23
|
+
require "justifi/webhook"
|
22
24
|
|
23
25
|
module Justifi
|
24
26
|
@config = Justifi::Configuration.setup
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: justifi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JustiFi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- justifi.gemspec
|
162
162
|
- lib/justifi.rb
|
163
163
|
- lib/justifi/api_operations.rb
|
164
|
+
- lib/justifi/balance_transaction.rb
|
164
165
|
- lib/justifi/configuration.rb
|
165
166
|
- lib/justifi/dispute.rb
|
166
167
|
- lib/justifi/in_memory_cache.rb
|
@@ -177,6 +178,7 @@ files:
|
|
177
178
|
- lib/justifi/refund.rb
|
178
179
|
- lib/justifi/util.rb
|
179
180
|
- lib/justifi/version.rb
|
181
|
+
- lib/justifi/webhook.rb
|
180
182
|
homepage: https://justifi.ai
|
181
183
|
licenses: []
|
182
184
|
metadata:
|