stripe-cli-ruby 1.33.0 → 1.55.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/README.md +18 -8
- data/lib/puma/plugin/stripe.rb +25 -9
- data/lib/stripe_cli/signing_secret.rb +4 -3
- data/lib/stripe_cli/upstream.rb +5 -3
- data/lib/stripe_cli/version.rb +1 -1
- data/lib/stripe_cli.rb +3 -10
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3aa4eebf08caad52436074ab4db7021e660233b37abf6998caa6127aa7b713ec
|
|
4
|
+
data.tar.gz: 9ad8f738ef37e1d874d4b2dd93bc499a7953f35ccd2a21748e868c6dcd758afa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33a5f1da95e56ba540338f8cd881ad5a237e7e82110982271b40f3196264155ad7fa494a411eb62e061fc308067822e350b4e94dfd7a76ba18950788b2cf8d50
|
|
7
|
+
data.tar.gz: f4511abc8659aaee87e3d6210dbd937ad4d2aad744af1f8931e99fefdbfe32109bc759a69adbbcb56ebadec69dc6445a69b771e0308ad886d0ea28d1267ba7c8
|
data/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Supported platforms are:
|
|
|
13
13
|
- `arm64-darwin` (macos-arm64)
|
|
14
14
|
- `x86_64-darwin` (macos-x64)
|
|
15
15
|
- `x86_64-linux` (linux-x64)
|
|
16
|
-
- `
|
|
16
|
+
- `aarch64-linux` (linux-arm64)
|
|
17
17
|
|
|
18
18
|
Install the gem and add to the application's Gemfile by executing:
|
|
19
19
|
|
|
@@ -39,7 +39,7 @@ The gem makes available `StripeCLI.executable` which is the path to the vendored
|
|
|
39
39
|
```ruby
|
|
40
40
|
require "stripe-cli-ruby"
|
|
41
41
|
StripeCLI.executable
|
|
42
|
-
# => "/path/to/
|
|
42
|
+
# => "/path/to/gems/stripe-cli-ruby-1.33.0-x86_64-linux/exe/x86_64-linux/stripe"
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
### Command line
|
|
@@ -52,8 +52,8 @@ $ bundle exec which stripe
|
|
|
52
52
|
/path/to/installs/ruby/3.3/bin/stripe
|
|
53
53
|
|
|
54
54
|
# run the actual executable through the shim
|
|
55
|
-
$ bundle exec stripe --
|
|
56
|
-
stripe version 1.
|
|
55
|
+
$ bundle exec stripe --version
|
|
56
|
+
stripe version 1.33.0
|
|
57
57
|
```
|
|
58
58
|
|
|
59
59
|
## Forwarding events to your web server
|
|
@@ -71,7 +71,9 @@ Add `plugin :stripe` to `puma.rb` configuration:
|
|
|
71
71
|
plugin :stripe if ENV["RAILS_ENV"] == "development"
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
By default, events will be forwarded to `/stripe_events`, this can be configured using `stripe_forward_to "/stripe/webhook"` in `puma.rb`.
|
|
74
|
+
By default, all events will be forwarded to `/stripe_events`, this can be configured using `stripe_forward_to "/stripe/webhook"` in `puma.rb`.
|
|
75
|
+
|
|
76
|
+
To forward the events of the webhook endpoints set up in your Stripe dashboard instead, add `stripe_use_configured_webhooks` to `puma.rb`. Each endpoint's events go to that endpoint's path on your local server, so an endpoint at `https://example.com/stripe/webhook` gets forwarded to `http://localhost:3000/stripe/webhook`. Your test mode account needs at least one webhook endpoint.
|
|
75
77
|
|
|
76
78
|
You can grab your *signing secret* using `StripeCLI.signing_secret`. For example:
|
|
77
79
|
|
|
@@ -79,7 +81,7 @@ You can grab your *signing secret* using `StripeCLI.signing_secret`. For example
|
|
|
79
81
|
# config/environments/development.rb
|
|
80
82
|
config.stripe_signing_secret = StripeCLI.signing_secret(Stripe.api_key)
|
|
81
83
|
|
|
82
|
-
# app/
|
|
84
|
+
# app/controllers/stripe_events_controller.rb
|
|
83
85
|
class StripeEventsController < ActionController::API
|
|
84
86
|
before_action :set_event
|
|
85
87
|
|
|
@@ -110,9 +112,17 @@ end
|
|
|
110
112
|
|
|
111
113
|
## Development
|
|
112
114
|
|
|
113
|
-
|
|
115
|
+
Run `bin/setup` to install dependencies, `bundle exec rake download` to fetch the Stripe CLI binaries, and `bundle exec rake test` to run the tests. Set `TEST_STRIPE_API_KEY` to a test-mode key to run the tests that talk to Stripe.
|
|
116
|
+
|
|
117
|
+
## Releases
|
|
118
|
+
|
|
119
|
+
Releases are automatic:
|
|
120
|
+
|
|
121
|
+
1. The `update` workflow checks for a new Stripe CLI release every day. When there is one, the workflow bumps `StripeCLI::VERSION` and `StripeCLI::Upstream::VERSION` and pushes the commit to `main`.
|
|
122
|
+
2. The `ci` workflow tests every push to `main`, builds a gem per platform, and installs each one on its platform.
|
|
123
|
+
3. When `StripeCLI::VERSION` isn't tagged yet, `ci` pushes the gems to rubygems.org with [trusted publishing](https://guides.rubygems.org/trusted-publishing/) and creates a GitHub release.
|
|
114
124
|
|
|
115
|
-
To
|
|
125
|
+
To ship a fix without a new Stripe CLI version, bump `StripeCLI::VERSION` to something like `1.33.0.1` and push to `main`.
|
|
116
126
|
|
|
117
127
|
## Contributing
|
|
118
128
|
|
data/lib/puma/plugin/stripe.rb
CHANGED
|
@@ -3,18 +3,21 @@
|
|
|
3
3
|
require "puma"
|
|
4
4
|
require "puma/plugin"
|
|
5
5
|
require "stripe"
|
|
6
|
+
require "stripe_cli"
|
|
6
7
|
|
|
7
8
|
Puma::Plugin.create do
|
|
8
9
|
def start(launcher)
|
|
9
10
|
@launcher = launcher
|
|
10
11
|
|
|
11
12
|
launcher.events.on_booted do
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
launcher.log_writer.log "[Stripe] Not found. See https://docs.stripe.com/stripe-cli#install"
|
|
13
|
+
if use_configured_webhooks?
|
|
14
|
+
launcher.log_writer.log "Stripe: forwarding webhooks configured in the dashboard to #{forward_to}"
|
|
15
|
+
else
|
|
16
|
+
launcher.log_writer.log "Stripe: forwarding webhooks to #{forward_to}"
|
|
17
17
|
end
|
|
18
|
+
@pid = spawn(StripeCLI.executable, "listen", "--all-snapshot", *("--use-configured-webhooks" if use_configured_webhooks?), "--forward-to", forward_to.to_s, "--api-key", Stripe.api_key.to_s)
|
|
19
|
+
rescue StripeCLI::UnsupportedPlatformException, StripeCLI::ExecutableNotFoundException, Errno::ENOENT => e
|
|
20
|
+
launcher.log_writer.log "[Stripe] Could not start the Stripe CLI: #{e.message}"
|
|
18
21
|
end
|
|
19
22
|
|
|
20
23
|
launcher.events.on_stopped { stop_stripe }
|
|
@@ -22,17 +25,26 @@ Puma::Plugin.create do
|
|
|
22
25
|
|
|
23
26
|
private
|
|
24
27
|
def stop_stripe
|
|
25
|
-
|
|
28
|
+
return unless @pid
|
|
29
|
+
|
|
26
30
|
@launcher.log_writer.log "[Stripe] Stopping..."
|
|
27
|
-
Process.kill(:INT, @pid)
|
|
31
|
+
Process.kill(:INT, @pid)
|
|
28
32
|
Process.wait(@pid)
|
|
29
33
|
rescue Errno::ECHILD, Errno::ESRCH
|
|
30
34
|
end
|
|
31
35
|
|
|
36
|
+
def use_configured_webhooks?
|
|
37
|
+
@launcher.options[:stripe_use_configured_webhooks]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Dashboard endpoints bring their own paths, so only the host and port are ours.
|
|
32
41
|
def forward_to
|
|
33
|
-
path = @launcher.options.fetch(:stripe_forward_to, "/stripe_events")
|
|
34
42
|
_, port, host = @launcher.binder.ios.first.addr
|
|
35
|
-
|
|
43
|
+
if use_configured_webhooks?
|
|
44
|
+
URI::HTTP.build(port:, host:)
|
|
45
|
+
else
|
|
46
|
+
URI::HTTP.build(port:, host:, path: @launcher.options.fetch(:stripe_forward_to, "/stripe_events"))
|
|
47
|
+
end
|
|
36
48
|
end
|
|
37
49
|
end
|
|
38
50
|
|
|
@@ -41,5 +53,9 @@ module Puma
|
|
|
41
53
|
def stripe_forward_to(path)
|
|
42
54
|
@options[:stripe_forward_to] = path
|
|
43
55
|
end
|
|
56
|
+
|
|
57
|
+
def stripe_use_configured_webhooks(enabled = true)
|
|
58
|
+
@options[:stripe_use_configured_webhooks] = enabled
|
|
59
|
+
end
|
|
44
60
|
end
|
|
45
61
|
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "open3"
|
|
4
|
+
|
|
3
5
|
module StripeCLI
|
|
4
6
|
def self.signing_secret(api_key)
|
|
5
|
-
secret =
|
|
6
|
-
|
|
7
|
-
secret unless secret.empty?
|
|
7
|
+
secret, status = Open3.capture2(executable, "listen", "--api-key", api_key.to_s, "--print-secret", err: File::NULL)
|
|
8
|
+
secret.chomp if status.success? && !secret.strip.empty?
|
|
8
9
|
rescue
|
|
9
10
|
nil
|
|
10
11
|
end
|
data/lib/stripe_cli/upstream.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module StripeCLI
|
|
2
|
-
# constants describing the upstream
|
|
4
|
+
# constants describing the upstream stripe/stripe-cli project
|
|
3
5
|
module Upstream
|
|
4
|
-
VERSION = "1.
|
|
6
|
+
VERSION = "1.55.0"
|
|
5
7
|
|
|
6
8
|
# rubygems platform name => upstream release filename
|
|
7
9
|
NATIVE_PLATFORMS = {
|
|
8
10
|
"arm64-darwin" => "stripe_#{VERSION}_mac-os_arm64.tar.gz",
|
|
9
|
-
"
|
|
11
|
+
"aarch64-linux" => "stripe_#{VERSION}_linux_arm64.tar.gz",
|
|
10
12
|
"x86_64-darwin" => "stripe_#{VERSION}_mac-os_x86_64.tar.gz",
|
|
11
13
|
"x86_64-linux" => "stripe_#{VERSION}_linux_x86_64.tar.gz"
|
|
12
14
|
}
|
data/lib/stripe_cli/version.rb
CHANGED
data/lib/stripe_cli.rb
CHANGED
|
@@ -16,10 +16,6 @@ module StripeCLI
|
|
|
16
16
|
class ExecutableNotFoundException < StandardError
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
# raised when STRIPE_CLI_INSTALL_DIR does not exist
|
|
20
|
-
class DirectoryNotFoundException < StandardError
|
|
21
|
-
end
|
|
22
|
-
|
|
23
19
|
class << self
|
|
24
20
|
def platform
|
|
25
21
|
[ :cpu, :os ].map { |m| Gem::Platform.local.send(m) }.join("-")
|
|
@@ -28,9 +24,8 @@ module StripeCLI
|
|
|
28
24
|
def executable(exe_path: DEFAULT_DIR)
|
|
29
25
|
if StripeCLI::Upstream::NATIVE_PLATFORMS.keys.none? { |p| Gem::Platform.match_gem?(Gem::Platform.new(p), GEM_NAME) }
|
|
30
26
|
raise UnsupportedPlatformException, <<~MESSAGE
|
|
31
|
-
#{GEM_NAME} does not support the #{platform} platform
|
|
32
|
-
|
|
33
|
-
for more details.
|
|
27
|
+
#{GEM_NAME} does not support the #{platform} platform.
|
|
28
|
+
Install the Stripe CLI another way: https://docs.stripe.com/stripe-cli#install
|
|
34
29
|
MESSAGE
|
|
35
30
|
end
|
|
36
31
|
|
|
@@ -55,9 +50,7 @@ module StripeCLI
|
|
|
55
50
|
See `bundle lock --help` output for details.
|
|
56
51
|
|
|
57
52
|
If you're still seeing this message after taking those steps, try running
|
|
58
|
-
`bundle config` and ensure `force_ruby_platform` isn't set to `true`.
|
|
59
|
-
https://github.com/flavorjones/tailwindcss-ruby#check-bundle_force_ruby_platform
|
|
60
|
-
for more details.
|
|
53
|
+
`bundle config` and ensure `force_ruby_platform` isn't set to `true`.
|
|
61
54
|
MESSAGE
|
|
62
55
|
end
|
|
63
56
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: stripe-cli-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.55.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Zacharias Knudsen
|
|
@@ -73,7 +73,7 @@ licenses:
|
|
|
73
73
|
- MIT
|
|
74
74
|
metadata:
|
|
75
75
|
source_code_uri: https://github.com/zachasme/stripe-cli-ruby
|
|
76
|
-
changelog_uri: https://github.com/zachasme/stripe-cli-ruby/
|
|
76
|
+
changelog_uri: https://github.com/zachasme/stripe-cli-ruby/releases
|
|
77
77
|
rubygems_mfa_required: 'true'
|
|
78
78
|
rdoc_options: []
|
|
79
79
|
require_paths:
|
|
@@ -82,14 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
82
82
|
requirements:
|
|
83
83
|
- - ">="
|
|
84
84
|
- !ruby/object:Gem::Version
|
|
85
|
-
version: 3.
|
|
85
|
+
version: 3.2.0
|
|
86
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
|
88
88
|
- - ">="
|
|
89
89
|
- !ruby/object:Gem::Version
|
|
90
90
|
version: '0'
|
|
91
91
|
requirements: []
|
|
92
|
-
rubygems_version:
|
|
92
|
+
rubygems_version: 4.0.20
|
|
93
93
|
specification_version: 4
|
|
94
94
|
summary: A self-contained `stripe` executable.
|
|
95
95
|
test_files: []
|