stripe_model_callbacks 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/db/migrate/20200520152604_change_stripe_subscription_schedule_phase_id_to_bigint.rb +1 -1
- data/db/migrate/20201224122058_create_stripe_prices.rb +11 -1
- data/db/migrate/20221223095244_rename_stripe_customers_account_balance_to_balance.rb +5 -0
- data/lib/stripe_model_callbacks/engine.rb +1 -1
- data/lib/stripe_model_callbacks/factories/stripe_customers.rb +1 -1
- data/lib/stripe_model_callbacks/factories/stripe_plans.rb +0 -1
- data/lib/stripe_model_callbacks/models/stripe_customer.rb +10 -1
- data/lib/stripe_model_callbacks/models/stripe_plan.rb +1 -0
- data/lib/stripe_model_callbacks/models/stripe_price.rb +2 -0
- data/lib/stripe_model_callbacks/models/stripe_source.rb +2 -0
- data/lib/stripe_model_callbacks/models/stripe_subscription.rb +1 -0
- data/lib/stripe_model_callbacks/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 344d7a3dacb569caaadc32a2959cd2f740d493b3626fc6e3dabdc2f14bcf76f7
|
4
|
+
data.tar.gz: 30c78d0e6dfb2acb7baa4b7a0eb99aea7893f516717f863a465bdbc9d6ed0f5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0def52a911f242f016c3994b973edfadde72c9dfe565615e4493302b63de32eb2f5f50fe88a86cdd1377261792f9ccd140d281e6ddb9e77625daff1d82cec66
|
7
|
+
data.tar.gz: 6dccf484db456f98641a84f71ae36cda7cb8ecfa96c68426d853ec99cf9c76dcaad2584e3f659bbf10a224e3c3205865719f90f6701e1aabf00efc03c00b4b73
|
@@ -10,7 +10,7 @@ class ChangeStripeSubscriptionSchedulePhaseIdToBigint < ActiveRecord::Migration[
|
|
10
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
16
|
change_column :stripe_subscription_schedule_phase_plans, :stripe_subscription_schedule_phase_id, :bigint # rubocop:disable Rails/ReversibleMigration
|
@@ -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
|
-
|
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
|
@@ -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
|
-
|
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 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"
|
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
|
+
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:
|
11
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -256,6 +256,7 @@ files:
|
|
256
256
|
- db/migrate/20201224123838_add_stripe_price_to_stripe_subscription_items.rb
|
257
257
|
- db/migrate/20211121155313_change_invoice_billing_to_nullable.rb
|
258
258
|
- db/migrate/20211121155732_rename_invoices_billing_to_deprecated_billing.rb
|
259
|
+
- db/migrate/20221223095244_rename_stripe_customers_account_balance_to_balance.rb
|
259
260
|
- lib/stripe_model_callbacks.rb
|
260
261
|
- lib/stripe_model_callbacks/autoload_models.rb
|
261
262
|
- lib/stripe_model_callbacks/configuration.rb
|