stripe_model_callbacks 0.1.4 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (25) hide show
  1. checksums.yaml +4 -4
  2. data/app/services/stripe_model_callbacks/base_service.rb +2 -1
  3. data/config/routes.rb +1 -1
  4. data/db/migrate/20180206151132_change_activities_trackable_id_to_string.rb +1 -1
  5. data/db/migrate/20180208091647_change_stripe_subscription_items_quantity_to_integer.rb +1 -1
  6. data/db/migrate/20200520152604_change_stripe_subscription_schedule_phase_id_to_bigint.rb +4 -4
  7. data/db/migrate/20201224122058_create_stripe_prices.rb +11 -1
  8. data/db/migrate/20221223095244_rename_stripe_customers_account_balance_to_balance.rb +5 -0
  9. data/lib/stripe_model_callbacks/engine.rb +1 -1
  10. data/lib/stripe_model_callbacks/factories/stripe_customers.rb +1 -1
  11. data/lib/stripe_model_callbacks/factories/stripe_plans.rb +0 -1
  12. data/lib/stripe_model_callbacks/models/stripe_customer.rb +10 -1
  13. data/lib/stripe_model_callbacks/models/stripe_plan.rb +1 -0
  14. data/lib/stripe_model_callbacks/models/stripe_price.rb +2 -0
  15. data/lib/stripe_model_callbacks/models/stripe_source.rb +2 -0
  16. data/lib/stripe_model_callbacks/models/stripe_subscription.rb +1 -0
  17. data/lib/stripe_model_callbacks/version.rb +1 -1
  18. metadata +36 -13
  19. data/app/assets/config/stripe_model_callbacks_manifest.js +0 -2
  20. data/app/assets/javascripts/stripe_model_callbacks/application.js +0 -13
  21. data/app/assets/stylesheets/stripe_model_callbacks/application.css +0 -15
  22. data/app/controllers/stripe_model_callbacks/application_controller.rb +0 -3
  23. data/app/jobs/stripe_model_callbacks/application_job.rb +0 -2
  24. data/app/mailers/stripe_model_callbacks/application_mailer.rb +0 -4
  25. data/app/views/layouts/stripe_model_callbacks/application.html.erb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a2074ea120eeaea0b8f7abbbc91136afb646a7fe48a1854c604499977208835
4
- data.tar.gz: b02d2706c5d4946a6fb2ab0ca1c26f8258d09cd2a344ade286b317333f1a77b4
3
+ metadata.gz: 344d7a3dacb569caaadc32a2959cd2f740d493b3626fc6e3dabdc2f14bcf76f7
4
+ data.tar.gz: 30c78d0e6dfb2acb7baa4b7a0eb99aea7893f516717f863a465bdbc9d6ed0f5c
5
5
  SHA512:
6
- metadata.gz: 5d4af6fb585fb6015a7ef483974edfe76175b166f82cd506e576bdfc8e956f1795dc6746130041a2c64a78de22c992d331d5df3ce70ed417ddc05d93f021f52f
7
- data.tar.gz: 5a9cbca86509ed5bf45111a4aef2124005f6ca986c8a134312bf9fed0a4e49a038b7e824732f372e2fdc9069ecaea3f6aa62403e372ee6ceee7cfdcb429c7044
6
+ metadata.gz: b0def52a911f242f016c3994b973edfadde72c9dfe565615e4493302b63de32eb2f5f50fe88a86cdd1377261792f9ccd140d281e6ddb9e77625daff1d82cec66
7
+ data.tar.gz: 6dccf484db456f98641a84f71ae36cda7cb8ecfa96c68426d853ec99cf9c76dcaad2584e3f659bbf10a224e3c3205865719f90f6701e1aabf00efc03c00b4b73
@@ -20,7 +20,8 @@ class StripeModelCallbacks::BaseService < ServicePattern::Service
20
20
  Rails.logger.error e.backtrace.join("\n")
21
21
  end
22
22
 
23
- ExceptionNotifier.notify_exception(e) if Object.const_defined?("ExceptionNotifier")
23
+ ExceptionNotifier.notify_exception(e) if Object.const_defined?(:ExceptionNotifier)
24
+ PeakFlowUtils::Notifier.notify(error: e) if Object.const_defined?(:PeakFlowUtils)
24
25
  raise e
25
26
  end
26
27
 
data/config/routes.rb CHANGED
@@ -1,2 +1,2 @@
1
- StripeModelCallbacks::Engine.routes.draw do
1
+ StripeModelCallbacks::Engine.routes.draw do # rubocop:disable Lint/EmptyBlock
2
2
  end
@@ -1,5 +1,5 @@
1
1
  class ChangeActivitiesTrackableIdToString < ActiveRecord::Migration[5.1]
2
2
  def change
3
- change_column :activities, :trackable_id, :string
3
+ change_column :activities, :trackable_id, :string # rubocop:disable Rails/ReversibleMigration
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  class ChangeStripeSubscriptionItemsQuantityToInteger < ActiveRecord::Migration[5.1]
2
2
  def change
3
- change_column :stripe_subscription_items, :quantity, :integer
3
+ change_column :stripe_subscription_items, :quantity, :integer # rubocop:disable Rails/ReversibleMigration
4
4
  end
5
5
  end
@@ -1,19 +1,19 @@
1
1
  class ChangeStripeSubscriptionSchedulePhaseIdToBigint < ActiveRecord::Migration[6.0]
2
2
  def change
3
3
  if postgres?
4
- change_column(
4
+ change_column( # rubocop:disable Rails/ReversibleMigration
5
5
  :stripe_subscription_schedule_phase_plans,
6
6
  :stripe_subscription_schedule_phase_id,
7
7
  "bigint USING stripe_subscription_schedule_phase_id::bigint"
8
8
  )
9
9
  elsif mysql?
10
- change_column(
10
+ change_column( # rubocop:disable Rails/ReversibleMigration
11
11
  :stripe_subscription_schedule_phase_plans,
12
12
  :stripe_subscription_schedule_phase_id,
13
- "bigint USING CAST(stripe_subscription_schedule_phase_id AS bigint"
13
+ "bigint USING CAST(stripe_subscription_schedule_phase_id AS bigint)"
14
14
  )
15
15
  else
16
- change_column :stripe_subscription_schedule_phase_plans, :stripe_subscription_schedule_phase_id, :bigint
16
+ change_column :stripe_subscription_schedule_phase_plans, :stripe_subscription_schedule_phase_id, :bigint # rubocop:disable Rails/ReversibleMigration
17
17
  end
18
18
  end
19
19
 
@@ -8,7 +8,13 @@ class CreateStripePrices < ActiveRecord::Migration[6.0]
8
8
  t.datetime :created
9
9
  t.string :currency
10
10
  t.string :lookup_key
11
- t.jsonb :metadata
11
+
12
+ if mysql?
13
+ t.json :metadata
14
+ else
15
+ t.jsonb :metadata
16
+ end
17
+
12
18
  t.string :nickname
13
19
  t.string :stripe_product_id, index: true
14
20
  t.boolean :recurring_aggregate_usage
@@ -23,4 +29,8 @@ class CreateStripePrices < ActiveRecord::Migration[6.0]
23
29
  t.timestamps
24
30
  end
25
31
  end
32
+
33
+ def mysql?
34
+ ActiveRecord::Base.connection.adapter_name.downcase.include?("mysql")
35
+ end
26
36
  end
@@ -0,0 +1,5 @@
1
+ class RenameStripeCustomersAccountBalanceToBalance < ActiveRecord::Migration[7.0]
2
+ def change
3
+ rename_column :stripe_customers, :account_balance, :balance
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module StripeModelCallbacks; end
2
2
 
3
- class StripeModelCallbacks::Engine < ::Rails::Engine
3
+ class StripeModelCallbacks::Engine < Rails::Engine
4
4
  isolate_namespace StripeModelCallbacks
5
5
  end
@@ -1,7 +1,7 @@
1
1
  FactoryBot.define do
2
2
  factory :stripe_customer do
3
3
  sequence(:stripe_id) { |n| "customer-identifier-#{n}" }
4
- account_balance { 0 }
4
+ balance { 0 }
5
5
  currency { "usd" }
6
6
  delinquent { false }
7
7
  livemode { false }
@@ -17,7 +17,6 @@ FactoryBot.define do
17
17
  id: stripe_plan.stripe_id,
18
18
  amount: stripe_plan.amount_cents,
19
19
  currency: stripe_plan.currency,
20
- name: "No name any more - waiting for Stripe mock to be updated",
21
20
  interval: stripe_plan.interval,
22
21
  interval_count: stripe_plan.interval_count,
23
22
  product: stripe_plan.stripe_product.stripe_id
@@ -14,10 +14,19 @@ class StripeCustomer < StripeModelCallbacks::ApplicationRecord
14
14
 
15
15
  def assign_from_stripe(object)
16
16
  check_object_is_stripe_class(object)
17
+
18
+ if object.respond_to?(:account_balance)
19
+ self.balance = object.account_balance
20
+ elsif object.respond_to?(:balance)
21
+ self.balance = object.balance
22
+ else
23
+ Rails.logger.error "Couldn't figure out where to get the customers balance from"
24
+ end
25
+
17
26
  StripeModelCallbacks::AttributesAssignerService.execute!(
18
27
  model: self, stripe_model: object,
19
28
  attributes: %w[
20
- account_balance currency created default_source delinquent description discount email
29
+ currency created default_source delinquent description discount email
21
30
  id livemode metadata
22
31
  ]
23
32
  )
@@ -4,6 +4,7 @@ class StripePlan < StripeModelCallbacks::ApplicationRecord
4
4
  has_many :stripe_invoice_items, primary_key: "stripe_id"
5
5
  has_many :stripe_subscriptions, primary_key: "stripe_id"
6
6
  has_many :stripe_subscription_items, primary_key: "stripe_id"
7
+ has_many :stripe_subscription_schedule_phase_plans, primary_key: "stripe_id"
7
8
 
8
9
  scope :not_deleted, -> { where(deleted_at: nil) }
9
10
 
@@ -1,4 +1,6 @@
1
1
  class StripePrice < StripeModelCallbacks::ApplicationRecord
2
+ has_many :stripe_subscription_item, primary_key: "stripe_id"
3
+
2
4
  def self.stripe_class
3
5
  Stripe::Price
4
6
  end
@@ -1,4 +1,6 @@
1
1
  class StripeSource < StripeModelCallbacks::ApplicationRecord
2
+ has_many :stripe_charges, primary_key: "stripe_id"
3
+
2
4
  monetize :amount_cents, allow_nil: true
3
5
  monetize :receiver_amount_charged_cents, allow_nil: true
4
6
  monetize :receiver_amount_received_cents, allow_nil: true
@@ -3,6 +3,7 @@ class StripeSubscription < StripeModelCallbacks::ApplicationRecord
3
3
  belongs_to :stripe_discount, optional: true
4
4
  belongs_to :stripe_plan, optional: true, primary_key: "stripe_id"
5
5
  has_many :stripe_invoices, primary_key: "stripe_id"
6
+ has_many :stripe_invoice_items, primary_key: "stripe_id"
6
7
  has_many :stripe_discounts, primary_key: "stripe_id"
7
8
  has_many :stripe_subscription_default_tax_rates, autosave: true, dependent: :destroy
8
9
  has_many :stripe_subscription_items, autosave: true, primary_key: "stripe_id"
@@ -1,3 +1,3 @@
1
1
  module StripeModelCallbacks
2
- VERSION = "0.1.4".freeze
2
+ VERSION = "0.1.6".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe_model_callbacks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaspernj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-31 00:00:00.000000000 Z
11
+ date: 2023-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 6.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: auto_autoloader
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 4.6.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: appraisal
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description: Framework for getting Stripe webhook callbacks directly to your models
126
154
  email:
127
155
  - kaspernj@gmail.com
@@ -132,12 +160,6 @@ files:
132
160
  - MIT-LICENSE
133
161
  - README.md
134
162
  - Rakefile
135
- - app/assets/config/stripe_model_callbacks_manifest.js
136
- - app/assets/javascripts/stripe_model_callbacks/application.js
137
- - app/assets/stylesheets/stripe_model_callbacks/application.css
138
- - app/controllers/stripe_model_callbacks/application_controller.rb
139
- - app/jobs/stripe_model_callbacks/application_job.rb
140
- - app/mailers/stripe_model_callbacks/application_mailer.rb
141
163
  - app/models/stripe_model_callbacks/application_record.rb
142
164
  - app/services/stripe_model_callbacks/account/external_account/updated_service.rb
143
165
  - app/services/stripe_model_callbacks/attributes_assigner_service.rb
@@ -175,7 +197,6 @@ files:
175
197
  - app/services/stripe_model_callbacks/sync_from_stripe.rb
176
198
  - app/services/stripe_model_callbacks/tax_rate/updated_service.rb
177
199
  - app/services/stripe_model_callbacks/transfer/updated_service.rb
178
- - app/views/layouts/stripe_model_callbacks/application.html.erb
179
200
  - config/rails_best_practices.yml
180
201
  - config/routes.rb
181
202
  - db/migrate/20180206115801_create_stripe_charges.rb
@@ -235,6 +256,7 @@ files:
235
256
  - db/migrate/20201224123838_add_stripe_price_to_stripe_subscription_items.rb
236
257
  - db/migrate/20211121155313_change_invoice_billing_to_nullable.rb
237
258
  - db/migrate/20211121155732_rename_invoices_billing_to_deprecated_billing.rb
259
+ - db/migrate/20221223095244_rename_stripe_customers_account_balance_to_balance.rb
238
260
  - lib/stripe_model_callbacks.rb
239
261
  - lib/stripe_model_callbacks/autoload_models.rb
240
262
  - lib/stripe_model_callbacks/configuration.rb
@@ -378,7 +400,8 @@ files:
378
400
  homepage: https://github.com/kaspernj/stripe_model_callbacks
379
401
  licenses:
380
402
  - MIT
381
- metadata: {}
403
+ metadata:
404
+ rubygems_mfa_required: 'true'
382
405
  post_install_message:
383
406
  rdoc_options: []
384
407
  require_paths:
@@ -387,7 +410,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
387
410
  requirements:
388
411
  - - ">="
389
412
  - !ruby/object:Gem::Version
390
- version: '2.5'
413
+ version: '2.7'
391
414
  required_rubygems_version: !ruby/object:Gem::Requirement
392
415
  requirements:
393
416
  - - ">="
@@ -1,2 +0,0 @@
1
- //= link_directory ../javascripts/stripe_model_callbacks .js
2
- //= link_directory ../stylesheets/stripe_model_callbacks .css
@@ -1,13 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
- //
10
- // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
- // about supported directives.
12
- //
13
- //= require_tree .
@@ -1,15 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
- * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
- * files in this directory. Styles in this file should be added after the last require_* statement.
11
- * It is generally better to create a new file per style scope.
12
- *
13
- *= require_tree .
14
- *= require_self
15
- */
@@ -1,3 +0,0 @@
1
- class StripeModelCallbacks::ApplicationController < ActionController::Base
2
- protect_from_forgery with: :exception
3
- end
@@ -1,2 +0,0 @@
1
- class StripeModelCallbacks::ApplicationJob < ActiveJob::Base
2
- end
@@ -1,4 +0,0 @@
1
- class StripeModelCallbacks::ApplicationMailer < ActionMailer::Base
2
- default from: "from@example.com"
3
- layout "mailer"
4
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Stripe model callbacks</title>
5
- <%= stylesheet_link_tag "stripe_model_callbacks/application", media: "all" %>
6
- <%= javascript_include_tag "stripe_model_callbacks/application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>