jera_payment 1.0.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +2 -0
- data/app/controllers/jera_payment/callbacks_controller.rb +22 -0
- data/app/controllers/jera_payment/jera_payment_controller.rb +5 -0
- data/config/locale/jera_payment.pt-BR.yml +243 -0
- data/config/routes.rb +5 -0
- data/lib/generators/active_record/jera_payment_generator.rb +59 -0
- data/lib/generators/active_record/templates/create_jera_payment_charges.rb +36 -0
- data/lib/generators/active_record/templates/create_jera_payment_credit_cards.rb +20 -0
- data/lib/generators/active_record/templates/create_jera_payment_customers.rb +22 -0
- data/lib/generators/active_record/templates/create_jera_payment_households.rb +18 -0
- data/lib/generators/active_record/templates/create_jera_payment_invoices.rb +42 -0
- data/lib/generators/active_record/templates/create_jera_payment_plans.rb +18 -0
- data/lib/generators/active_record/templates/create_jera_payment_sub_accounts.rb +39 -0
- data/lib/generators/active_record/templates/create_jera_payment_subscriptions.rb +26 -0
- data/lib/generators/active_record/templates/create_jera_payment_transfers.rb +15 -0
- data/lib/generators/active_record/templates/create_jera_payment_withdrawals.rb +15 -0
- data/lib/generators/jera_payment/install_generator.rb +68 -0
- data/lib/generators/jera_payment/jera_payment_generator.rb +46 -0
- data/lib/generators/jera_payment/templates/jera_payment.rb +9 -0
- data/lib/jera_payment.rb +39 -0
- data/lib/jera_payment/api/iugu/base.rb +55 -0
- data/lib/jera_payment/api/iugu/charge.rb +12 -0
- data/lib/jera_payment/api/iugu/customer.rb +37 -0
- data/lib/jera_payment/api/iugu/household.rb +13 -0
- data/lib/jera_payment/api/iugu/invoice.rb +55 -0
- data/lib/jera_payment/api/iugu/payment_method.rb +39 -0
- data/lib/jera_payment/api/iugu/payment_token.rb +12 -0
- data/lib/jera_payment/api/iugu/plan.rb +42 -0
- data/lib/jera_payment/api/iugu/sub_account.rb +40 -0
- data/lib/jera_payment/api/iugu/subscription.rb +72 -0
- data/lib/jera_payment/api/iugu/transfer.rb +24 -0
- data/lib/jera_payment/api/iugu/withdrawal.rb +26 -0
- data/lib/jera_payment/application.rb +79 -0
- data/lib/jera_payment/engine.rb +5 -0
- data/lib/jera_payment/models/charge.rb +30 -0
- data/lib/jera_payment/models/concerns/household_methods.rb +33 -0
- data/lib/jera_payment/models/concerns/invoice_methods.rb +42 -0
- data/lib/jera_payment/models/concerns/resource_callbacks.rb +40 -0
- data/lib/jera_payment/models/concerns/sub_account_methods.rb +18 -0
- data/lib/jera_payment/models/concerns/subscription_methods.rb +34 -0
- data/lib/jera_payment/models/concerns/transfer_methods.rb +18 -0
- data/lib/jera_payment/models/concerns/withdrawal_methods.rb +18 -0
- data/lib/jera_payment/models/credit_card.rb +16 -0
- data/lib/jera_payment/models/customer.rb +14 -0
- data/lib/jera_payment/models/household.rb +51 -0
- data/lib/jera_payment/models/invoice.rb +49 -0
- data/lib/jera_payment/models/plan.rb +16 -0
- data/lib/jera_payment/models/sub_account.rb +53 -0
- data/lib/jera_payment/models/subscription.rb +29 -0
- data/lib/jera_payment/models/transfer.rb +20 -0
- data/lib/jera_payment/models/withdrawal.rb +24 -0
- data/lib/jera_payment/parsers/iugu/charge_parser.rb +39 -0
- data/lib/jera_payment/parsers/iugu/credit_card_parser.rb +31 -0
- data/lib/jera_payment/parsers/iugu/household_parser.rb +16 -0
- data/lib/jera_payment/parsers/iugu/invoice_parser.rb +31 -0
- data/lib/jera_payment/parsers/iugu/sub_account_parser.rb +26 -0
- data/lib/jera_payment/parsers/iugu/transfer_parser.rb +15 -0
- data/lib/jera_payment/services/iugu/base.rb +23 -0
- data/lib/jera_payment/services/iugu/charges/create.rb +30 -0
- data/lib/jera_payment/services/iugu/credit_cards/create.rb +40 -0
- data/lib/jera_payment/services/iugu/credit_cards/destroy.rb +23 -0
- data/lib/jera_payment/services/iugu/credit_cards/update.rb +19 -0
- data/lib/jera_payment/services/iugu/customers/create.rb +27 -0
- data/lib/jera_payment/services/iugu/customers/destroy.rb +22 -0
- data/lib/jera_payment/services/iugu/customers/update.rb +30 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/base.rb +24 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/created.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/due.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/dunning_action.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/installment_released.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/payment_failed.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/refund.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/released.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/invoice/status_changed.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/referrals/bank_verification.rb +39 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/referrals/base.rb +16 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/referrals/verification.rb +24 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/activated.rb +12 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/base.rb +18 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/changed.rb +12 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/created.rb +12 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/expired.rb +12 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/renewed.rb +12 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/subscription/suspended.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/withdraw_request/base.rb +16 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/withdraw_request/created.rb +8 -0
- data/lib/jera_payment/services/iugu/handle_callbacks/withdraw_request/status_changed.rb +20 -0
- data/lib/jera_payment/services/iugu/households/create.rb +19 -0
- data/lib/jera_payment/services/iugu/invoices/create.rb +31 -0
- data/lib/jera_payment/services/iugu/invoices/duplicate.rb +54 -0
- data/lib/jera_payment/services/iugu/invoices/send_email.rb +18 -0
- data/lib/jera_payment/services/iugu/invoices/update_status.rb +31 -0
- data/lib/jera_payment/services/iugu/plans/create.rb +26 -0
- data/lib/jera_payment/services/iugu/plans/destroy.rb +17 -0
- data/lib/jera_payment/services/iugu/plans/update.rb +18 -0
- data/lib/jera_payment/services/iugu/sub_accounts/create.rb +26 -0
- data/lib/jera_payment/services/iugu/sub_accounts/update.rb +19 -0
- data/lib/jera_payment/services/iugu/sub_accounts/verify.rb +38 -0
- data/lib/jera_payment/services/iugu/subscriptions/change_plan.rb +41 -0
- data/lib/jera_payment/services/iugu/subscriptions/create.rb +29 -0
- data/lib/jera_payment/services/iugu/subscriptions/destroy.rb +26 -0
- data/lib/jera_payment/services/iugu/subscriptions/update.rb +18 -0
- data/lib/jera_payment/services/iugu/subscriptions/update_credits.rb +37 -0
- data/lib/jera_payment/services/iugu/subscriptions/update_situation.rb +36 -0
- data/lib/jera_payment/services/iugu/transfers/create.rb +28 -0
- data/lib/jera_payment/services/iugu/withdrawals/create.rb +27 -0
- data/lib/jera_payment/version.rb +3 -0
- metadata +208 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Concerns
|
3
|
+
module HouseholdMethods
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
after_create -> { ensure_current_household }, if: :is_verification?
|
8
|
+
|
9
|
+
def has_update_callback?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_create_callback?
|
14
|
+
!is_verification?
|
15
|
+
end
|
16
|
+
|
17
|
+
def is_verification?
|
18
|
+
self.verification
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_destroy_callback?
|
22
|
+
false
|
23
|
+
end
|
24
|
+
|
25
|
+
def ensure_current_household
|
26
|
+
sub_account = self.sub_account
|
27
|
+
sub_account.update_columns(current_household_id: self.id)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Concerns
|
3
|
+
module InvoiceMethods
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
def cancel
|
8
|
+
JeraPayment::Services::Iugu::Invoices::UpdateStatus.new(self, :cancel).call
|
9
|
+
end
|
10
|
+
|
11
|
+
def capture
|
12
|
+
JeraPayment::Services::Iugu::Invoices::UpdateStatus.new(self, :capture).call
|
13
|
+
end
|
14
|
+
|
15
|
+
def refund
|
16
|
+
JeraPayment::Services::Iugu::Invoices::UpdateStatus.new(self, :refund).call
|
17
|
+
end
|
18
|
+
|
19
|
+
def duplicate(attributes = {})
|
20
|
+
JeraPayment::Services::Iugu::Invoices::Duplicate.new(self, attributes).call
|
21
|
+
end
|
22
|
+
|
23
|
+
def send_email
|
24
|
+
JeraPayment::Services::Iugu::Invoices::SendEmail.new(self).call
|
25
|
+
end
|
26
|
+
|
27
|
+
def has_update_callback?
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
def has_destroy_callback?
|
32
|
+
false
|
33
|
+
end
|
34
|
+
|
35
|
+
def has_create_callback?
|
36
|
+
!self.duplicated
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Concerns
|
3
|
+
module ResourceCallbacks
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
before_create -> { api_action(:create) }, if: :has_create_callback?
|
8
|
+
before_update -> { api_action(:update) }, if: :has_update_callback?
|
9
|
+
before_destroy -> { api_action(:destroy) }, if: :has_destroy_callback?
|
10
|
+
end
|
11
|
+
|
12
|
+
def api_action(action_name)
|
13
|
+
api_response = eval("JeraPayment::Services::#{api_name}::#{module_name}::#{action_name.to_s.capitalize}.new(self).call")
|
14
|
+
throw(:abort) unless api_response
|
15
|
+
end
|
16
|
+
|
17
|
+
def has_update_callback?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def has_create_callback?
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def has_destroy_callback?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def module_name
|
31
|
+
self.class.name.pluralize.split('::').last
|
32
|
+
end
|
33
|
+
|
34
|
+
def api_name
|
35
|
+
JeraPayment.api.to_s.capitalize
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Concerns
|
3
|
+
module SubAccountMethods
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
def verify(attributes)
|
8
|
+
JeraPayment::Services::Iugu::SubAccounts::Verify.new(self, attributes).call
|
9
|
+
end
|
10
|
+
|
11
|
+
def has_destroy_callback?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Concerns
|
3
|
+
module SubscriptionMethods
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
def activate
|
8
|
+
JeraPayment::Services::Iugu::Subscriptions::UpdateSituation.new(self, :activate).call
|
9
|
+
end
|
10
|
+
|
11
|
+
def suspend
|
12
|
+
JeraPayment::Services::Iugu::Subscriptions::UpdateSituation.new(self, :suspend).call
|
13
|
+
end
|
14
|
+
|
15
|
+
def change_plan_simulation(plan_identifier)
|
16
|
+
JeraPayment::Services::Iugu::Subscriptions::ChangePlan.new(self, plan_identifier, :_simulation).call
|
17
|
+
end
|
18
|
+
|
19
|
+
def change_plan(plan_identifier)
|
20
|
+
JeraPayment::Services::Iugu::Subscriptions::ChangePlan.new(self, plan_identifier).call
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_credits(credits)
|
24
|
+
JeraPayment::Services::Iugu::Subscriptions::UpdateCredits.new(self, credits, :add).call
|
25
|
+
end
|
26
|
+
|
27
|
+
def remove_credits(credits)
|
28
|
+
JeraPayment::Services::Iugu::Subscriptions::UpdateCredits.new(self, credits, :remove).call
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class JeraPayment::CreditCard < ActiveRecord::Base
|
2
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
3
|
+
|
4
|
+
attr_readonly :customer_id, :api_id, :brand, :number, :first_name, :last_name, :cvv, :month, :year, :test
|
5
|
+
|
6
|
+
self.table_name = "jera_payment_credit_cards"
|
7
|
+
|
8
|
+
belongs_to :customer, class_name: 'JeraPayment::Customer'
|
9
|
+
|
10
|
+
after_create :set_as_default
|
11
|
+
|
12
|
+
def set_as_default
|
13
|
+
self.customer.update_column(:current_credit_card_id, self.id)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class JeraPayment::Customer < ActiveRecord::Base
|
2
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
3
|
+
|
4
|
+
self.table_name = "jera_payment_customers"
|
5
|
+
|
6
|
+
has_many :credit_cards, class_name: 'JeraPayment::CreditCard'
|
7
|
+
has_many :invoices, class_name: 'JeraPayment::Invoice'
|
8
|
+
has_many :subscriptions, class_name: 'JeraPayment::Subscription'
|
9
|
+
|
10
|
+
belongs_to :sub_account, class_name: 'JeraPayment::SubAccount', optional: true
|
11
|
+
belongs_to :customerable, polymorphic: true
|
12
|
+
belongs_to :current_credit_card, class_name: 'JeraPayment::CreditCard', foreign_key: :current_credit_card_id, optional: true
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class JeraPayment::Household < ActiveRecord::Base
|
2
|
+
require 'enumerize'
|
3
|
+
|
4
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
5
|
+
include JeraPayment::Concerns::HouseholdMethods
|
6
|
+
extend Enumerize
|
7
|
+
|
8
|
+
attr_readonly :sub_account, :agency, :account, :account_type, :bank, :document
|
9
|
+
|
10
|
+
self.table_name = 'jera_payment_households'
|
11
|
+
|
12
|
+
belongs_to :sub_account, class_name: 'JeraPayment::SubAccount'
|
13
|
+
|
14
|
+
enumerize :status, in: { pending: 0, rejected: 2, accepted: 3 }, predicates: true, scope: true, default: :pending
|
15
|
+
enumerize :bank, in: { itau: 0, bradesco: 1, caixa_economica: 2, banco_do_brasil: 3, santander: 4, banrisul: 5, sicredi: 6, sicoob: 7, inter: 8, brb: 9 }
|
16
|
+
enumerize :account_type, in: { checking: 0, savings: 1 }
|
17
|
+
|
18
|
+
def self.bank_to_enumerize(bank_name)
|
19
|
+
bank_name.parameterize.underscore.to_sym
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.account_type_to_enumerize(account_type)
|
23
|
+
account_type.eql?('Corrente') ? :checking : :savings
|
24
|
+
end
|
25
|
+
|
26
|
+
def bank_iugu_code
|
27
|
+
case self.bank
|
28
|
+
when "banco_do_brasil"
|
29
|
+
"001"
|
30
|
+
when "itau"
|
31
|
+
"341"
|
32
|
+
when "bradesco"
|
33
|
+
"237"
|
34
|
+
when "caixa_economica"
|
35
|
+
"104"
|
36
|
+
when "banrisul"
|
37
|
+
"041"
|
38
|
+
when "sicredi"
|
39
|
+
"748"
|
40
|
+
when "brb"
|
41
|
+
"070"
|
42
|
+
when "santander"
|
43
|
+
"033"
|
44
|
+
when "sicoob"
|
45
|
+
"756"
|
46
|
+
when "inter"
|
47
|
+
"077"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class JeraPayment::Invoice < ActiveRecord::Base
|
2
|
+
require 'enumerize'
|
3
|
+
|
4
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
5
|
+
include JeraPayment::Concerns::InvoiceMethods
|
6
|
+
extend Enumerize
|
7
|
+
|
8
|
+
attr_readonly :api_id, :customer, :email, :cc_emails, :due_date,
|
9
|
+
:ensure_workday_due_date, :items, :total_cents, :discount_cents,
|
10
|
+
:payable_with, :return_url, :expired_url, :notification_url, :fines,
|
11
|
+
:late_payment_fine, :per_day_interest, :ignore_due_email, :subscription_api_id,
|
12
|
+
:credits, :early_payment_discount, :early_payment_discounts, :payer, :paid_at, :secure_url, :digitable_line, :barcode_data, :barcode
|
13
|
+
|
14
|
+
self.table_name = 'jera_payment_invoices'
|
15
|
+
|
16
|
+
enumerize :status, in: { pending: 0, paid: 1, canceled: 2, partially_paid: 3, refunded: 4, expired: 5,
|
17
|
+
authorized: 6, in_protest: 7, chargeback: 8, in_analysis: 9 }, predicates: true, scope: true, default: :pending
|
18
|
+
|
19
|
+
belongs_to :customer, class_name: 'JeraPayment::Customer', optional: true
|
20
|
+
|
21
|
+
belongs_to :sub_account, class_name: 'JeraPayment::SubAccount', optional: true
|
22
|
+
|
23
|
+
has_one :charge, class_name: 'JeraPayment::Charge'
|
24
|
+
|
25
|
+
def items=(value)
|
26
|
+
write_attribute(:items, value&.to_json)
|
27
|
+
end
|
28
|
+
|
29
|
+
def items
|
30
|
+
ActiveSupport::JSON.decode(self[:items]) if self[:items]
|
31
|
+
end
|
32
|
+
|
33
|
+
def early_payment_discounts=(value)
|
34
|
+
write_attribute(:items, value&.to_json)
|
35
|
+
end
|
36
|
+
|
37
|
+
def early_payment_discounts
|
38
|
+
ActiveSupport::JSON.decode(self[:early_payment_discounts]).map{ |early_payment_discount| early_payment_discount.deep_symbolize_keys } if self[:early_payment_discounts]
|
39
|
+
end
|
40
|
+
|
41
|
+
def payer=(value)
|
42
|
+
write_attribute(:payer, value&.to_json)
|
43
|
+
end
|
44
|
+
|
45
|
+
def payer
|
46
|
+
ActiveSupport::JSON.decode(self[:payer]) if self[:payer]
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class JeraPayment::Plan < ActiveRecord::Base
|
2
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
3
|
+
|
4
|
+
belongs_to :sub_account, class_name: 'JeraPayment::SubAccount', optional: true
|
5
|
+
|
6
|
+
self.table_name = 'jera_payment_plans'
|
7
|
+
|
8
|
+
def features=(value)
|
9
|
+
write_attribute(:features, value&.to_json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def features
|
13
|
+
ActiveSupport::JSON.decode(self[:features]).map{ |item| item.deep_symbolize_keys } if self[:features]
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class JeraPayment::SubAccount < ActiveRecord::Base
|
2
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
3
|
+
include JeraPayment::Concerns::SubAccountMethods
|
4
|
+
|
5
|
+
self.table_name = "jera_payment_sub_accounts"
|
6
|
+
|
7
|
+
has_many :plans, class_name: 'JeraPayment::Plan'
|
8
|
+
has_many :customers, class_name: 'JeraPayment::Customer'
|
9
|
+
has_many :withdrawals, class_name: 'JeraPayment::Withdrawal'
|
10
|
+
has_many :households, class_name: 'JeraPayment::Household'
|
11
|
+
has_many :transfers, class_name: 'JeraPayment::Transfer'
|
12
|
+
has_many :invoices, class_name: 'JeraPayment::Invoice'
|
13
|
+
has_many :charges, class_name: 'JeraPayment::Charge'
|
14
|
+
|
15
|
+
belongs_to :sub_accountable, polymorphic: true, optional: true
|
16
|
+
belongs_to :current_household, class_name: 'JeraPayment::Household', foreign_key: :current_household_id, optional: true
|
17
|
+
|
18
|
+
def api_token
|
19
|
+
JeraPayment.is_test ? self.test_api_token : self.live_api_token
|
20
|
+
end
|
21
|
+
|
22
|
+
def comissions=(value)
|
23
|
+
write_attribute(:comissions, value&.to_json)
|
24
|
+
end
|
25
|
+
|
26
|
+
def comissions
|
27
|
+
ActiveSupport::JSON.decode(self[:comissions]) if self[:comissions]
|
28
|
+
end
|
29
|
+
|
30
|
+
def bank_slip=(value)
|
31
|
+
write_attribute(:bank_slip, value&.to_json)
|
32
|
+
end
|
33
|
+
|
34
|
+
def bank_slip
|
35
|
+
ActiveSupport::JSON.decode(self[:bank_slip]) if self[:bank_slip]
|
36
|
+
end
|
37
|
+
|
38
|
+
def credit_card=(value)
|
39
|
+
write_attribute(:credit_card, value&.to_json)
|
40
|
+
end
|
41
|
+
|
42
|
+
def credit_card
|
43
|
+
ActiveSupport::JSON.decode(self[:credit_card]) if self[:credit_card]
|
44
|
+
end
|
45
|
+
|
46
|
+
def early_payment_discounts=(value)
|
47
|
+
write_attribute(:early_payment_discounts, value&.to_json)
|
48
|
+
end
|
49
|
+
|
50
|
+
def early_payment_discounts
|
51
|
+
ActiveSupport::JSON.decode(self[:early_payment_discounts]).map{ |early_payment_discounts| early_payment_discounts.deep_symbolize_keys } if self[:early_payment_discounts]
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class JeraPayment::Subscription < ActiveRecord::Base
|
2
|
+
include JeraPayment::Concerns::ResourceCallbacks
|
3
|
+
include JeraPayment::Concerns::SubscriptionMethods
|
4
|
+
|
5
|
+
self.table_name = 'jera_payment_subscriptions'
|
6
|
+
|
7
|
+
belongs_to :customer, class_name: 'JeraPayment::Customer'
|
8
|
+
|
9
|
+
def subitems=(value)
|
10
|
+
write_attribute(:subitems, value&.to_json)
|
11
|
+
end
|
12
|
+
|
13
|
+
def subitems
|
14
|
+
ActiveSupport::JSON.decode(self[:subitems]).map{ |item| item.deep_symbolize_keys } if self[:subitems]
|
15
|
+
end
|
16
|
+
|
17
|
+
def custom_variables=(value)
|
18
|
+
write_attribute(:custom_variables, value&.to_json)
|
19
|
+
end
|
20
|
+
|
21
|
+
def custom_variables
|
22
|
+
ActiveSupport::JSON.decode(self[:custom_variables]).map{ |item| item.deep_symbolize_keys } if self[:custom_variables]
|
23
|
+
end
|
24
|
+
|
25
|
+
def plan
|
26
|
+
JeraPayment::Plan.find_by(identifier: self.plan_identifier)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|