fake_stripe 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fake_stripe.rb +3 -0
- data/lib/fake_stripe/assets/v3.js +1 -1
- data/lib/fake_stripe/bootable.rb +18 -0
- data/lib/fake_stripe/stub_stripe_connect.rb +37 -0
- data/lib/fake_stripe/stub_stripe_js.rb +3 -16
- data/lib/fake_stripe/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95608f72cf54e33d771f23240b0a404a5ad5048d29a72715ae6bace87bd3b1f1
|
4
|
+
data.tar.gz: 0a674d0aefda0dc92596bad72dddb0b9030fb36c171c08a8111ec844cb92ee2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4744a1e8c3908b102f66715831dd6f94d5352a2b898a96465ae9c987753903e392aea45f9883b69abd85840a2d11678e00bcf6f31e61b92d8bc4dd7e475062f
|
7
|
+
data.tar.gz: 3ab46254d45a9f961572b1fe26d766fcad63a190d4cfce3a12f5015a08903d6aa3b0cf900316a6fcb539cf4633bf5ca2a0bfe099697190ffba2eb86a037f3df5
|
data/lib/fake_stripe.rb
CHANGED
@@ -2,6 +2,7 @@ require 'fake_stripe/configuration'
|
|
2
2
|
require 'fake_stripe/initializers/webmock'
|
3
3
|
require 'fake_stripe/stub_app'
|
4
4
|
require 'fake_stripe/stub_stripe_js'
|
5
|
+
require 'fake_stripe/stub_stripe_connect'
|
5
6
|
|
6
7
|
module FakeStripe
|
7
8
|
extend Configuration
|
@@ -33,8 +34,10 @@ module FakeStripe
|
|
33
34
|
Stripe.api_key = 'FAKE_STRIPE_API_KEY'
|
34
35
|
FakeStripe.reset
|
35
36
|
FakeStripe::StubStripeJS.boot_once
|
37
|
+
FakeStripe::StubStripeConnect.boot_once
|
36
38
|
stub_request(:any, /api.stripe.com/).to_rack(FakeStripe::StubApp)
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
40
42
|
STRIPE_JS_HOST = "http://localhost:#{FakeStripe::StubStripeJS.server_port}"
|
43
|
+
STRIPE_CONNECT_HOST = "http://localhost:#{FakeStripe::StubStripeConnect.server_port}"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "capybara"
|
2
|
+
require "capybara/server"
|
3
|
+
require "fake_stripe/utils"
|
4
|
+
|
5
|
+
module Bootable
|
6
|
+
def boot(port = FakeStripe::Utils.find_available_port)
|
7
|
+
instance = new
|
8
|
+
Capybara::Server.new(instance, port: port).tap(&:boot)
|
9
|
+
end
|
10
|
+
|
11
|
+
def boot_once
|
12
|
+
@boot_once ||= boot(server_port)
|
13
|
+
end
|
14
|
+
|
15
|
+
def server_port
|
16
|
+
@server_port ||= FakeStripe::Utils.find_available_port
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "fake_stripe/bootable"
|
2
|
+
require "sinatra/base"
|
3
|
+
|
4
|
+
module FakeStripe
|
5
|
+
class StubStripeConnect < Sinatra::Base
|
6
|
+
extend Bootable
|
7
|
+
|
8
|
+
CODE = "stripe_connect_express_oauth_authorization_code".freeze
|
9
|
+
|
10
|
+
post "/oauth/token" do
|
11
|
+
code = params[:code]
|
12
|
+
if code == CODE
|
13
|
+
{
|
14
|
+
access_token: "ACCESS_TOKEN",
|
15
|
+
livemode: false,
|
16
|
+
refresh_token: "REFRESH_TOEKN",
|
17
|
+
token_type: "bearer",
|
18
|
+
stripe_publishable_key: "PUBLISHABLE_KEY",
|
19
|
+
stripe_user_id: "acc_stripe_user_id",
|
20
|
+
scope: "express",
|
21
|
+
}.to_json
|
22
|
+
else
|
23
|
+
status 400
|
24
|
+
{
|
25
|
+
error: "invalid_grant",
|
26
|
+
error_description: "Authorization code does not exist: #{code}",
|
27
|
+
}.to_json
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
get "/express/oauth/authorize" do
|
32
|
+
uri = URI(params[:redirect_uri])
|
33
|
+
uri.query = URI.encode_www_form(state: params[:state], code: CODE)
|
34
|
+
redirect uri
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require "
|
2
|
-
require "capybara/server"
|
3
|
-
require "fake_stripe/utils"
|
1
|
+
require "fake_stripe/bootable"
|
4
2
|
require "sinatra/base"
|
5
3
|
|
6
4
|
module FakeStripe
|
7
5
|
class StubStripeJS < Sinatra::Base
|
6
|
+
extend Bootable
|
7
|
+
|
8
8
|
get "/v1/" do
|
9
9
|
file_path = File.join(File.dirname(__FILE__), "/assets/v1.js")
|
10
10
|
|
@@ -29,18 +29,5 @@ module FakeStripe
|
|
29
29
|
status 200
|
30
30
|
IO.read(file_path)
|
31
31
|
end
|
32
|
-
|
33
|
-
def self.boot(port = FakeStripe::Utils.find_available_port)
|
34
|
-
instance = new
|
35
|
-
Capybara::Server.new(instance, port: port).tap(&:boot)
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.boot_once
|
39
|
-
@@stripe_js_server ||= FakeStripe::StubStripeJS.boot(server_port)
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.server_port
|
43
|
-
@@stripe_js_port ||= FakeStripe::Utils.find_available_port
|
44
|
-
end
|
45
32
|
end
|
46
33
|
end
|
data/lib/fake_stripe/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fake_stripe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harlow Ward
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- lib/fake_stripe/assets/v2-mock.js
|
129
129
|
- lib/fake_stripe/assets/v2.js
|
130
130
|
- lib/fake_stripe/assets/v3.js
|
131
|
+
- lib/fake_stripe/bootable.rb
|
131
132
|
- lib/fake_stripe/configuration.rb
|
132
133
|
- lib/fake_stripe/fixtures/cancel_subscription.json
|
133
134
|
- lib/fake_stripe/fixtures/cancel_transfer.json
|
@@ -202,6 +203,7 @@ files:
|
|
202
203
|
- lib/fake_stripe/fixtures/update_transfer.json
|
203
204
|
- lib/fake_stripe/initializers/webmock.rb
|
204
205
|
- lib/fake_stripe/stub_app.rb
|
206
|
+
- lib/fake_stripe/stub_stripe_connect.rb
|
205
207
|
- lib/fake_stripe/stub_stripe_js.rb
|
206
208
|
- lib/fake_stripe/utils.rb
|
207
209
|
- lib/fake_stripe/version.rb
|
@@ -223,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
225
|
- !ruby/object:Gem::Version
|
224
226
|
version: '0'
|
225
227
|
requirements: []
|
226
|
-
|
227
|
-
rubygems_version: 2.7.7
|
228
|
+
rubygems_version: 3.0.3
|
228
229
|
signing_key:
|
229
230
|
specification_version: 4
|
230
231
|
summary: A fake Stripe server.
|