stripe 5.19.0 → 5.20.0
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/CHANGELOG.md +4 -1
- data/VERSION +1 -1
- data/lib/stripe/version.rb +1 -1
- data/lib/stripe/webhook.rb +17 -0
- data/test/stripe/webhook_test.rb +23 -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: 53d5362cf3395da735662c079302a68f77a067db5ed0b33d9049ab47a5d610e6
|
4
|
+
data.tar.gz: a33095d14ba39ec3d3a178c5b6a7aaf477f3290a060bc9955d840d30f284d9ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5708098cb83cae3806edc15aa7baa946f7e1107e380282e64012b59d849a8e5b1a6c394b23347b20dc94a81922760cdaea7cb6b634c8c2f35f8b8c74694e5bee
|
7
|
+
data.tar.gz: 3add4e8a981bf84adabf38d6c6ee98c7dbebb0254709e38e3ee9c4aeddd68c9ce1b78cf594cf1aad7c1bb587767952cba0be15a273bdb6bf31ed215040c5162b
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## - 2020-04-
|
3
|
+
## 5.20.0 - 2020-04-27
|
4
|
+
* [#916](https://github.com/stripe/stripe-ruby/pull/916) Add new `.generate_header` method for webhooks
|
5
|
+
|
6
|
+
## 5.19.0 - 2020-04-24
|
4
7
|
* [#915](https://github.com/stripe/stripe-ruby/pull/915) Expose `Stripe::Webhook.compute_signature` publicly
|
5
8
|
|
6
9
|
## 5.18.0 - 2020-04-22
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
5.
|
1
|
+
5.20.0
|
data/lib/stripe/version.rb
CHANGED
data/lib/stripe/webhook.rb
CHANGED
@@ -39,6 +39,23 @@ module Stripe
|
|
39
39
|
timestamped_payload)
|
40
40
|
end
|
41
41
|
|
42
|
+
# Generates a value that would be added to a `Stripe-Signature` for a
|
43
|
+
# given webhook payload.
|
44
|
+
#
|
45
|
+
# Note that this isn't needed to verify webhooks in any way, and is
|
46
|
+
# mainly here for use in test cases (those that are both within this
|
47
|
+
# project and without).
|
48
|
+
def self.generate_header(timestamp, signature, scheme: EXPECTED_SCHEME)
|
49
|
+
raise ArgumentError, "timestamp should be an instance of Time" \
|
50
|
+
unless timestamp.is_a?(Time)
|
51
|
+
raise ArgumentError, "signature should be a string" \
|
52
|
+
unless signature.is_a?(String)
|
53
|
+
raise ArgumentError, "scheme should be a string" \
|
54
|
+
unless scheme.is_a?(String)
|
55
|
+
|
56
|
+
"t=#{timestamp.to_i},#{scheme}=#{signature}"
|
57
|
+
end
|
58
|
+
|
42
59
|
# Extracts the timestamp and the signature(s) with the desired scheme
|
43
60
|
# from the header
|
44
61
|
def self.get_timestamp_and_signatures(header, scheme)
|
data/test/stripe/webhook_test.rb
CHANGED
@@ -22,7 +22,11 @@ module Stripe
|
|
22
22
|
opts[:payload],
|
23
23
|
opts[:secret]
|
24
24
|
)
|
25
|
-
|
25
|
+
Stripe::Webhook::Signature.generate_header(
|
26
|
+
opts[:timestamp],
|
27
|
+
opts[:signature],
|
28
|
+
scheme: opts[:scheme]
|
29
|
+
)
|
26
30
|
end
|
27
31
|
|
28
32
|
context ".compute_signature" do
|
@@ -38,6 +42,24 @@ module Stripe
|
|
38
42
|
end
|
39
43
|
end
|
40
44
|
|
45
|
+
context ".generate_header" do
|
46
|
+
should "generate a header in valid format" do
|
47
|
+
timestamp = Time.now
|
48
|
+
signature = Stripe::Webhook::Signature.compute_signature(
|
49
|
+
timestamp,
|
50
|
+
EVENT_PAYLOAD,
|
51
|
+
SECRET
|
52
|
+
)
|
53
|
+
scheme = "v1"
|
54
|
+
header = Stripe::Webhook::Signature.generate_header(
|
55
|
+
timestamp,
|
56
|
+
signature,
|
57
|
+
scheme: scheme
|
58
|
+
)
|
59
|
+
assert_equal("t=#{timestamp.to_i},#{scheme}=#{signature}", header)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
41
63
|
context ".construct_event" do
|
42
64
|
should "return an Event instance from a valid JSON payload and valid signature header" do
|
43
65
|
header = generate_header
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stripe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Stripe is the easiest way to accept payments online. See https://stripe.com
|
14
14
|
for details.
|