stripe_saas 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1a7732ddce9b22f0317f66f0ca31313b09a951f
4
- data.tar.gz: aa80053f89c1874fe1afbde71403163709849419
3
+ metadata.gz: 11d33c83f274930a298978620639a355a8c74e0f
4
+ data.tar.gz: 115508a935fc8fe389b89bb57f20adc5c412d88d
5
5
  SHA512:
6
- metadata.gz: 9616f27904015b43795afb097350c0be7a502ee76ffc784434bd6ce1cde6f9f7cde6ad3d0374896fd1518d769659d6dd9bfdc7c04ce787cd2d68d4b32ced491e
7
- data.tar.gz: 267567bb6b9275c2e53abfa6c413051b21ab7a98767671aa0c298442e16fc979e98542ddb7cf25e0554b1aeece391d54c9d2874c1425fa08343021dad90f0ab0
6
+ metadata.gz: 2e76f158eb245eafce9c67c07eee561272b8d952d43ecce13e6d7eb0b82144cf7ee58fe8f7ce7acb79e96a548a5a4551cb9e8976b950788b7b3b631712112f4d
7
+ data.tar.gz: 3d8bff7dc13eae924e75df86389811295a0952974ae71c35fc753671d1b2d199ade53a742392ca58326e9268c65b4f3fd44ea44eec2d7ace6e126bf0487edd03
data/README.asc CHANGED
@@ -3,6 +3,14 @@
3
3
  A Rails 4 Engine providing Stripe subscription management for SaaS applications.
4
4
  Based on the work of Andrew Culver in Koudoku (https://github.com/andrewculver/koudoku).
5
5
 
6
+ == Status
7
+
8
+ image:https://www.codeship.io/projects/7ab95b50-8968-0133-979d-4619ccd24e37/status?branch=master[CI Status]
9
+ image:https://codeclimate.com/github/integrallis/stripe_saas/badges/gpa.svg[
10
+ "Code Climate",link="https://codeclimate.com/github/integrallis/stripe_saas"]
11
+ image:https://codeclimate.com/github/integrallis/stripe_saas/badges/coverage.svg[
12
+ "Test Coverage",link="https://codeclimate.com/github/integrallis/stripe_saas/coverage"]
13
+
6
14
  == Installation
7
15
 
8
16
  === Add gem dependency
@@ -17,6 +17,9 @@ module StripeSaas
17
17
  mattr_accessor :create_plans_in_stripe
18
18
  @@create_plans_in_stripe = false
19
19
 
20
+ mattr_accessor :non_stripe_plans
21
+ @@non_stripe_plans = []
22
+
20
23
  def self.setup
21
24
  yield self
22
25
 
@@ -18,21 +18,23 @@ module StripeSaas
18
18
  if StripeSaas.create_plans_in_stripe?
19
19
  begin
20
20
  ::Plan.all.each do |plan|
21
- begin
22
- stripe_plan = Stripe::Plan.retrieve(plan.stripe_id)
23
- rescue Stripe::InvalidRequestError => ire
24
- if ire.message == "No such plan: #{plan.stripe_id}"
25
- Stripe::Plan.create(
26
- id: plan.stripe_id,
27
- name: plan.name,
28
- amount: plan.price_cents,
29
- interval: plan.interval,
30
- interval_count: plan.interval_count,
31
- trial_period_days: plan.trial_period_days,
32
- statement_descriptor: plan.statement_descriptor,
33
- currency: 'usd',
34
- metadata: plan.metadata_as_json
35
- )
21
+ unless StripeSaas.non_stripe_plans.include?(plan.stripe_id)
22
+ begin
23
+ stripe_plan = Stripe::Plan.retrieve(plan.stripe_id)
24
+ rescue Stripe::InvalidRequestError => ire
25
+ if ire.message == "No such plan: #{plan.stripe_id}"
26
+ Stripe::Plan.create(
27
+ id: plan.stripe_id,
28
+ name: plan.name,
29
+ amount: plan.price_cents,
30
+ interval: plan.interval,
31
+ interval_count: plan.interval_count,
32
+ trial_period_days: plan.trial_period_days,
33
+ statement_descriptor: plan.statement_descriptor,
34
+ currency: 'usd',
35
+ metadata: plan.metadata_as_json
36
+ )
37
+ end
36
38
  end
37
39
  end
38
40
  end
@@ -1,3 +1,3 @@
1
1
  module StripeSaas
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
Binary file
@@ -3323,3 +3323,106 @@ Migrating to CreatePlanFeatures (20151220161817)
3323
3323
   (2.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3324
3324
   (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3325
3325
  ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
3326
+ ActiveRecord::SchemaMigration Load (1.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
3327
+  (2.2ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3328
+  (1.8ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3329
+  (1.7ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3330
+  (1.3ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3331
+  (1.8ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3332
+  (0.1ms) select sqlite_version(*)
3333
+  (1.8ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3334
+  (0.1ms) SELECT sql
3335
+ FROM sqlite_master
3336
+ WHERE name='index_users_on_email' AND type='index'
3337
+ UNION ALL
3338
+ SELECT sql
3339
+ FROM sqlite_temp_master
3340
+ WHERE name='index_users_on_email' AND type='index'
3341
+
3342
+  (1.2ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3343
+  (1.9ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3344
+  (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3345
+  (0.1ms) SELECT version FROM "schema_migrations"
3346
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3347
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3348
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3349
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3350
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3351
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3352
+  (2.4ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3353
+  (3.1ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3354
+  (1.9ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3355
+  (2.0ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3356
+  (2.4ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3357
+  (0.1ms) select sqlite_version(*)
3358
+  (1.9ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3359
+  (0.2ms) SELECT sql
3360
+ FROM sqlite_master
3361
+ WHERE name='index_users_on_email' AND type='index'
3362
+ UNION ALL
3363
+ SELECT sql
3364
+ FROM sqlite_temp_master
3365
+ WHERE name='index_users_on_email' AND type='index'
3366
+
3367
+  (1.7ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3368
+  (1.7ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3369
+  (1.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3370
+  (0.2ms) SELECT version FROM "schema_migrations"
3371
+  (2.3ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3372
+  (3.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3373
+  (1.8ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3374
+  (1.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3375
+  (1.6ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3376
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
3377
+ ActiveRecord::SchemaMigration Load (1.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
3378
+  (1.9ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3379
+  (1.9ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3380
+  (1.7ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3381
+  (2.1ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3382
+  (2.8ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3383
+  (0.2ms) select sqlite_version(*)
3384
+  (2.0ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3385
+  (0.2ms) SELECT sql
3386
+ FROM sqlite_master
3387
+ WHERE name='index_users_on_email' AND type='index'
3388
+ UNION ALL
3389
+ SELECT sql
3390
+ FROM sqlite_temp_master
3391
+ WHERE name='index_users_on_email' AND type='index'
3392
+
3393
+  (3.0ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3394
+  (1.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3395
+  (1.7ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3396
+  (0.2ms) SELECT version FROM "schema_migrations"
3397
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3398
+  (3.5ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3399
+  (2.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3400
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3401
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3402
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
3403
+ ActiveRecord::SchemaMigration Load (1.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
3404
+  (4.6ms) CREATE TABLE "features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar, "description" varchar, "feature_type" varchar, "unit" varchar, "display_order" integer, "use_unit" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3405
+  (3.0ms) CREATE TABLE "plan_features" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "value" varchar, "display_value" varchar, "plan_id" integer, "feature_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3406
+  (7.9ms) CREATE TABLE "plans" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "name" varchar, "price_cents" integer, "interval" varchar, "interval_count" integer, "trial_period_days" integer, "metadata_as_json" text, "statement_descriptor" text, "highlight" boolean, "display_order" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) 
3407
+  (17.9ms) CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "stripe_id" varchar, "plan_id" integer, "last_four" varchar, "card_type" varchar, "current_price_cents" integer, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
3408
+  (5.3ms) CREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar DEFAULT '' NOT NULL, "encrypted_password" varchar DEFAULT '' NOT NULL, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "created_at" datetime, "updated_at" datetime) 
3409
+  (0.1ms) select sqlite_version(*)
3410
+  (4.0ms) CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email")
3411
+  (0.2ms) SELECT sql
3412
+ FROM sqlite_master
3413
+ WHERE name='index_users_on_email' AND type='index'
3414
+ UNION ALL
3415
+ SELECT sql
3416
+ FROM sqlite_temp_master
3417
+ WHERE name='index_users_on_email' AND type='index'
3418
+
3419
+  (3.1ms) CREATE UNIQUE INDEX "index_users_on_reset_password_token" ON "users" ("reset_password_token")
3420
+  (7.8ms) CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
3421
+  (4.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
3422
+  (0.1ms) SELECT version FROM "schema_migrations"
3423
+  (7.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161817')
3424
+  (17.2ms) INSERT INTO "schema_migrations" (version) VALUES ('20150101233243')
3425
+  (1.7ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001921')
3426
+  (2.0ms) INSERT INTO "schema_migrations" (version) VALUES ('20150102001930')
3427
+  (1.9ms) INSERT INTO "schema_migrations" (version) VALUES ('20151220161809')
3428
+ ActiveRecord::SchemaMigration Load (0.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
@@ -30,7 +30,7 @@ describe PlanFeature, type: :model do
30
30
  display_order: 3
31
31
  })
32
32
 
33
- @plan = Plan.find_or_create_by(stripe_id: 'my_plan')
33
+ @plan = Plan.find_or_create_by(stripe_id: 'the_plan')
34
34
  @plan.update({
35
35
  name: 'My Plan',
36
36
  price: 0.0,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe_saas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Sam-Bodden
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-21 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails