stripe_model_callbacks 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +153 -0
- data/Rakefile +26 -0
- data/app/assets/config/stripe_model_callbacks_manifest.js +2 -0
- data/app/assets/javascripts/stripe_model_callbacks/application.js +13 -0
- data/app/assets/stylesheets/stripe_model_callbacks/application.css +15 -0
- data/app/controllers/stripe_model_callbacks/application_controller.rb +3 -0
- data/app/jobs/stripe_model_callbacks/application_job.rb +2 -0
- data/app/mailers/stripe_model_callbacks/application_mailer.rb +4 -0
- data/app/models/stripe_model_callbacks/application_record.rb +60 -0
- data/app/services/stripe_model_callbacks/account/external_account/updated_service.rb +13 -0
- data/app/services/stripe_model_callbacks/attributes_assigner_service.rb +35 -0
- data/app/services/stripe_model_callbacks/base_event_service.rb +9 -0
- data/app/services/stripe_model_callbacks/base_service.rb +26 -0
- data/app/services/stripe_model_callbacks/charge/dispute_updated_service.rb +29 -0
- data/app/services/stripe_model_callbacks/charge/updated_service.rb +40 -0
- data/app/services/stripe_model_callbacks/configure_service.rb +217 -0
- data/app/services/stripe_model_callbacks/coupon/updated_service.rb +18 -0
- data/app/services/stripe_model_callbacks/customer/bank_account/deleted_service.rb +13 -0
- data/app/services/stripe_model_callbacks/customer/deleted_service.rb +13 -0
- data/app/services/stripe_model_callbacks/customer/discount_updated_service.rb +32 -0
- data/app/services/stripe_model_callbacks/customer/source_updated_service.rb +25 -0
- data/app/services/stripe_model_callbacks/customer/subscription/updated_service.rb +28 -0
- data/app/services/stripe_model_callbacks/customer/updated_service.rb +13 -0
- data/app/services/stripe_model_callbacks/event_mocker_service.rb +38 -0
- data/app/services/stripe_model_callbacks/invoice/updated_service.rb +26 -0
- data/app/services/stripe_model_callbacks/invoice_item/updated_service.rb +13 -0
- data/app/services/stripe_model_callbacks/notifier_service.rb +6 -0
- data/app/services/stripe_model_callbacks/order/updated_service.rb +28 -0
- data/app/services/stripe_model_callbacks/payout/updated_service.rb +29 -0
- data/app/services/stripe_model_callbacks/plan/updated_service.rb +14 -0
- data/app/services/stripe_model_callbacks/product/updated_service.rb +14 -0
- data/app/services/stripe_model_callbacks/recipient/updated_service.rb +14 -0
- data/app/services/stripe_model_callbacks/refund/updated_service.rb +12 -0
- data/app/services/stripe_model_callbacks/review/updated_service.rb +13 -0
- data/app/services/stripe_model_callbacks/sku/updated_service.rb +14 -0
- data/app/services/stripe_model_callbacks/source/updated_service.rb +31 -0
- data/app/services/stripe_model_callbacks/subscription/state_checker_service.rb +21 -0
- data/app/services/stripe_model_callbacks/transfer/updated_service.rb +18 -0
- data/app/views/layouts/stripe_model_callbacks/application.html.erb +14 -0
- data/config/rails_best_practices.yml +49 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20180206115801_create_stripe_charges.rb +54 -0
- data/db/migrate/20180206115802_create_stripe_coupons.rb +22 -0
- data/db/migrate/20180206115803_create_stripe_customers.rb +21 -0
- data/db/migrate/20180206115804_create_stripe_discounts.rb +27 -0
- data/db/migrate/20180206115805_create_stripe_invoice_items.rb +26 -0
- data/db/migrate/20180206115806_create_stripe_invoices.rb +57 -0
- data/db/migrate/20180206115807_create_stripe_order_items.rb +15 -0
- data/db/migrate/20180206115808_create_stripe_orders.rb +46 -0
- data/db/migrate/20180206115809_create_stripe_payouts.rb +27 -0
- data/db/migrate/20180206115810_create_stripe_plans.rb +20 -0
- data/db/migrate/20180206115811_create_stripe_products.rb +25 -0
- data/db/migrate/20180206115812_create_stripe_recipients.rb +18 -0
- data/db/migrate/20180206115813_create_stripe_refunds.rb +21 -0
- data/db/migrate/20180206115814_create_stripe_skus.rb +22 -0
- data/db/migrate/20180206115815_create_stripe_sources.rb +70 -0
- data/db/migrate/20180206115816_create_stripe_subscriptions.rb +29 -0
- data/db/migrate/20180206115817_create_stripe_transfers.rb +25 -0
- data/db/migrate/20180206130408_create_disputes.rb +76 -0
- data/db/migrate/20180206151132_change_activities_trackable_id_to_string.rb +5 -0
- data/db/migrate/20180207121808_create_stripe_subscription_items.rb +14 -0
- data/db/migrate/20180207171559_remove_name_from_stripe_plans.rb +5 -0
- data/db/migrate/20180207172011_add_stripe_product_id_to_stripe_plans.rb +6 -0
- data/db/migrate/20180207185604_add_index_on_refund_charge.rb +5 -0
- data/db/migrate/20180208091647_change_stripe_subscription_items_quantity_to_integer.rb +5 -0
- data/db/migrate/20180208102513_add_attempt_count_to_stripe_invoices.rb +7 -0
- data/db/migrate/20180208121235_create_stripe_reviews.rb +13 -0
- data/db/migrate/20180208122654_create_stripe_bank_accounts.rb +20 -0
- data/db/migrate/20180208160046_add_nickname_to_stripe_plans.rb +5 -0
- data/db/migrate/20180211092437_rename_stripe_invoice_items_subscription_item.rb +6 -0
- data/db/migrate/20180216224335_rename_stripe_subscriptions_discount.rb +5 -0
- data/db/migrate/20180217200350_change_stripe_invoices_to_reference_discounts.rb +9 -0
- data/db/migrate/20180217204628_create_stripe_cards.rb +29 -0
- data/db/migrate/20180218092600_add_deleted_at_to_stripe_cards.rb +9 -0
- data/db/migrate/20181219121712_add_new_primary_id_and_rename_old.rb +37 -0
- data/db/migrate/20190629112050_rename_stripe_invoice_date_to_created.rb +5 -0
- data/lib/stripe_model_callbacks.rb +19 -0
- data/lib/stripe_model_callbacks/autoload_models.rb +8 -0
- data/lib/stripe_model_callbacks/configuration.rb +23 -0
- data/lib/stripe_model_callbacks/engine.rb +5 -0
- data/lib/stripe_model_callbacks/event_mocker.rb +5 -0
- data/lib/stripe_model_callbacks/factory_bot_definitions.rb +7 -0
- data/lib/stripe_model_callbacks/models/stripe_bank_account.rb +17 -0
- data/lib/stripe_model_callbacks/models/stripe_card.rb +25 -0
- data/lib/stripe_model_callbacks/models/stripe_charge.rb +47 -0
- data/lib/stripe_model_callbacks/models/stripe_coupon.rb +24 -0
- data/lib/stripe_model_callbacks/models/stripe_customer.rb +23 -0
- data/lib/stripe_model_callbacks/models/stripe_discount.rb +53 -0
- data/lib/stripe_model_callbacks/models/stripe_dispute.rb +86 -0
- data/lib/stripe_model_callbacks/models/stripe_invoice.rb +88 -0
- data/lib/stripe_model_callbacks/models/stripe_invoice_item.rb +33 -0
- data/lib/stripe_model_callbacks/models/stripe_order.rb +63 -0
- data/lib/stripe_model_callbacks/models/stripe_order_item.rb +20 -0
- data/lib/stripe_model_callbacks/models/stripe_payout.rb +26 -0
- data/lib/stripe_model_callbacks/models/stripe_plan.rb +32 -0
- data/lib/stripe_model_callbacks/models/stripe_product.rb +27 -0
- data/lib/stripe_model_callbacks/models/stripe_recipient.rb +16 -0
- data/lib/stripe_model_callbacks/models/stripe_refund.rb +28 -0
- data/lib/stripe_model_callbacks/models/stripe_review.rb +18 -0
- data/lib/stripe_model_callbacks/models/stripe_sku.rb +28 -0
- data/lib/stripe_model_callbacks/models/stripe_source.rb +79 -0
- data/lib/stripe_model_callbacks/models/stripe_subscription.rb +101 -0
- data/lib/stripe_model_callbacks/models/stripe_subscription_item.rb +36 -0
- data/lib/stripe_model_callbacks/models/stripe_transfer.rb +25 -0
- data/lib/stripe_model_callbacks/require_models.rb +7 -0
- data/lib/stripe_model_callbacks/version.rb +3 -0
- data/lib/tasks/stripe_model_callbacks_tasks.rake +4 -0
- metadata +249 -0
@@ -0,0 +1,26 @@
|
|
1
|
+
class StripeModelCallbacks::Invoice::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
invoice.assign_from_stripe(object)
|
4
|
+
|
5
|
+
if invoice.save
|
6
|
+
create_activity
|
7
|
+
|
8
|
+
succeed!
|
9
|
+
else
|
10
|
+
fail! invoice.errors.full_messages
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def create_activity
|
17
|
+
invoice.create_activity :payment_failed if event.type == "invoice.payment_failed"
|
18
|
+
invoice.create_activity :payment_succeeded if event.type == "invoice.payment_succeeded"
|
19
|
+
invoice.create_activity :sent if event.type == "invoice.sent"
|
20
|
+
invoice.create_activity :upcoming if event.type == "invoice.upcoming"
|
21
|
+
end
|
22
|
+
|
23
|
+
def invoice
|
24
|
+
@invoice ||= StripeInvoice.find_or_initialize_by(stripe_id: object.id)
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class StripeModelCallbacks::InvoiceItem::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
invoice_item = ::StripeInvoiceItem.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
invoice_item.assign_from_stripe(object)
|
5
|
+
invoice_item.deleted_at = Time.zone.now if event.type == "invoiceitem.deleted"
|
6
|
+
|
7
|
+
if invoice_item.save
|
8
|
+
succeed!
|
9
|
+
else
|
10
|
+
fail! invoice_item.errors.full_messages
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class StripeModelCallbacks::Order::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
order.assign_from_stripe(object)
|
4
|
+
|
5
|
+
if order.save
|
6
|
+
create_order_items
|
7
|
+
|
8
|
+
succeed!
|
9
|
+
else
|
10
|
+
fail! order.errors.full_messages
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def create_order_items
|
17
|
+
object.items.each do |order_item|
|
18
|
+
stripe_order_item = StripeOrderItem.find_or_initialize_by(parent_id: order_item.parent)
|
19
|
+
stripe_order_item.stripe_order_id = object.id
|
20
|
+
stripe_order_item.assign_from_stripe(order_item)
|
21
|
+
stripe_order_item.save!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def order
|
26
|
+
@order ||= StripeOrder.find_or_initialize_by(stripe_id: object.id)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class StripeModelCallbacks::Payout::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
payout.assign_from_stripe(object)
|
4
|
+
|
5
|
+
if payout.save
|
6
|
+
create_activity
|
7
|
+
succeed!
|
8
|
+
else
|
9
|
+
fail! payout.errors.full_messages
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def create_activity
|
16
|
+
case event.type
|
17
|
+
when "payout.canceled"
|
18
|
+
payout.create_activity :canceled
|
19
|
+
when "payout.failed"
|
20
|
+
payout.create_activity :failed
|
21
|
+
when "payout.paid"
|
22
|
+
payout.create_activity :paid
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def payout
|
27
|
+
@payout ||= StripePayout.find_or_initialize_by(stripe_id: object.id)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class StripeModelCallbacks::Plan::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
plan = StripePlan.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
plan.assign_from_stripe(object)
|
5
|
+
plan.deleted_at ||= Time.zone.now if event.type == "plan.deleted"
|
6
|
+
|
7
|
+
if plan.save
|
8
|
+
plan.create_activity :deleted if event.type == "plan.deleted"
|
9
|
+
succeed!
|
10
|
+
else
|
11
|
+
fail! plan.errors.full_messages
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class StripeModelCallbacks::Product::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
product = StripeProduct.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
product.assign_from_stripe(object)
|
5
|
+
product.deleted_at ||= Time.zone.now if event.type == "product.deleted"
|
6
|
+
|
7
|
+
if product.save
|
8
|
+
product.create_activity :deleted if event.type == "product.deleted"
|
9
|
+
succeed!
|
10
|
+
else
|
11
|
+
fail! product.errors.full_messages
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class StripeModelCallbacks::Recipient::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
recipient = StripeRecipient.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
recipient.assign_from_stripe(object)
|
5
|
+
recipient.deleted_at ||= Time.zone.now if event.type == "recipient.deleted"
|
6
|
+
|
7
|
+
if recipient.save
|
8
|
+
recipient.create_activity :deleted if event.type == "recipient.deleted"
|
9
|
+
succeed!
|
10
|
+
else
|
11
|
+
fail! recipient.errors.full_messages
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class StripeModelCallbacks::Refund::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
refund = StripeRefund.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
refund.assign_from_stripe(object)
|
5
|
+
|
6
|
+
if refund.save
|
7
|
+
succeed!
|
8
|
+
else
|
9
|
+
fail! refund.errors.full_messages
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class StripeModelCallbacks::Review::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
review = StripeReview.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
review.assign_from_stripe(object)
|
5
|
+
|
6
|
+
if review.save
|
7
|
+
review.create_activity :closed if event.type == "review.closed"
|
8
|
+
succeed!
|
9
|
+
else
|
10
|
+
fail! review.errors.full_messages
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class StripeModelCallbacks::Sku::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
sku = StripeSku.find_or_initialize_by(stripe_id: object.id)
|
4
|
+
sku.assign_from_stripe(object)
|
5
|
+
sku.deleted_at ||= Time.zone.now if event.type == "sku.deleted"
|
6
|
+
|
7
|
+
if sku.save
|
8
|
+
sku.create_activity :deleted if event.type == "sku.deleted"
|
9
|
+
succeed!
|
10
|
+
else
|
11
|
+
fail! sku.errors.full_messages
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class StripeModelCallbacks::Source::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
source.assign_from_stripe(object)
|
4
|
+
|
5
|
+
if source.save
|
6
|
+
create_activity
|
7
|
+
succeed!
|
8
|
+
else
|
9
|
+
fail! source.errors.full_messages
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def create_activity
|
16
|
+
case event.type
|
17
|
+
when "source.canceled"
|
18
|
+
source.create_activity :canceled
|
19
|
+
when "source.chargeable"
|
20
|
+
source.create_activity :chargeable
|
21
|
+
when "source.failed"
|
22
|
+
source.create_activity :failed
|
23
|
+
when "source.mandate_notification"
|
24
|
+
source.create_activity :mandate_notification
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def source
|
29
|
+
@source ||= StripeSource.find_or_initialize_by(stripe_id: object.id)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class StripeModelCallbacks::Subscription::StateCheckerService < StripeModelCallbacks::BaseService
|
2
|
+
attr_reader :allowed, :state
|
3
|
+
|
4
|
+
def initialize(allowed:, state:)
|
5
|
+
@allowed = allowed
|
6
|
+
@state = state.to_s
|
7
|
+
end
|
8
|
+
|
9
|
+
def execute
|
10
|
+
if state.is_a?(Array)
|
11
|
+
state.each do |state_i|
|
12
|
+
response = Subscription::StateCheckerService.execute!(allowed: allowed, state: state_i)
|
13
|
+
return response unless response.success?
|
14
|
+
end
|
15
|
+
elsif !allowed.include?(state)
|
16
|
+
return fail! ["Not allowed: #{state}"]
|
17
|
+
end
|
18
|
+
|
19
|
+
succeed!
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class StripeModelCallbacks::Transfer::UpdatedService < StripeModelCallbacks::BaseEventService
|
2
|
+
def execute
|
3
|
+
transfer.assign_from_stripe(object)
|
4
|
+
|
5
|
+
if transfer.save
|
6
|
+
transfer.create_activity :reversed if event.type == "transfer.reversed"
|
7
|
+
succeed!
|
8
|
+
else
|
9
|
+
fail! transfer.errors.full_messages
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def transfer
|
16
|
+
@transfer ||= StripeTransfer.find_or_initialize_by(stripe_id: object.id)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
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>
|
@@ -0,0 +1,49 @@
|
|
1
|
+
AddModelVirtualAttributeCheck: { }
|
2
|
+
AlwaysAddDbIndexCheck: { }
|
3
|
+
#CheckSaveReturnValueCheck: { }
|
4
|
+
#CheckDestroyReturnValueCheck: { }
|
5
|
+
DefaultScopeIsEvilCheck: { }
|
6
|
+
DryBundlerInCapistranoCheck: { }
|
7
|
+
#HashSyntaxCheck: { }
|
8
|
+
IsolateSeedDataCheck: { }
|
9
|
+
KeepFindersOnTheirOwnModelCheck: { }
|
10
|
+
LawOfDemeterCheck: { }
|
11
|
+
#LongLineCheck: { max_line_length: 80 }
|
12
|
+
MoveCodeIntoControllerCheck: { }
|
13
|
+
MoveCodeIntoHelperCheck: { array_count: 3 }
|
14
|
+
MoveCodeIntoModelCheck: { use_count: 2 }
|
15
|
+
MoveFinderToNamedScopeCheck: { }
|
16
|
+
MoveModelLogicIntoModelCheck: { use_count: 4 }
|
17
|
+
NeedlessDeepNestingCheck: { nested_count: 2 }
|
18
|
+
NotRescueExceptionCheck: { }
|
19
|
+
NotUseDefaultRouteCheck: { }
|
20
|
+
NotUseTimeAgoInWordsCheck: { }
|
21
|
+
OveruseRouteCustomizationsCheck: { customize_count: 3 }
|
22
|
+
ProtectMassAssignmentCheck: { }
|
23
|
+
RemoveEmptyHelpersCheck: { }
|
24
|
+
#RemoveTabCheck: { }
|
25
|
+
RemoveTrailingWhitespaceCheck: { }
|
26
|
+
RemoveUnusedMethodsInControllersCheck: { except_methods: [] }
|
27
|
+
RemoveUnusedMethodsInHelpersCheck: { except_methods: [] }
|
28
|
+
RemoveUnusedMethodsInModelsCheck: {
|
29
|
+
except_methods: [
|
30
|
+
"StripeModelCallbacks::ApplicationRecord#create_on_stripe!",
|
31
|
+
"StripeModelCallbacks::ApplicationRecord#reload!",
|
32
|
+
"StripeModelCallbacks::ApplicationRecord#update_on_stripe!",
|
33
|
+
"StripeModelCallbacks::ApplicationRecord#destroy_on_stripe!"
|
34
|
+
]
|
35
|
+
}
|
36
|
+
ReplaceComplexCreationWithFactoryMethodCheck: { attribute_assignment_count: 2 }
|
37
|
+
ReplaceInstanceVariableWithLocalVariableCheck: { }
|
38
|
+
RestrictAutoGeneratedRoutesCheck: { }
|
39
|
+
SimplifyRenderInControllersCheck: { }
|
40
|
+
SimplifyRenderInViewsCheck: { }
|
41
|
+
#UseBeforeFilterCheck: { customize_count: 2 }
|
42
|
+
UseModelAssociationCheck: { }
|
43
|
+
UseMultipartAlternativeAsContentTypeOfEmailCheck: { }
|
44
|
+
#UseParenthesesInMethodDefCheck: { }
|
45
|
+
UseObserverCheck: { }
|
46
|
+
UseQueryAttributeCheck: { }
|
47
|
+
UseSayWithTimeInMigrationsCheck: { }
|
48
|
+
UseScopeAccessCheck: { }
|
49
|
+
UseTurboSprocketsRails3Check: { }
|
data/config/routes.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class CreateStripeCharges < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :stripe_charges do |table|
|
4
|
+
table.string :stripe_id, index: true, null: false
|
5
|
+
amount_columns(table)
|
6
|
+
dispute_failure_and_fraud_columns(table)
|
7
|
+
recipient_columns(table)
|
8
|
+
table.boolean :livemode, default: true, null: false
|
9
|
+
table.text :metadata
|
10
|
+
table.string :source_transfer
|
11
|
+
table.string :statement_descriptor
|
12
|
+
table.string :status
|
13
|
+
table.string :transfer_group
|
14
|
+
table.datetime :created
|
15
|
+
table.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def amount_columns(table)
|
22
|
+
table.integer :amount_cents, null: false
|
23
|
+
table.string :amount_currency, null: false
|
24
|
+
table.integer :amount_refunded_cents
|
25
|
+
table.string :amount_refunded_currency
|
26
|
+
table.integer :application_cents
|
27
|
+
table.string :application_currency
|
28
|
+
table.string :currency, null: false
|
29
|
+
table.boolean :captured, null: false
|
30
|
+
table.boolean :paid, null: false
|
31
|
+
end
|
32
|
+
|
33
|
+
def dispute_failure_and_fraud_columns(table)
|
34
|
+
table.string :dispute
|
35
|
+
table.string :failure_code
|
36
|
+
table.string :failure_message
|
37
|
+
table.text :fraud_details
|
38
|
+
table.text :outcome
|
39
|
+
table.boolean :refunded, null: false
|
40
|
+
table.string :review
|
41
|
+
end
|
42
|
+
|
43
|
+
def recipient_columns(table)
|
44
|
+
table.string :description
|
45
|
+
table.string :stripe_customer_id, index: true
|
46
|
+
table.string :stripe_order_id, index: true
|
47
|
+
table.string :stripe_source_id, index: true
|
48
|
+
table.string :stripe_invoice_id, index: true
|
49
|
+
table.string :on_behalf_of
|
50
|
+
table.string :receipt_email
|
51
|
+
table.string :receipt_number
|
52
|
+
table.text :shipping
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CreateStripeCoupons < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :stripe_coupons do |t|
|
4
|
+
t.string :stripe_id, index: true, null: false
|
5
|
+
t.integer :amount_off_cents
|
6
|
+
t.string :amount_off_currency
|
7
|
+
t.datetime :created
|
8
|
+
t.datetime :deleted_at, index: true
|
9
|
+
t.string :currency
|
10
|
+
t.string :duration
|
11
|
+
t.integer :duration_in_months
|
12
|
+
t.boolean :livemode, default: true, null: false
|
13
|
+
t.integer :max_redemptions
|
14
|
+
t.text :metadata
|
15
|
+
t.integer :percent_off
|
16
|
+
t.datetime :redeem_by
|
17
|
+
t.integer :times_redeemed
|
18
|
+
t.boolean :stripe_valid
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class CreateStripeCustomers < ActiveRecord::Migration[5.0]
|
2
|
+
def change
|
3
|
+
create_table :stripe_customers do |t|
|
4
|
+
t.string :stripe_id, index: true, null: false
|
5
|
+
t.integer :account_balance, null: false
|
6
|
+
t.string :business_vat_id
|
7
|
+
t.datetime :deleted_at, index: true
|
8
|
+
t.string :currency
|
9
|
+
t.string :default_source
|
10
|
+
t.boolean :delinquent, null: false
|
11
|
+
t.string :description
|
12
|
+
t.text :discount
|
13
|
+
t.string :email
|
14
|
+
t.boolean :livemode, default: true, null: false
|
15
|
+
t.text :metadata
|
16
|
+
t.text :shipping
|
17
|
+
t.datetime :created
|
18
|
+
t.timestamps
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|