stripe_local 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +35 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/stripe_local/application.js +13 -0
- data/app/assets/javascripts/stripe_local/cards.js +2 -0
- data/app/assets/javascripts/stripe_local/charges.js +2 -0
- data/app/assets/javascripts/stripe_local/coupons.js +2 -0
- data/app/assets/javascripts/stripe_local/customers.js +2 -0
- data/app/assets/javascripts/stripe_local/discounts.js +2 -0
- data/app/assets/javascripts/stripe_local/invoices.js +2 -0
- data/app/assets/javascripts/stripe_local/line_items.js +2 -0
- data/app/assets/javascripts/stripe_local/plans.js +2 -0
- data/app/assets/javascripts/stripe_local/subscriptions.js +2 -0
- data/app/assets/stylesheets/stripe_local/application.css +13 -0
- data/app/assets/stylesheets/stripe_local/cards.css +4 -0
- data/app/assets/stylesheets/stripe_local/charges.css +4 -0
- data/app/assets/stylesheets/stripe_local/coupons.css +4 -0
- data/app/assets/stylesheets/stripe_local/customers.css +4 -0
- data/app/assets/stylesheets/stripe_local/discounts.css +4 -0
- data/app/assets/stylesheets/stripe_local/invoices.css +4 -0
- data/app/assets/stylesheets/stripe_local/line_items.css +4 -0
- data/app/assets/stylesheets/stripe_local/plans.css +4 -0
- data/app/assets/stylesheets/stripe_local/subscriptions.css +4 -0
- data/app/callbacks/stripe_local/plan_sync.rb +33 -0
- data/app/controllers/stripe_local/application_controller.rb +4 -0
- data/app/controllers/stripe_local/cards_controller.rb +6 -0
- data/app/controllers/stripe_local/charges_controller.rb +6 -0
- data/app/controllers/stripe_local/coupons_controller.rb +6 -0
- data/app/controllers/stripe_local/customers_controller.rb +6 -0
- data/app/controllers/stripe_local/discounts_controller.rb +6 -0
- data/app/controllers/stripe_local/invoices_controller.rb +6 -0
- data/app/controllers/stripe_local/line_items_controller.rb +6 -0
- data/app/controllers/stripe_local/plans_controller.rb +6 -0
- data/app/controllers/stripe_local/subscriptions_controller.rb +6 -0
- data/app/controllers/stripe_local/webhooks_controller.rb +13 -0
- data/app/helpers/stripe_local/application_helper.rb +4 -0
- data/app/helpers/stripe_local/cards_helper.rb +4 -0
- data/app/helpers/stripe_local/charges_helper.rb +4 -0
- data/app/helpers/stripe_local/coupons_helper.rb +4 -0
- data/app/helpers/stripe_local/customers_helper.rb +4 -0
- data/app/helpers/stripe_local/discounts_helper.rb +4 -0
- data/app/helpers/stripe_local/invoices_helper.rb +4 -0
- data/app/helpers/stripe_local/line_items_helper.rb +4 -0
- data/app/helpers/stripe_local/plans_helper.rb +4 -0
- data/app/helpers/stripe_local/subscriptions_helper.rb +4 -0
- data/app/mixins/stripe_local/object_adapter.rb +33 -0
- data/app/mixins/stripe_local/sync_plans.rb +39 -0
- data/app/models/stripe_local/balance.rb +48 -0
- data/app/models/stripe_local/card.rb +39 -0
- data/app/models/stripe_local/charge.rb +63 -0
- data/app/models/stripe_local/coupon.rb +21 -0
- data/app/models/stripe_local/customer.rb +98 -0
- data/app/models/stripe_local/discount.rb +36 -0
- data/app/models/stripe_local/invoice.rb +68 -0
- data/app/models/stripe_local/line_item.rb +56 -0
- data/app/models/stripe_local/plan.rb +41 -0
- data/app/models/stripe_local/subscription.rb +50 -0
- data/app/models/stripe_local/transaction.rb +45 -0
- data/app/models/stripe_local/transfer.rb +48 -0
- data/app/validators/email_pattern_validator.rb +7 -0
- data/app/validators/full_name_pattern_validator.rb +7 -0
- data/app/validators/legal_name_pattern_validator.rb +7 -0
- data/app/validators/phone_pattern_validator.rb +17 -0
- data/app/validators/plan_id_pattern_validator.rb +7 -0
- data/app/validators/slug_pattern_validator.rb +38 -0
- data/app/validators/state_abbreviation_validator.rb +13 -0
- data/app/validators/stripe_type_validator.rb +7 -0
- data/app/validators/zip_type_validator.rb +8 -0
- data/app/views/layouts/stripe_local/application.html.erb +14 -0
- data/config/routes.rb +22 -0
- data/db/migrate/20131122063517_load_stripe_tables.rb +200 -0
- data/lib/stripe_local/engine.rb +7 -0
- data/lib/stripe_local/version.rb +3 -0
- data/lib/stripe_local/webhook/subscriber.rb +34 -0
- data/lib/stripe_local/webhook/types.rb +45 -0
- data/lib/stripe_local/webhook.rb +55 -0
- data/lib/stripe_local/webhooks.rb +20 -0
- data/lib/stripe_local.rb +48 -0
- data/lib/tasks/stripe_local_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/client.rb +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +21 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +17 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20131102200937_create_clients.rb +11 -0
- data/spec/dummy/db/migrate/20131122104223_add_stripe_customer_id_to_clients.rb +5 -0
- data/spec/dummy/db/schema.rb +236 -0
- data/spec/dummy/log/development.log +1290 -0
- data/spec/dummy/log/test.log +7041 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/spec_helper.rb +42 -0
- data/spec/fixtures/client_params.json +18 -0
- data/spec/fixtures/credit_card.json +18 -0
- data/spec/fixtures/stripe_local/balance_transactions.yml +25 -0
- data/spec/fixtures/stripe_local/cards.yml +21 -0
- data/spec/fixtures/stripe_local/charges.yml +37 -0
- data/spec/fixtures/stripe_local/coupons.yml +23 -0
- data/spec/fixtures/stripe_local/customers.yml +21 -0
- data/spec/fixtures/stripe_local/discounts.yml +13 -0
- data/spec/fixtures/stripe_local/invoices.yml +37 -0
- data/spec/fixtures/stripe_local/line_items.yml +19 -0
- data/spec/fixtures/stripe_local/plans.yml +17 -0
- data/spec/fixtures/stripe_local/subscriptions.yml +25 -0
- data/spec/fixtures/stripe_local/transfers.yml +17 -0
- data/spec/models/stripe_local/balance_spec.rb +47 -0
- data/spec/models/stripe_local/card_spec.rb +13 -0
- data/spec/models/stripe_local/charge_spec.rb +13 -0
- data/spec/models/stripe_local/customer_spec.rb +17 -0
- data/spec/models/stripe_local/invoice_spec.rb +17 -0
- data/spec/models/stripe_local/plan_spec.rb +33 -0
- data/spec/models/stripe_local/subscription_spec.rb +15 -0
- data/spec/models/stripe_local/transaction_spec.rb +14 -0
- data/spec/models/stripe_local/transfer_spec.rb +13 -0
- data/spec/spec_helper.rb +19 -0
- data/spec/webhook_fixtures/balance_transaction.json +23 -0
- data/spec/webhook_fixtures/charge.succeeded.json +45 -0
- data/spec/webhook_fixtures/customer.created.json +41 -0
- data/spec/webhook_fixtures/customer.subscription.created.json +27 -0
- data/spec/webhook_fixtures/customer_creation_response.json +66 -0
- data/spec/webhook_fixtures/invoice.payment_succeeded.json +55 -0
- data/spec/webhook_fixtures/plan.created.json +12 -0
- data/spec/webhook_fixtures/transfer.json +32 -0
- metadata +403 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../../config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
|
7
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
8
|
+
# in spec/support/ and its subdirectories.
|
9
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
10
|
+
|
11
|
+
# Checks for pending migrations before tests are run.
|
12
|
+
# If you are not using ActiveRecord, you can remove this line.
|
13
|
+
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
14
|
+
|
15
|
+
RSpec.configure do |config|
|
16
|
+
# ## Mock Framework
|
17
|
+
#
|
18
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
19
|
+
#
|
20
|
+
# config.mock_with :mocha
|
21
|
+
# config.mock_with :flexmock
|
22
|
+
# config.mock_with :rr
|
23
|
+
|
24
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
25
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
26
|
+
|
27
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
28
|
+
# examples within a transaction, remove the following line or assign false
|
29
|
+
# instead of true.
|
30
|
+
config.use_transactional_fixtures = true
|
31
|
+
|
32
|
+
# If true, the base class of anonymous controllers will be inferred
|
33
|
+
# automatically. This will be the default behavior in future versions of
|
34
|
+
# rspec-rails.
|
35
|
+
config.infer_base_class_for_anonymous_controllers = false
|
36
|
+
|
37
|
+
# Run specs in random order to surface order dependencies. If you find an
|
38
|
+
# order dependency and want to debug it, you can fix the order by providing
|
39
|
+
# the seed, which is printed after each run.
|
40
|
+
# --seed 1234
|
41
|
+
config.order = "random"
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"client": {
|
3
|
+
"address": {
|
4
|
+
"city": "<%= m.fetch( :city, 'Lees Summit' ) %>",
|
5
|
+
"state": "<%= m.fetch( :state, 'MO' ) %>",
|
6
|
+
"street": "<%= m.fetch( :street, '429 NE Station Dr' ) %>",
|
7
|
+
"zip": "<%= m.fetch( :zip, 64086 ) %>"
|
8
|
+
},
|
9
|
+
"email": "<%= m.fetch( :email, 'outlawandy@gmail.com' ) %>",
|
10
|
+
"full_name": "<%= m.fetch( :full_name, 'John Applebrain' ) %>",
|
11
|
+
"organization": "<%= m.fetch( :organization, 'John''s Bon-Bons' ) %>",
|
12
|
+
"phone": "<%= m.fetch( :phone, '8167974635' ) %>"
|
13
|
+
},
|
14
|
+
"coupon": "<%= m.fetch( :coupon, nil ) %>",
|
15
|
+
"path": "complyability",
|
16
|
+
"plan": "<%= m.fetch( :plan, 'HR99') %>",
|
17
|
+
"stripe_card_token": "<%= m.fetch( :token, 'stub_token') %>"
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
"card": {
|
2
|
+
"id": "card_102VMn1Cmf55uWiegCrCV1A5",
|
3
|
+
"object": "card",
|
4
|
+
"last4": "4242",
|
5
|
+
"type": "Visa",
|
6
|
+
"exp_month": 8,
|
7
|
+
"exp_year": 2014,
|
8
|
+
"fingerprint": "Y7M2OsbpnbUz91ED",
|
9
|
+
"customer": null,
|
10
|
+
"country": "US",
|
11
|
+
"name": null,
|
12
|
+
"address_line1": null,
|
13
|
+
"address_line2": null,
|
14
|
+
"address_city": null,
|
15
|
+
"address_state": null,
|
16
|
+
"address_zip": null,
|
17
|
+
"address_country": null
|
18
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: MyString
|
5
|
+
amount: 1
|
6
|
+
available_on: 2013-11-14 22:25:48
|
7
|
+
created: 2013-11-14 22:25:48
|
8
|
+
fee: 1
|
9
|
+
net: 1
|
10
|
+
source_id: MyString
|
11
|
+
source_type: MyString
|
12
|
+
status: MyString
|
13
|
+
description: MyString
|
14
|
+
|
15
|
+
two:
|
16
|
+
id: MyString
|
17
|
+
amount: 1
|
18
|
+
available_on: 2013-11-14 22:25:48
|
19
|
+
created: 2013-11-14 22:25:48
|
20
|
+
fee: 1
|
21
|
+
net: 1
|
22
|
+
source_id: MyString
|
23
|
+
source_type: MyString
|
24
|
+
status: MyString
|
25
|
+
description: MyString
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: MyString
|
5
|
+
customer_id:
|
6
|
+
name: MyString
|
7
|
+
exp_month: 1
|
8
|
+
exp_year: 1
|
9
|
+
brand: MyString
|
10
|
+
last4: MyString
|
11
|
+
cvc_check: MyString
|
12
|
+
|
13
|
+
two:
|
14
|
+
id: MyString
|
15
|
+
customer_id:
|
16
|
+
name: MyString
|
17
|
+
exp_month: 1
|
18
|
+
exp_year: 1
|
19
|
+
brand: MyString
|
20
|
+
last4: MyString
|
21
|
+
cvc_check: MyString
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: MyString
|
5
|
+
customer_id: MyString
|
6
|
+
transaction_id: MyString
|
7
|
+
amount: 1
|
8
|
+
captured: false
|
9
|
+
refunded: false
|
10
|
+
paid: false
|
11
|
+
created: 2013-11-01 12:15:03
|
12
|
+
currency: MyString
|
13
|
+
amount_refunded: 1
|
14
|
+
description: MyString
|
15
|
+
invoice_id: MyString
|
16
|
+
failure_code: MyString
|
17
|
+
failure_message: MyString
|
18
|
+
metadata: MyText
|
19
|
+
card_id: MyString
|
20
|
+
|
21
|
+
two:
|
22
|
+
id: MyString
|
23
|
+
customer_id: MyString
|
24
|
+
transaction_id: MyString
|
25
|
+
amount: 1
|
26
|
+
captured: false
|
27
|
+
refunded: false
|
28
|
+
paid: false
|
29
|
+
created: 2013-11-01 12:15:03
|
30
|
+
currency: MyString
|
31
|
+
amount_refunded: 1
|
32
|
+
description: MyString
|
33
|
+
invoice_id: MyString
|
34
|
+
failure_code: MyString
|
35
|
+
failure_message: MyString
|
36
|
+
metadata: MyText
|
37
|
+
card_id: MyString
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: MyString
|
5
|
+
percent_off: 1
|
6
|
+
amount_off: 1
|
7
|
+
currency: MyString
|
8
|
+
duration: MyString
|
9
|
+
redeem_by: 2013-10-30 22:24:53
|
10
|
+
max_redemptions: 1
|
11
|
+
times_redeemed: 1
|
12
|
+
duration_in_months: 1
|
13
|
+
|
14
|
+
two:
|
15
|
+
id: MyString
|
16
|
+
percent_off: 1
|
17
|
+
amount_off: 1
|
18
|
+
currency: MyString
|
19
|
+
duration: MyString
|
20
|
+
redeem_by: 2013-10-30 22:24:53
|
21
|
+
max_redemptions: 1
|
22
|
+
times_redeemed: 1
|
23
|
+
duration_in_months: 1
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
account_balance: 1
|
5
|
+
default_card: MyString
|
6
|
+
delinquent: false
|
7
|
+
description: MyString
|
8
|
+
email: MyString
|
9
|
+
metadata: MyText
|
10
|
+
model_type: MyString
|
11
|
+
model_id: 1
|
12
|
+
|
13
|
+
two:
|
14
|
+
account_balance: 1
|
15
|
+
default_card: MyString
|
16
|
+
delinquent: false
|
17
|
+
description: MyString
|
18
|
+
email: MyString
|
19
|
+
metadata: MyText
|
20
|
+
model_type: MyString
|
21
|
+
model_id: 1
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
coupon_id: MyString
|
5
|
+
subscription_id: MyString
|
6
|
+
start: 2013-10-31 22:40:57
|
7
|
+
end: 2013-10-31 22:40:57
|
8
|
+
|
9
|
+
two:
|
10
|
+
coupon_id: MyString
|
11
|
+
subscription_id: MyString
|
12
|
+
start: 2013-10-31 22:40:57
|
13
|
+
end: 2013-10-31 22:40:57
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
customer_id: MyString
|
5
|
+
amount_due: 1
|
6
|
+
attempt_count: 1
|
7
|
+
attempted: false
|
8
|
+
closed: false
|
9
|
+
currency: MyString
|
10
|
+
date: 2013-11-01 06:03:59
|
11
|
+
paid: false
|
12
|
+
period_start: 2013-11-01 06:03:59
|
13
|
+
period_end: 2013-11-01 06:03:59
|
14
|
+
starting_balance: 1
|
15
|
+
subtotal: 1
|
16
|
+
total: 1
|
17
|
+
charge_id: MyString
|
18
|
+
ending_balance: 1
|
19
|
+
next_payment_attempt: 2013-11-01 06:03:59
|
20
|
+
|
21
|
+
two:
|
22
|
+
customer_id: MyString
|
23
|
+
amount_due: 1
|
24
|
+
attempt_count: 1
|
25
|
+
attempted: false
|
26
|
+
closed: false
|
27
|
+
currency: MyString
|
28
|
+
date: 2013-11-01 06:03:59
|
29
|
+
paid: false
|
30
|
+
period_start: 2013-11-01 06:03:59
|
31
|
+
period_end: 2013-11-01 06:03:59
|
32
|
+
starting_balance: 1
|
33
|
+
subtotal: 1
|
34
|
+
total: 1
|
35
|
+
charge_id: MyString
|
36
|
+
ending_balance: 1
|
37
|
+
next_payment_attempt: 2013-11-01 06:03:59
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: MyString
|
5
|
+
amount: 1
|
6
|
+
currency: MyString
|
7
|
+
date: 2013-11-01 08:45:17
|
8
|
+
proration: false
|
9
|
+
description: MyString
|
10
|
+
metadata: MyText
|
11
|
+
|
12
|
+
two:
|
13
|
+
id: MyString
|
14
|
+
amount: 1
|
15
|
+
currency: MyString
|
16
|
+
date: 2013-11-01 08:45:17
|
17
|
+
proration: false
|
18
|
+
description: MyString
|
19
|
+
metadata: MyText
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
id: MyString
|
5
|
+
name: MyString
|
6
|
+
amount: 1
|
7
|
+
interval: MyString
|
8
|
+
interval_count: 1
|
9
|
+
trial_period_days: 1
|
10
|
+
|
11
|
+
two:
|
12
|
+
id: MyString
|
13
|
+
name: MyString
|
14
|
+
amount: 1
|
15
|
+
interval: MyString
|
16
|
+
interval_count: 1
|
17
|
+
trial_period_days: 1
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
customer_id: MyString
|
5
|
+
status: MyString
|
6
|
+
quantity: 1
|
7
|
+
start: 2013-11-01 04:25:26
|
8
|
+
canceled_at: 2013-11-01 04:25:26
|
9
|
+
ended_at: 2013-11-01 04:25:26
|
10
|
+
current_period_start: 2013-11-01 04:25:26
|
11
|
+
current_period_end: 2013-11-01 04:25:26
|
12
|
+
trial_start: 2013-11-01 04:25:26
|
13
|
+
trial_end: 2013-11-01 04:25:26
|
14
|
+
|
15
|
+
two:
|
16
|
+
customer_id: MyString
|
17
|
+
status: MyString
|
18
|
+
quantity: 1
|
19
|
+
start: 2013-11-01 04:25:26
|
20
|
+
canceled_at: 2013-11-01 04:25:26
|
21
|
+
ended_at: 2013-11-01 04:25:26
|
22
|
+
current_period_start: 2013-11-01 04:25:26
|
23
|
+
current_period_end: 2013-11-01 04:25:26
|
24
|
+
trial_start: 2013-11-01 04:25:26
|
25
|
+
trial_end: 2013-11-01 04:25:26
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
amount: 1
|
5
|
+
date: 2013-11-14 22:17:57
|
6
|
+
status: MyString
|
7
|
+
balance_transaction: MyString
|
8
|
+
description: MyString
|
9
|
+
metadata: MyText
|
10
|
+
|
11
|
+
two:
|
12
|
+
amount: 1
|
13
|
+
date: 2013-11-14 22:17:57
|
14
|
+
status: MyString
|
15
|
+
balance_transaction: MyString
|
16
|
+
description: MyString
|
17
|
+
metadata: MyText
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StripeLocal::Balance do
|
4
|
+
|
5
|
+
before do
|
6
|
+
StripeLocal::Balance.create pending: 29900, available: 9900
|
7
|
+
StripeLocal::Balance.create pending: 19900, available: 19900
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { StripeLocal::Balance }
|
11
|
+
|
12
|
+
its( :current ) { should be 19900 }
|
13
|
+
|
14
|
+
its( :previous ) { should be 9900 }
|
15
|
+
|
16
|
+
its( :changed ) { should be 10000 }
|
17
|
+
|
18
|
+
its( :pending ) { should be 19900 }
|
19
|
+
|
20
|
+
its( :previous_pending ) { should be 29900 }
|
21
|
+
|
22
|
+
# describe "redundant `StripeLocal::balance.available` webhook is received" do
|
23
|
+
# before do
|
24
|
+
# @count = StripeLocal::Balance.count
|
25
|
+
# @updated = StripeLocal::Balance.last.updated_at.to_i
|
26
|
+
# end
|
27
|
+
# before { Timecop.travel 1.day.from_now }
|
28
|
+
# after { Timecop.return }
|
29
|
+
#
|
30
|
+
# it "keeps StripeLocal::Balance updated, but doesn't create redundant records" do
|
31
|
+
# StripeLocal::Balance.event({ pending: 19900, available: 19900 })
|
32
|
+
#
|
33
|
+
# StripeLocal::Balance.count.should eq @count
|
34
|
+
# StripeLocal::Balance.last.updated_at.to_i.should > @updated
|
35
|
+
# end
|
36
|
+
# end
|
37
|
+
|
38
|
+
describe "`balance.available` webhook signifies a changed balance" do
|
39
|
+
before { @count = StripeLocal::Balance.count }
|
40
|
+
|
41
|
+
it "creates a new record" do
|
42
|
+
StripeLocal::Balance.event({ pending: 0, available: 39800 })
|
43
|
+
|
44
|
+
StripeLocal::Balance.count.should eq @count + 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StripeLocal::Card do
|
4
|
+
let(:response) { File.read("./spec/webhook_fixtures/customer.created.json") }
|
5
|
+
let(:stripe_customer) { Stripe::Customer.construct_from(MultiJson.load(response)) }
|
6
|
+
|
7
|
+
it 'can normalize Stripe Params on creation' do
|
8
|
+
card = StripeLocal::Card.create( stripe_customer.cards.data.first.to_hash )
|
9
|
+
card.brand.should == 'Visa'
|
10
|
+
card.name.should == 'Connor Tumbleson'
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StripeLocal::Charge do
|
4
|
+
let(:response) { File.read("./spec/webhook_fixtures/charge.succeeded.json") }
|
5
|
+
let(:stripe_charge) { Stripe::StripeObject.construct_from(MultiJson.load(response)) }
|
6
|
+
|
7
|
+
it "can normalize a json webhook on create" do
|
8
|
+
c = StripeLocal::Charge.create( stripe_charge.to_hash )
|
9
|
+
c.card_id.should eq "cc_1eX7GyRo6wivEf"
|
10
|
+
c.amount.should eq 9900
|
11
|
+
c.captured.should be_true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe StripeLocal::Customer do
|
5
|
+
let(:response) { File.read("./spec/webhook_fixtures/customer_creation_response.json") }
|
6
|
+
let(:stripe_customer) { Stripe::StripeObject.construct_from(MultiJson.load(response)) }
|
7
|
+
let(:client) { ::Client.create( name: "Test Case", email: "test@test.com", password: "password" ) }
|
8
|
+
|
9
|
+
it "can normalize a customer on create" do
|
10
|
+
Stripe::Customer.should_receive( :create ).and_return stripe_customer
|
11
|
+
stripe_customer.should_receive :update_subscription
|
12
|
+
StripeLocal::Customer.should_receive( :create ).with( stripe_customer ).and_call_original
|
13
|
+
StripeLocal::Customer.should_receive( :normalize ).with( stripe_customer ).and_call_original
|
14
|
+
client.signup( card: "token", plan: "plan" )
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StripeLocal::Invoice do
|
4
|
+
let(:response) { File.read("./spec/webhook_fixtures/invoice.payment_succeeded.json") }
|
5
|
+
let(:stripe_invoice) { Stripe::Invoice.construct_from(MultiJson.load(response)) }
|
6
|
+
|
7
|
+
it "can normalize Stripe Params on create" do
|
8
|
+
i = StripeLocal::Invoice.create( stripe_invoice )
|
9
|
+
i.customer_id.should eq "cus_1A3zUmx7NpUgrT"
|
10
|
+
i.amount_due.should eq 9900
|
11
|
+
i.total.should eq 9900
|
12
|
+
i.subtotal.should eq 9900
|
13
|
+
i.lines(true).size.should be 1
|
14
|
+
i.lines.first.amount.should eq 9900
|
15
|
+
i.lines.first.period_start.should eq "2013-05-07 18:23:47 -0500"
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe StripeLocal::Plan do
|
4
|
+
let(:response) { File.read("./spec/webhook_fixtures/plan.created.json") }
|
5
|
+
let(:stripe_plan) { Stripe::Invoice.construct_from(MultiJson.load(response)) }
|
6
|
+
|
7
|
+
# it "normalizes a plan created in the stripe dashboard and saves it locally" do
|
8
|
+
# Stripe::Plan.should_not_receive :create
|
9
|
+
#
|
10
|
+
# plan = StripeLocal::Plan.create( stripe_plan )
|
11
|
+
# plan.id.should eq "HR99"
|
12
|
+
# plan.amount.should eq 9900
|
13
|
+
# plan.synced?.should be_true
|
14
|
+
# end
|
15
|
+
|
16
|
+
it "will remotely sync creation of a new plan" do
|
17
|
+
Stripe::Plan.should_receive :create
|
18
|
+
|
19
|
+
plan = StripeLocal::Plan.create( id: "New_Plan", amount: 2999, interval: "month", name: "New Plan" )
|
20
|
+
plan.id.should eq "New_Plan"
|
21
|
+
plan.amount.should eq 2999
|
22
|
+
end
|
23
|
+
|
24
|
+
# context "existing plan" do
|
25
|
+
# before { Plan.create id: 'HR99', amount: 9900, synced: false }
|
26
|
+
# it "will mark an existing plan as 'synced' upon an incoming 'plan.created' hook" do
|
27
|
+
# Plan.should_not_receive :sync_create
|
28
|
+
#
|
29
|
+
# plan = Plan.create( stripe_plan )
|
30
|
+
# plan.synced.should be_true
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
end
|