disco_app 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/disco_app/admin/concerns/plans_controller.rb +51 -0
- data/app/controllers/disco_app/admin/plans_controller.rb +3 -0
- data/app/controllers/disco_app/charges_controller.rb +37 -20
- data/app/controllers/disco_app/concerns/app_proxy_controller.rb +1 -1
- data/app/controllers/disco_app/concerns/authenticated_controller.rb +26 -12
- data/app/controllers/disco_app/concerns/carrier_request_controller.rb +1 -1
- data/app/controllers/disco_app/install_controller.rb +20 -19
- data/app/controllers/disco_app/subscriptions_controller.rb +40 -0
- data/app/controllers/disco_app/webhooks_controller.rb +1 -1
- data/app/controllers/sessions_controller.rb +22 -0
- data/app/jobs/disco_app/concerns/app_installed_job.rb +21 -4
- data/app/jobs/disco_app/concerns/app_uninstalled_job.rb +2 -5
- data/app/jobs/disco_app/concerns/subscription_changed_job.rb +7 -0
- data/app/jobs/disco_app/subscription_changed_job.rb +3 -0
- data/app/models/disco_app/application_charge.rb +18 -0
- data/app/models/disco_app/concerns/plan.rb +13 -1
- data/app/models/disco_app/concerns/plan_code.rb +15 -0
- data/app/models/disco_app/concerns/shop.rb +10 -9
- data/app/models/disco_app/concerns/subscription.rb +36 -2
- data/app/models/disco_app/plan_code.rb +3 -0
- data/app/models/disco_app/recurring_application_charge.rb +18 -0
- data/app/services/disco_app/charges_service.rb +66 -58
- data/app/services/disco_app/subscription_service.rb +27 -15
- data/app/views/disco_app/admin/plans/_form.html.erb +27 -0
- data/app/views/disco_app/admin/plans/edit.html.erb +7 -0
- data/app/views/disco_app/admin/plans/index.html.erb +32 -0
- data/app/views/disco_app/admin/plans/new.html.erb +7 -0
- data/app/views/disco_app/charges/new.html.erb +9 -42
- data/app/views/disco_app/subscriptions/new.html.erb +25 -0
- data/app/views/layouts/admin/_navbar.html.erb +1 -0
- data/config/routes.rb +8 -5
- data/db/migrate/20160301223215_update_plans.rb +22 -0
- data/db/migrate/20160301224558_update_subscriptions.rb +13 -0
- data/db/migrate/20160302104816_create_disco_app_recurring_application_charges.rb +14 -0
- data/db/migrate/20160302105259_create_disco_app_application_charges.rb +14 -0
- data/db/migrate/20160302134728_drop_charge_status_from_shops.rb +5 -0
- data/db/migrate/20160302142941_add_shopify_attributes_to_charges.rb +8 -0
- data/db/migrate/20160331093148_create_disco_app_plan_codes.rb +14 -0
- data/db/migrate/20160401044420_add_status_to_plan_codes.rb +5 -0
- data/db/migrate/20160401045551_add_amount_and_plan_code_to_disco_app_subscriptions.rb +7 -0
- data/lib/disco_app/configuration.rb +6 -0
- data/lib/disco_app/version.rb +1 -1
- data/lib/generators/disco_app/reactify/reactify_generator.rb +1 -1
- data/lib/generators/disco_app/templates/initializers/disco_app.rb +9 -4
- data/test/controllers/disco_app/charges_controller_test.rb +91 -0
- data/test/controllers/disco_app/subscriptions_controller_test.rb +73 -0
- data/test/controllers/home_controller_test.rb +37 -6
- data/test/dummy/app/jobs/disco_app/app_installed_job.rb +16 -0
- data/test/dummy/config/initializers/disco_app.rb +9 -4
- data/test/dummy/db/schema.rb +54 -14
- data/test/fixtures/api/widget_store/charges/activate_application_charge_request.json +16 -0
- data/test/fixtures/api/widget_store/charges/activate_application_charge_response.json +1 -0
- data/test/fixtures/api/widget_store/charges/activate_recurring_application_charge_request.json +20 -0
- data/test/fixtures/api/widget_store/charges/activate_recurring_application_charge_response.json +1 -0
- data/test/fixtures/api/widget_store/charges/create_application_charge_request.json +9 -0
- data/test/fixtures/api/widget_store/charges/create_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/create_recurring_application_charge_request.json +9 -0
- data/test/fixtures/api/widget_store/charges/create_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/create_second_recurring_application_charge_request.json +9 -0
- data/test/fixtures/api/widget_store/charges/create_second_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/get_accepted_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/get_accepted_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/get_declined_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/get_declined_recurring_application_charge_response.json +20 -0
- data/test/fixtures/api/widget_store/charges/get_pending_application_charge_response.json +16 -0
- data/test/fixtures/api/widget_store/charges/get_pending_recurring_application_charge_response.json +20 -0
- data/test/fixtures/disco_app/application_charges.yml +11 -0
- data/test/fixtures/disco_app/plan_codes.yml +6 -0
- data/test/fixtures/disco_app/plans.yml +23 -18
- data/test/fixtures/disco_app/recurring_application_charges.yml +11 -0
- data/test/fixtures/disco_app/subscriptions.yml +12 -17
- data/test/jobs/disco_app/app_installed_job_test.rb +17 -5
- data/test/jobs/disco_app/app_uninstalled_job_test.rb +0 -2
- data/test/models/disco_app/shop_test.rb +3 -2
- data/test/services/disco_app/charges_service_test.rb +104 -0
- data/test/services/disco_app/subscription_service_test.rb +39 -8
- data/test/support/test_file_fixtures.rb +1 -1
- data/test/support/test_shopify_api.rb +16 -0
- data/test/test_helper.rb +1 -0
- metadata +73 -3
- data/test/models/disco_app/subscription_test.rb +0 -6
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DiscoApp::ChargesControllerTest < ActionController::TestCase
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
include DiscoApp::Test::ShopifyAPI
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@shop = disco_app_shops(:widget_store)
|
9
|
+
@current_subscription = disco_app_subscriptions(:current_widget_store_subscription)
|
10
|
+
@new_charge = disco_app_recurring_application_charges(:new_widget_store_subscription_recurring_charge)
|
11
|
+
@routes = DiscoApp::Engine.routes
|
12
|
+
log_in_as(@shop)
|
13
|
+
@shop.installed!
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
@shop = nil
|
18
|
+
@current_subscription = nil
|
19
|
+
WebMock.reset!
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'non-logged in user is redirected to the login page' do
|
23
|
+
log_out
|
24
|
+
get(:new, subscription_id: @current_subscription)
|
25
|
+
assert_redirected_to ShopifyApp::Engine.routes.url_helpers.login_path
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'logged-in, never installed user is redirected to the install page' do
|
29
|
+
@shop.never_installed!
|
30
|
+
get(:new, subscription_id: @current_subscription)
|
31
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.install_path
|
32
|
+
end
|
33
|
+
|
34
|
+
test 'user with paid-for current subscription can not access page' do
|
35
|
+
get(:new, subscription_id: @current_subscription)
|
36
|
+
assert_redirected_to Rails.application.routes.url_helpers.root_path
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'user with unpaid current subscription can access page' do
|
40
|
+
@current_subscription.active_charge.destroy
|
41
|
+
get(:new, subscription_id: @current_subscription)
|
42
|
+
assert_response :ok
|
43
|
+
end
|
44
|
+
|
45
|
+
test 'user with unpaid current subscription can create new charge and is redirected to confirmation url' do
|
46
|
+
stub_api_request(:post, "#{@shop.admin_url}/recurring_application_charges.json", 'widget_store/charges/create_second_recurring_application_charge')
|
47
|
+
|
48
|
+
@current_subscription.active_charge.destroy
|
49
|
+
post(:create, subscription_id: @current_subscription)
|
50
|
+
assert_redirected_to 'https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa'
|
51
|
+
end
|
52
|
+
|
53
|
+
test 'user trying to activate charge for invalid gets not found and hence 404' do
|
54
|
+
assert_raises ActiveRecord::RecordNotFound do
|
55
|
+
get(:activate, subscription_id: '123', id: '456', charge_id: '789')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
test 'user trying to activate invalid charge for valid subscription gets redirected to new charge page for that subscription' do
|
60
|
+
@current_subscription.active_charge.destroy
|
61
|
+
get(:activate, subscription_id: @current_subscription, id: '456', charge_id: '789')
|
62
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_charge_path(@current_subscription)
|
63
|
+
end
|
64
|
+
|
65
|
+
test 'user trying to activate pending charge is redirected back to new charge page' do
|
66
|
+
stub_api_request(:get, "#{@shop.admin_url}/recurring_application_charges/654381179.json", 'widget_store/charges/get_pending_recurring_application_charge')
|
67
|
+
|
68
|
+
@current_subscription.active_charge.destroy
|
69
|
+
get(:activate, subscription_id: @current_subscription, id: @new_charge.id, charge_id: @new_charge.shopify_id)
|
70
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_charge_path(@current_subscription)
|
71
|
+
end
|
72
|
+
|
73
|
+
test 'user trying to activate declined charge is redirected back to new charge page' do
|
74
|
+
stub_api_request(:get, "#{@shop.admin_url}/recurring_application_charges/654381179.json", 'widget_store/charges/get_declined_recurring_application_charge')
|
75
|
+
|
76
|
+
@current_subscription.active_charge.destroy
|
77
|
+
get(:activate, subscription_id: @current_subscription, id: @new_charge.id, charge_id: @new_charge.shopify_id)
|
78
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_charge_path(@current_subscription)
|
79
|
+
end
|
80
|
+
|
81
|
+
test 'user trying to activate accepted charge succeeds and is redirected to the root page' do
|
82
|
+
stub_api_request(:get, "#{@shop.admin_url}/recurring_application_charges/654381179.json", 'widget_store/charges/get_accepted_recurring_application_charge')
|
83
|
+
stub_api_request(:post, "#{@shop.admin_url}/recurring_application_charges/654381179/activate.json", 'widget_store/charges/activate_recurring_application_charge')
|
84
|
+
|
85
|
+
@current_subscription.active_charge.destroy
|
86
|
+
get(:activate, subscription_id: @current_subscription, id: @new_charge.id, charge_id: @new_charge.shopify_id)
|
87
|
+
assert_equal @new_charge, @current_subscription.active_charge
|
88
|
+
assert_redirected_to Rails.application.routes.url_helpers.root_path
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class DiscoApp::SubscriptionsControllerTest < ActionController::TestCase
|
4
|
+
include ActiveJob::TestHelper
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@shop = disco_app_shops(:widget_store)
|
8
|
+
@current_subscription = disco_app_subscriptions(:current_widget_store_subscription)
|
9
|
+
@routes = DiscoApp::Engine.routes
|
10
|
+
log_in_as(@shop)
|
11
|
+
@shop.installed!
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
@shop = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
test 'non-logged in user is redirected to the login page' do
|
19
|
+
log_out
|
20
|
+
get(:new)
|
21
|
+
assert_redirected_to ShopifyApp::Engine.routes.url_helpers.login_path
|
22
|
+
end
|
23
|
+
|
24
|
+
test 'logged-in, never installed user is redirected to the install page' do
|
25
|
+
@shop.never_installed!
|
26
|
+
get(:new)
|
27
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.install_path
|
28
|
+
end
|
29
|
+
|
30
|
+
test 'logged-in, installed user with no current subscription can access page' do
|
31
|
+
@current_subscription.destroy
|
32
|
+
get(:new)
|
33
|
+
assert_response :ok
|
34
|
+
end
|
35
|
+
|
36
|
+
test 'logged-in, installed user with current subscription can access page' do
|
37
|
+
get(:new)
|
38
|
+
assert_response :ok
|
39
|
+
end
|
40
|
+
|
41
|
+
test 'logged-in, installed user with current subscription can create new subscription' do
|
42
|
+
post(:create, subscription: { plan: disco_app_plans(:premium) })
|
43
|
+
assert_redirected_to Rails.application.routes.url_helpers.root_path
|
44
|
+
assert_equal disco_app_plans(:premium), @shop.current_plan
|
45
|
+
end
|
46
|
+
|
47
|
+
test 'logged-in, installed user with no subscription can create new subscription for available plan' do
|
48
|
+
@current_subscription.destroy
|
49
|
+
post(:create, subscription: { plan: disco_app_plans(:premium) })
|
50
|
+
assert_redirected_to Rails.application.routes.url_helpers.root_path
|
51
|
+
assert_equal disco_app_plans(:premium), @shop.current_plan
|
52
|
+
end
|
53
|
+
|
54
|
+
test 'logged-in, installed user with current subscription can not create new subscription for unavailable plan' do
|
55
|
+
post(:create, subscription: { plan: disco_app_plans(:cheapo) })
|
56
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_path
|
57
|
+
assert_equal @current_subscription, @shop.current_subscription
|
58
|
+
end
|
59
|
+
|
60
|
+
test 'logged-in, installed user with current subscription can not create new subscription with invalid plan code' do
|
61
|
+
post(:create, subscription: { plan: disco_app_plans(:premium), plan_code: 'BANANA' })
|
62
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_path
|
63
|
+
assert_equal @current_subscription, @shop.current_subscription
|
64
|
+
end
|
65
|
+
|
66
|
+
test 'logged-in, installed user with current subscription can create new subscription with valid plan code' do
|
67
|
+
post(:create, subscription: { plan: disco_app_plans(:premium), plan_code: 'PODCAST' })
|
68
|
+
assert_redirected_to Rails.application.routes.url_helpers.root_path
|
69
|
+
assert_equal disco_app_plans(:premium), @shop.current_plan
|
70
|
+
assert_equal 8999, @shop.current_subscription.amount
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -4,11 +4,14 @@ class HomeControllerTest < ActionController::TestCase
|
|
4
4
|
|
5
5
|
def setup
|
6
6
|
@shop = disco_app_shops(:widget_store)
|
7
|
+
@current_subscription = disco_app_subscriptions(:current_widget_store_subscription)
|
8
|
+
@current_recurring_charge = disco_app_recurring_application_charges(:current_widget_store_subscription_recurring_charge)
|
7
9
|
log_in_as(@shop)
|
8
10
|
end
|
9
11
|
|
10
12
|
def teardown
|
11
13
|
@shop = nil
|
14
|
+
@current_subscription = nil
|
12
15
|
end
|
13
16
|
|
14
17
|
test 'non-logged in user is redirected to the login page' do
|
@@ -34,12 +37,6 @@ class HomeControllerTest < ActionController::TestCase
|
|
34
37
|
assert_redirected_to DiscoApp::Engine.routes.url_helpers.installing_path
|
35
38
|
end
|
36
39
|
|
37
|
-
test 'logged-in, installed user is able to access the page' do
|
38
|
-
@shop.installed!
|
39
|
-
get(:index)
|
40
|
-
assert_response :success
|
41
|
-
end
|
42
|
-
|
43
40
|
test 'logged-in, awaiting uninstall user is redirected to the uninstalling page' do
|
44
41
|
@shop.awaiting_uninstall!
|
45
42
|
get(:index)
|
@@ -58,4 +55,38 @@ class HomeControllerTest < ActionController::TestCase
|
|
58
55
|
assert_redirected_to DiscoApp::Engine.routes.url_helpers.install_path
|
59
56
|
end
|
60
57
|
|
58
|
+
test 'logged-in, installed user with no current subscription is redirected to new subscription page' do
|
59
|
+
@shop.installed!
|
60
|
+
@current_subscription.destroy
|
61
|
+
get(:index)
|
62
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_path
|
63
|
+
end
|
64
|
+
|
65
|
+
test 'logged-in, installed user with no cancelled subscription is redirected to new subscription page' do
|
66
|
+
@shop.installed!
|
67
|
+
@current_subscription.cancelled!
|
68
|
+
get(:index)
|
69
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_path
|
70
|
+
end
|
71
|
+
|
72
|
+
test 'logged-in, installed user with current but unpaid subscription is redirected to new charges page' do
|
73
|
+
@shop.installed!
|
74
|
+
@current_recurring_charge.destroy
|
75
|
+
get(:index)
|
76
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_charge_path(@current_subscription)
|
77
|
+
end
|
78
|
+
|
79
|
+
test 'logged-in, installed user with current subscription with declined charge is redirected to new charges page' do
|
80
|
+
@shop.installed!
|
81
|
+
@current_recurring_charge.declined!
|
82
|
+
get(:index)
|
83
|
+
assert_redirected_to DiscoApp::Engine.routes.url_helpers.new_subscription_charge_path(@current_subscription)
|
84
|
+
end
|
85
|
+
|
86
|
+
test 'logged-in, installed user with a current and paid subscription is able to access the page' do
|
87
|
+
@shop.installed!
|
88
|
+
get(:index)
|
89
|
+
assert_response :success
|
90
|
+
end
|
91
|
+
|
61
92
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class DiscoApp::AppInstalledJob < DiscoApp::ShopJob
|
2
|
+
include DiscoApp::Concerns::AppInstalledJob
|
3
|
+
|
4
|
+
DEVELOPMENT_PLAN_ID = 1
|
5
|
+
|
6
|
+
# Implement the default_plan method to define an initial plan for shops based
|
7
|
+
# on their status.
|
8
|
+
def default_plan
|
9
|
+
@default_plan ||= begin
|
10
|
+
if @shop.plan_name === 'affiliate'
|
11
|
+
DiscoApp::Plan.find(DEVELOPMENT_PLAN_ID)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -7,8 +7,13 @@ DiscoApp.configure do |config|
|
|
7
7
|
# Set the below if using an application proxy.
|
8
8
|
config.app_proxy_prefix = ENV['SHOPIFY_APP_PROXY_PREFIX']
|
9
9
|
|
10
|
-
#
|
11
|
-
config.
|
12
|
-
|
13
|
-
|
10
|
+
# Set the below to create real charges.
|
11
|
+
config.real_charges = ENV['SHOPIFY_REAL_CHARGES'] === 'true'
|
12
|
+
|
13
|
+
# Optional configuration. These flags are only respected in the development
|
14
|
+
# environment and will have no effect in production.
|
15
|
+
config.skip_proxy_verification = ENV['SKIP_PROXY_VERIFICATION'] == 'true'
|
16
|
+
config.skip_webhook_verification = ENV['SKIP_WEBHOOK_VERIFICATION'] == 'true'
|
17
|
+
config.skip_carrier_request_verification = ENV['SKIP_CARRIER_REQUEST_VERIFICATION'] == 'true'
|
18
|
+
config.skip_oauth = ENV['SKIP_OAUTH'] == 'true'
|
14
19
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20160401045551) do
|
15
15
|
|
16
16
|
# These are extensions that must be enabled in order to support this database
|
17
17
|
enable_extension "plpgsql"
|
@@ -21,14 +21,47 @@ ActiveRecord::Schema.define(version: 20160307182229) do
|
|
21
21
|
t.datetime "updated_at", null: false
|
22
22
|
end
|
23
23
|
|
24
|
+
create_table "disco_app_application_charges", force: :cascade do |t|
|
25
|
+
t.integer "shop_id", limit: 8
|
26
|
+
t.integer "subscription_id", limit: 8
|
27
|
+
t.integer "status", default: 0
|
28
|
+
t.datetime "created_at", null: false
|
29
|
+
t.datetime "updated_at", null: false
|
30
|
+
t.integer "shopify_id", limit: 8
|
31
|
+
t.string "confirmation_url"
|
32
|
+
end
|
33
|
+
|
34
|
+
create_table "disco_app_plan_codes", force: :cascade do |t|
|
35
|
+
t.integer "plan_id", limit: 8
|
36
|
+
t.string "code"
|
37
|
+
t.integer "trial_period_days"
|
38
|
+
t.integer "amount"
|
39
|
+
t.datetime "created_at", null: false
|
40
|
+
t.datetime "updated_at", null: false
|
41
|
+
t.integer "status", default: 0
|
42
|
+
end
|
43
|
+
|
24
44
|
create_table "disco_app_plans", force: :cascade do |t|
|
25
|
-
t.integer "status"
|
45
|
+
t.integer "status", default: 0
|
26
46
|
t.string "name"
|
27
|
-
t.integer "
|
28
|
-
t.
|
29
|
-
t.
|
30
|
-
t.datetime "
|
31
|
-
t.
|
47
|
+
t.integer "plan_type", default: 0
|
48
|
+
t.integer "trial_period_days"
|
49
|
+
t.datetime "created_at", null: false
|
50
|
+
t.datetime "updated_at", null: false
|
51
|
+
t.integer "amount", default: 0
|
52
|
+
t.string "currency", default: "USD"
|
53
|
+
t.integer "interval", default: 0
|
54
|
+
t.integer "interval_count", default: 1
|
55
|
+
end
|
56
|
+
|
57
|
+
create_table "disco_app_recurring_application_charges", force: :cascade do |t|
|
58
|
+
t.integer "shop_id", limit: 8
|
59
|
+
t.integer "subscription_id", limit: 8
|
60
|
+
t.integer "status", default: 0
|
61
|
+
t.datetime "created_at", null: false
|
62
|
+
t.datetime "updated_at", null: false
|
63
|
+
t.integer "shopify_id", limit: 8
|
64
|
+
t.string "confirmation_url"
|
32
65
|
end
|
33
66
|
|
34
67
|
create_table "disco_app_sessions", force: :cascade do |t|
|
@@ -55,7 +88,6 @@ ActiveRecord::Schema.define(version: 20160307182229) do
|
|
55
88
|
t.string "money_with_currency_format"
|
56
89
|
t.string "domain"
|
57
90
|
t.string "plan_name"
|
58
|
-
t.integer "charge_status", default: 6
|
59
91
|
t.string "plan_display_name"
|
60
92
|
t.decimal "latitude"
|
61
93
|
t.decimal "longitude"
|
@@ -75,12 +107,14 @@ ActiveRecord::Schema.define(version: 20160307182229) do
|
|
75
107
|
t.integer "shop_id"
|
76
108
|
t.integer "plan_id"
|
77
109
|
t.integer "status"
|
78
|
-
t.
|
79
|
-
t.
|
80
|
-
t.
|
81
|
-
t.
|
82
|
-
t.datetime "
|
83
|
-
t.datetime "
|
110
|
+
t.integer "subscription_type"
|
111
|
+
t.datetime "created_at", null: false
|
112
|
+
t.datetime "updated_at", null: false
|
113
|
+
t.datetime "trial_start_at"
|
114
|
+
t.datetime "trial_end_at"
|
115
|
+
t.datetime "cancelled_at"
|
116
|
+
t.integer "amount", default: 0
|
117
|
+
t.integer "plan_code_id", limit: 8
|
84
118
|
end
|
85
119
|
|
86
120
|
add_index "disco_app_subscriptions", ["plan_id"], name: "index_disco_app_subscriptions_on_plan_id", using: :btree
|
@@ -93,6 +127,12 @@ ActiveRecord::Schema.define(version: 20160307182229) do
|
|
93
127
|
t.datetime "updated_at", null: false
|
94
128
|
end
|
95
129
|
|
130
|
+
add_foreign_key "disco_app_application_charges", "disco_app_shops", column: "shop_id"
|
131
|
+
add_foreign_key "disco_app_application_charges", "disco_app_subscriptions", column: "subscription_id"
|
132
|
+
add_foreign_key "disco_app_plan_codes", "disco_app_plans", column: "plan_id"
|
133
|
+
add_foreign_key "disco_app_recurring_application_charges", "disco_app_shops", column: "shop_id"
|
134
|
+
add_foreign_key "disco_app_recurring_application_charges", "disco_app_subscriptions", column: "subscription_id"
|
96
135
|
add_foreign_key "disco_app_sessions", "disco_app_shops", column: "shop_id", on_delete: :cascade
|
136
|
+
add_foreign_key "disco_app_subscriptions", "disco_app_plan_codes", column: "plan_code_id"
|
97
137
|
add_foreign_key "products", "disco_app_shops", column: "shop_id"
|
98
138
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"application_charge": {
|
3
|
+
"id": 1012637323,
|
4
|
+
"name": "Lifetime",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "49.00",
|
7
|
+
"status": "accepted",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"created_at": "2015-09-02T14:52:56-04:00",
|
10
|
+
"updated_at": "2015-09-02T14:52:56-04:00",
|
11
|
+
"test": true,
|
12
|
+
"charge_type": null,
|
13
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/1/activate?charge_id=1012637323",
|
14
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/1012637323/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
data/test/fixtures/api/widget_store/charges/activate_recurring_application_charge_request.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"recurring_application_charge": {
|
3
|
+
"id": 654381179,
|
4
|
+
"name": "Basic",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "9.99",
|
7
|
+
"status": "accepted",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"billing_on": null,
|
10
|
+
"created_at": "2015-09-02T14:50:32-04:00",
|
11
|
+
"updated_at": "2015-09-02T14:50:32-04:00",
|
12
|
+
"test": true,
|
13
|
+
"activated_on": null,
|
14
|
+
"trial_ends_on": null,
|
15
|
+
"cancelled_on": null,
|
16
|
+
"trial_days": 14,
|
17
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate?charge_id=654381179",
|
18
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
19
|
+
}
|
20
|
+
}
|
data/test/fixtures/api/widget_store/charges/activate_recurring_application_charge_response.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"application_charge": {
|
3
|
+
"id": 1012637323,
|
4
|
+
"name": "Lifetime",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "49.00",
|
7
|
+
"status": "pending",
|
8
|
+
"return_url": "https:\/\/test.example.com/subscriptions\/741857542\/charges\/1\/activate",
|
9
|
+
"created_at": "2015-09-02T14:55:01-04:00",
|
10
|
+
"updated_at": "2015-09-02T14:55:01-04:00",
|
11
|
+
"test": true,
|
12
|
+
"charge_type": null,
|
13
|
+
"decorated_return_url": "https:\/\/test.example.com\/subscriptions\/741857542\/charges\/1\/activate?charge_id=1012637323",
|
14
|
+
"confirmation_url": "https:\/\/apple.myshopify.com\/admin\/charges\/1012637323\/confirm_application_charge?signature=BAhpBIueWzw%3D--0ea1abacaf9d6fd538b7e9a7023e9b71ce1c7e98"
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"recurring_application_charge": {
|
3
|
+
"id": 654381179,
|
4
|
+
"name": "Basic",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "9.99",
|
7
|
+
"status": "pending",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"billing_on": null,
|
10
|
+
"created_at": "2015-09-02T14:51:23-04:00",
|
11
|
+
"updated_at": "2015-09-02T14:51:23-04:00",
|
12
|
+
"test": true,
|
13
|
+
"activated_on": null,
|
14
|
+
"trial_ends_on": "",
|
15
|
+
"cancelled_on": null,
|
16
|
+
"trial_days": 14,
|
17
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate?charge_id=654381179",
|
18
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
19
|
+
}
|
20
|
+
}
|
data/test/fixtures/api/widget_store/charges/create_second_recurring_application_charge_response.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"recurring_application_charge": {
|
3
|
+
"id": 654381179,
|
4
|
+
"name": "Basic",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "9.99",
|
7
|
+
"status": "pending",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/532970502/activate",
|
9
|
+
"billing_on": null,
|
10
|
+
"created_at": "2015-09-02T14:51:23-04:00",
|
11
|
+
"updated_at": "2015-09-02T14:51:23-04:00",
|
12
|
+
"test": true,
|
13
|
+
"activated_on": null,
|
14
|
+
"trial_ends_on": "",
|
15
|
+
"cancelled_on": null,
|
16
|
+
"trial_days": 14,
|
17
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/532970502/activate?charge_id=654381179",
|
18
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"application_charge": {
|
3
|
+
"id": 1012637323,
|
4
|
+
"name": "Lifetime",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "49.00",
|
7
|
+
"status": "accepted",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"created_at": "2015-09-02T14:52:56-04:00",
|
10
|
+
"updated_at": "2015-09-02T14:52:56-04:00",
|
11
|
+
"test": true,
|
12
|
+
"charge_type": null,
|
13
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/1/activate?charge_id=1012637323",
|
14
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/1012637323/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
15
|
+
}
|
16
|
+
}
|
data/test/fixtures/api/widget_store/charges/get_accepted_recurring_application_charge_response.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"recurring_application_charge": {
|
3
|
+
"id": 654381179,
|
4
|
+
"name": "Basic",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "9.99",
|
7
|
+
"status": "accepted",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"billing_on": null,
|
10
|
+
"created_at": "2015-09-02T14:50:32-04:00",
|
11
|
+
"updated_at": "2015-09-02T14:50:32-04:00",
|
12
|
+
"test": true,
|
13
|
+
"activated_on": null,
|
14
|
+
"trial_ends_on": null,
|
15
|
+
"cancelled_on": null,
|
16
|
+
"trial_days": 14,
|
17
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate?charge_id=654381179",
|
18
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"application_charge": {
|
3
|
+
"id": 1012637323,
|
4
|
+
"name": "Lifetime",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "49.00",
|
7
|
+
"status": "declined",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"created_at": "2015-09-02T14:52:56-04:00",
|
10
|
+
"updated_at": "2015-09-02T14:52:56-04:00",
|
11
|
+
"test": true,
|
12
|
+
"charge_type": null,
|
13
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/1/activate?charge_id=1012637323",
|
14
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/1012637323/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
15
|
+
}
|
16
|
+
}
|
data/test/fixtures/api/widget_store/charges/get_declined_recurring_application_charge_response.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"recurring_application_charge": {
|
3
|
+
"id": 654381179,
|
4
|
+
"name": "Basic",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "9.99",
|
7
|
+
"status": "declined",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"billing_on": null,
|
10
|
+
"created_at": "2015-09-02T14:50:32-04:00",
|
11
|
+
"updated_at": "2015-09-02T14:50:32-04:00",
|
12
|
+
"test": true,
|
13
|
+
"activated_on": null,
|
14
|
+
"trial_ends_on": null,
|
15
|
+
"cancelled_on": null,
|
16
|
+
"trial_days": 14,
|
17
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate?charge_id=654381179",
|
18
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"application_charge": {
|
3
|
+
"id": 1012637323,
|
4
|
+
"name": "Lifetime",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "49.00",
|
7
|
+
"status": "pending",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"created_at": "2015-09-02T14:52:56-04:00",
|
10
|
+
"updated_at": "2015-09-02T14:52:56-04:00",
|
11
|
+
"test": true,
|
12
|
+
"charge_type": null,
|
13
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/1/activate?charge_id=1012637323",
|
14
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/1012637323/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
15
|
+
}
|
16
|
+
}
|
data/test/fixtures/api/widget_store/charges/get_pending_recurring_application_charge_response.json
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"recurring_application_charge": {
|
3
|
+
"id": 654381179,
|
4
|
+
"name": "Basic",
|
5
|
+
"api_client_id": 755357713,
|
6
|
+
"price": "9.99",
|
7
|
+
"status": "pending",
|
8
|
+
"return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate",
|
9
|
+
"billing_on": null,
|
10
|
+
"created_at": "2015-09-02T14:50:32-04:00",
|
11
|
+
"updated_at": "2015-09-02T14:50:32-04:00",
|
12
|
+
"test": true,
|
13
|
+
"activated_on": null,
|
14
|
+
"trial_ends_on": null,
|
15
|
+
"cancelled_on": null,
|
16
|
+
"trial_days": 14,
|
17
|
+
"decorated_return_url": "https://test.example.com/subscriptions/304261385/charges/629961174/activate?charge_id=654381179",
|
18
|
+
"confirmation_url": "https://apple.myshopify.com/admin/charges/654381179/confirm_recurring_application_charge?signature=BAhpBHsQASc%3D--b2e90c6e4e94fbae15a464c566a31a1c23e6bffa"
|
19
|
+
}
|
20
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
current_widget_store_dev_subscription_one_time_charge:
|
2
|
+
shop: widget_store
|
3
|
+
subscription: current_widget_store_dev_subscription
|
4
|
+
status: <%= DiscoApp::ApplicationCharge.statuses[:active] %>
|
5
|
+
|
6
|
+
new_widget_store_dev_subscription_one_time_charge:
|
7
|
+
shop: widget_store_dev
|
8
|
+
subscription: current_widget_store_dev_subscription
|
9
|
+
status: <%= DiscoApp::ApplicationCharge.statuses[:pending] %>
|
10
|
+
shopify_id: 1012637323
|
11
|
+
confirmation_url: "https://apple.myshopify.com/admin/charges/1012637323/confirm_application_charge?signature=BAhpBIueWzw%3D--0ea1abacaf9d6fd538b7e9a7023e9b71ce1c7e98"
|