core_merchant 0.10.0 → 0.10.1
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/Gemfile.lock +1 -1
- data/lib/core_merchant/concerns/subscription_event_association.rb +5 -0
- data/lib/core_merchant/subscription.rb +1 -0
- data/lib/core_merchant/subscription_event.rb +0 -4
- data/lib/core_merchant/subscription_manager.rb +5 -0
- data/lib/core_merchant/version.rb +1 -1
- data/lib/generators/core_merchant/templates/core_merchant.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2a8720cdfe9e44ee389c1f9297dca125be49ee41dd0aa36353480ebe59242f1
|
4
|
+
data.tar.gz: 8dc8ed8fd42ef4fca3ecd63b5064a0b5499da237df1fbc19bdb75301054b7646
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76f2ff5aa75aeb8f992be5be10d1e5b7630102cf34ddf2bfcdeeafe7ac151253e27ff6dbeea2936b245af3b6965b02dce856354ae2ee7d958844e93f07cc51dd
|
7
|
+
data.tar.gz: 7175e21168584ba3b16863933e4ea5afc297fe8fb053f8502766fc8c55b1614168eb0b0c28f9ba89ca4d2e5a82d24c928b5effcbe5633dc18a38dba536d2b188
|
data/Gemfile.lock
CHANGED
@@ -10,6 +10,7 @@ module CoreMerchant
|
|
10
10
|
|
11
11
|
included do
|
12
12
|
has_many :events, class_name: "SubscriptionEvent", dependent: :destroy
|
13
|
+
after_update :create_status_change_event, if: :saved_change_to_status?
|
13
14
|
|
14
15
|
EVENT_TYPES.each do |event_type|
|
15
16
|
scope_name = "#{event_type}_events".to_sym
|
@@ -21,6 +22,10 @@ module CoreMerchant
|
|
21
22
|
events.create!(event_type: event_type, metadata: metadata)
|
22
23
|
end
|
23
24
|
end
|
25
|
+
|
26
|
+
def create_status_change_event
|
27
|
+
status_change_events.create!(from: saved_changes["status"].first, to: status)
|
28
|
+
end
|
24
29
|
end
|
25
30
|
end
|
26
31
|
end
|
@@ -123,6 +123,7 @@ module CoreMerchant
|
|
123
123
|
end
|
124
124
|
|
125
125
|
notify_subscription_manager(:canceled, reason: reason, immediate: !at_period_end)
|
126
|
+
cancellation_events.create!(reason: reason, at_period_end: at_period_end)
|
126
127
|
end
|
127
128
|
|
128
129
|
# Starts a new period for the subscription.
|
@@ -104,6 +104,11 @@ module CoreMerchant
|
|
104
104
|
return unless subscription.transition_to_active
|
105
105
|
|
106
106
|
subscription.start_new_period
|
107
|
+
subscription.renewal_events.create!(
|
108
|
+
price_cents: subscription.subscription_plan.price_cents,
|
109
|
+
renewed_from: subscription.current_period_start, renewed_until: subscription.current_period_end
|
110
|
+
)
|
111
|
+
|
107
112
|
notify(subscription, :renewed)
|
108
113
|
end
|
109
114
|
|
@@ -7,7 +7,7 @@ CoreMerchant.configure do |config|
|
|
7
7
|
# include CoreMerchant::CustomerBehavior
|
8
8
|
# ...
|
9
9
|
# end
|
10
|
-
config.customer_class = "User"
|
10
|
+
# config.customer_class = "User"
|
11
11
|
|
12
12
|
# Set the class that will receive subscription notifications/
|
13
13
|
# This class must include the CoreMerchant::SubscriptionListener module.
|
@@ -22,5 +22,5 @@ CoreMerchant.configure do |config|
|
|
22
22
|
#
|
23
23
|
# To test notifications to this class, you can override `on_test_event_received` method
|
24
24
|
# and call `CoreMerchant.subscription_manager.notify_test_event`.
|
25
|
-
config.subscription_listener_class = "SubscriptionListener"
|
25
|
+
# config.subscription_listener_class = "SubscriptionListener"
|
26
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: core_merchant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seyithan Teymur
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|