stripe_model_callbacks 0.1.3 → 0.1.4
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/README.md +11 -4
- data/app/services/stripe_model_callbacks/base_service.rb +7 -7
- data/db/migrate/20211121155313_change_invoice_billing_to_nullable.rb +5 -0
- data/db/migrate/20211121155732_rename_invoices_billing_to_deprecated_billing.rb +5 -0
- data/lib/stripe_model_callbacks/factories/stripe_invoices.rb +1 -1
- data/lib/stripe_model_callbacks/fixtures/stripe_events/invoice/invoice.created.json +36 -1
- data/lib/stripe_model_callbacks/models/stripe_invoice.rb +1 -1
- data/lib/stripe_model_callbacks/version.rb +1 -1
- metadata +7 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a2074ea120eeaea0b8f7abbbc91136afb646a7fe48a1854c604499977208835
|
4
|
+
data.tar.gz: b02d2706c5d4946a6fb2ab0ca1c26f8258d09cd2a344ade286b317333f1a77b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d4af6fb585fb6015a7ef483974edfe76175b166f82cd506e576bdfc8e956f1795dc6746130041a2c64a78de22c992d331d5df3ce70ed417ddc05d93f021f52f
|
7
|
+
data.tar.gz: 5a9cbca86509ed5bf45111a4aef2124005f6ca986c8a134312bf9fed0a4e49a038b7e824732f372e2fdc9069ecaea3f6aa62403e372ee6ceee7cfdcb429c7044
|
data/README.md
CHANGED
@@ -67,6 +67,16 @@ log and more automatically using the ActiveRecord models.
|
|
67
67
|
|
68
68
|
You can use a service like Ultrahook to set up a proxy for your local development machine to test against.
|
69
69
|
|
70
|
+
### Report errors
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
StripeModelCallbacks.configure do |config|
|
74
|
+
config.on_error do |args:, error:|
|
75
|
+
PeakFlowUtils::Notifier.notify(error: error)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
70
80
|
## Usage
|
71
81
|
|
72
82
|
### Queries with ActiveRecord
|
@@ -133,7 +143,7 @@ https://github.com/kaspernj/stripe_model_callbacks/tree/master/spec/factories
|
|
133
143
|
|
134
144
|
You can mock Stripe events by using the helper method `mock_stripe_event` by including this helper:
|
135
145
|
|
136
|
-
```
|
146
|
+
```ruby
|
137
147
|
RSpec.configure do |config|
|
138
148
|
config.include StripeModelCallbacks::EventMocker
|
139
149
|
end
|
@@ -154,9 +164,6 @@ mock_stripe_event("invoice.created", data: {object: {discount: {"customer": "cus
|
|
154
164
|
## Contributing
|
155
165
|
Contribution directions go here.
|
156
166
|
|
157
|
-
# capybara-webkit installation issue
|
158
|
-
Instruction how to solve the issue: https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit#macOS-catalina-1015
|
159
|
-
|
160
167
|
# Database schema changes
|
161
168
|
1. Add migration to `/db/migrate`: ```rails g migration AddStripeIdUniqToStripeInvoices```
|
162
169
|
2. Go to directory: `spec/dummy`
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class StripeModelCallbacks::BaseService < ServicePattern::Service
|
2
|
-
def self.reported_execute!(*args, &blk)
|
2
|
+
def self.reported_execute!(*args, **opts, &blk)
|
3
3
|
with_exception_notifications do
|
4
|
-
response = execute(*args, &blk)
|
4
|
+
response = execute(*args, **opts, &blk)
|
5
5
|
raise response.errors.join(". ") unless response.success?
|
6
6
|
|
7
7
|
response
|
@@ -24,13 +24,13 @@ class StripeModelCallbacks::BaseService < ServicePattern::Service
|
|
24
24
|
raise e
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.execute_with_advisory_lock!(*args, &blk)
|
27
|
+
def self.execute_with_advisory_lock!(*args, **opts, &blk)
|
28
28
|
# The difference between the stripe events is about a few milliseconds - with advisory_lock
|
29
29
|
# we will prevent from creating duplicated objects due to race condition.
|
30
30
|
# https://stripe.com/docs/webhooks/best-practices#event-ordering
|
31
31
|
with_exception_notifications do
|
32
|
-
StripeModelCallbacks::ApplicationRecord.with_advisory_lock(advisory_lock_name(*args)) do
|
33
|
-
response = execute(*args, &blk)
|
32
|
+
StripeModelCallbacks::ApplicationRecord.with_advisory_lock(advisory_lock_name(*args, **opts)) do
|
33
|
+
response = execute(*args, **opts, &blk)
|
34
34
|
raise response.errors.join(". ") unless response.success?
|
35
35
|
|
36
36
|
response
|
@@ -38,8 +38,8 @@ class StripeModelCallbacks::BaseService < ServicePattern::Service
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
def self.advisory_lock_name(
|
42
|
-
stripe_event_data =
|
41
|
+
def self.advisory_lock_name(event:)
|
42
|
+
stripe_event_data = event.data.object
|
43
43
|
|
44
44
|
["stripe", stripe_event_data.object, "id", advisory_lock_id(stripe_event_data)].join("-")
|
45
45
|
end
|
@@ -4,8 +4,8 @@ FactoryBot.define do
|
|
4
4
|
amount_due_cents { 0 }
|
5
5
|
amount_due_currency { "USD" }
|
6
6
|
attempted { false }
|
7
|
-
billing { "charge_automatically" }
|
8
7
|
closed { false }
|
8
|
+
collection_method { "charge_automatically" }
|
9
9
|
created { 2.days.ago }
|
10
10
|
currency { "usd" }
|
11
11
|
forgiven { false }
|
@@ -11,6 +11,9 @@
|
|
11
11
|
"object": {
|
12
12
|
"id": "in_00000000000000",
|
13
13
|
"object": "invoice",
|
14
|
+
"account_country": "DK",
|
15
|
+
"account_name": "KNJ IT-solutions",
|
16
|
+
"account_tax_ids": null,
|
14
17
|
"amount_due": 3500,
|
15
18
|
"amount_paid": 3500,
|
16
19
|
"amount_remaining": 0,
|
@@ -18,12 +21,44 @@
|
|
18
21
|
"attempt_count": 1,
|
19
22
|
"attempted": false,
|
20
23
|
"auto_advance": false,
|
21
|
-
"
|
24
|
+
"automatic_tax": {
|
25
|
+
"enabled": false,
|
26
|
+
"status": null
|
27
|
+
},
|
22
28
|
"billing_reason": "subscription_create",
|
23
29
|
"charge": "ch_00000000000000",
|
24
30
|
"collection_method": "charge_automatically",
|
31
|
+
"created": 1637488924,
|
25
32
|
"currency": "dkk",
|
26
33
|
"customer": "cus_00000000000000",
|
34
|
+
"customer_address": null,
|
35
|
+
"customer_email": "customer@example.com",
|
36
|
+
"customer_name": null,
|
37
|
+
"customer_phone": null,
|
38
|
+
"customer_shipping": null,
|
39
|
+
"customer_tax_exempt": "none",
|
40
|
+
"customer_tax_ids": [],
|
41
|
+
"default_payment_method": null,
|
42
|
+
"default_source": null,
|
43
|
+
"default_tax_rates": [
|
44
|
+
{
|
45
|
+
"id": "txr_1CLElKJHvNqCXRbQESFuQiCC",
|
46
|
+
"object": "tax_rate",
|
47
|
+
"active": true,
|
48
|
+
"country": null,
|
49
|
+
"created": 1524767050,
|
50
|
+
"description": null,
|
51
|
+
"display_name": "Tax",
|
52
|
+
"inclusive": false,
|
53
|
+
"jurisdiction": null,
|
54
|
+
"livemode": true,
|
55
|
+
"metadata": {
|
56
|
+
},
|
57
|
+
"percentage": 25,
|
58
|
+
"state": null,
|
59
|
+
"tax_type": null
|
60
|
+
}
|
61
|
+
],
|
27
62
|
"date": 1517763745,
|
28
63
|
"description": null,
|
29
64
|
"discount": null,
|
@@ -44,7 +44,7 @@ class StripeInvoice < StripeModelCallbacks::ApplicationRecord
|
|
44
44
|
StripeModelCallbacks::AttributesAssignerService.execute!(
|
45
45
|
model: self, stripe_model: object,
|
46
46
|
attributes: %w[
|
47
|
-
attempted attempt_count auto_advance
|
47
|
+
attempted attempt_count auto_advance billing_reason
|
48
48
|
collection_method currency description ending_balance hosted_invoice_url
|
49
49
|
id invoice_pdf livemode next_payment_attempt number
|
50
50
|
paid receipt_number starting_balance statement_descriptor
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.
|
75
|
+
version: 1.0.5
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 1.0.
|
82
|
+
version: 1.0.5
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: stripe
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,20 +108,6 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.0.4
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: stripe-ruby-mock
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 3.0.1
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 3.0.1
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
112
|
name: with_advisory_lock
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,6 +233,8 @@ files:
|
|
247
233
|
- db/migrate/20201224120534_create_stripe_subscription_default_tax_rates.rb
|
248
234
|
- db/migrate/20201224122058_create_stripe_prices.rb
|
249
235
|
- db/migrate/20201224123838_add_stripe_price_to_stripe_subscription_items.rb
|
236
|
+
- db/migrate/20211121155313_change_invoice_billing_to_nullable.rb
|
237
|
+
- db/migrate/20211121155732_rename_invoices_billing_to_deprecated_billing.rb
|
250
238
|
- lib/stripe_model_callbacks.rb
|
251
239
|
- lib/stripe_model_callbacks/autoload_models.rb
|
252
240
|
- lib/stripe_model_callbacks/configuration.rb
|
@@ -406,7 +394,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
406
394
|
- !ruby/object:Gem::Version
|
407
395
|
version: '0'
|
408
396
|
requirements: []
|
409
|
-
rubygems_version: 3.
|
397
|
+
rubygems_version: 3.2.32
|
410
398
|
signing_key:
|
411
399
|
specification_version: 4
|
412
400
|
summary: Framework for getting Stripe webhook callbacks directly to your models
|