jera_payment 1.0.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/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,26 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Plans
|
5
|
+
class Create < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_plan = JeraPayment::Api::Iugu::Plan.create(@attributes, @resource&.sub_account&.api_token)
|
8
|
+
|
9
|
+
if iugu_plan[:errors].present?
|
10
|
+
add_error(iugu_plan[:errors])
|
11
|
+
else
|
12
|
+
set_api_attributes(iugu_plan)
|
13
|
+
end
|
14
|
+
|
15
|
+
@resource.errors.blank?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def set_api_attributes(attributes)
|
20
|
+
@resource.api_id = attributes[:id]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Plans
|
5
|
+
class Destroy < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_plan = JeraPayment::Api::Iugu::Plan.destroy(@resource.api_id, @resource&.sub_account&.api_token)
|
8
|
+
|
9
|
+
add_error(iugu_plan[:errors]) if iugu_plan[:errors].present?
|
10
|
+
|
11
|
+
@resource.errors.blank?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Plans
|
5
|
+
class Update < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_plan = JeraPayment::Api::Iugu::Plan.update(@resource.api_id, @attributes,
|
8
|
+
@resource&.sub_account&.api_token)
|
9
|
+
|
10
|
+
add_error(iugu_plan[:errors]) if iugu_plan[:errors].present?
|
11
|
+
|
12
|
+
@resource.errors.blank?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module SubAccounts
|
5
|
+
class Create < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_marketplace = JeraPayment::Api::Iugu::SubAccount.create(@attributes)
|
8
|
+
|
9
|
+
if iugu_marketplace[:errors].present?
|
10
|
+
add_error(iugu_marketplace[:errors])
|
11
|
+
else
|
12
|
+
set_api_attributes(iugu_marketplace)
|
13
|
+
end
|
14
|
+
|
15
|
+
@resource.errors.blank?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def set_api_attributes(attributes)
|
20
|
+
@resource.assign_attributes(attributes.slice(:account_id, :live_api_token, :test_api_token, :user_token, :name))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module SubAccounts
|
5
|
+
class Update < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_marketplace = JeraPayment::Api::Iugu::SubAccount.update(JeraPayment::Parsers::Iugu::SubAccountParser.parse_account_configuration(@resource),
|
8
|
+
@resource.user_token)
|
9
|
+
|
10
|
+
add_error(iugu_marketplace[:errors]) if iugu_marketplace[:errors].present?
|
11
|
+
|
12
|
+
@resource.errors.blank?
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module SubAccounts
|
5
|
+
class Verify < JeraPayment::Services::Iugu::Base
|
6
|
+
def initialize(resource, attributes)
|
7
|
+
@resource = resource
|
8
|
+
@attributes = attributes
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
iugu_marketplace = JeraPayment::Api::Iugu::SubAccount.verify(@resource.account_id, @attributes, @resource.user_token)
|
13
|
+
|
14
|
+
add_error(iugu_marketplace[:errors]) and return @resource if iugu_marketplace[:errors].present?
|
15
|
+
|
16
|
+
set_api_attributes(iugu_marketplace)
|
17
|
+
|
18
|
+
@resource
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
def set_api_attributes(attributes)
|
23
|
+
@resource.assign_attributes(attributes.slice(:account_id, :live_api_token, :test_api_token, :user_token, :name)
|
24
|
+
.merge({resp_cpf: @attributes[:data][:resp_cpf], resp_name: @attributes[:data][:resp_name]}))
|
25
|
+
|
26
|
+
create_household
|
27
|
+
end
|
28
|
+
|
29
|
+
def create_household
|
30
|
+
@resource.households.create({ verification: true, agency: @attributes[:data][:bank_ag], account: @attributes[:data][:bank_cc],
|
31
|
+
bank: JeraPayment::Household.bank_to_enumerize(@attributes[:data][:bank]),
|
32
|
+
account_type: JeraPayment::Household.account_type_to_enumerize(@attributes[:data][:account_type]) })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Subscriptions
|
5
|
+
class ChangePlan < JeraPayment::Services::Iugu::Base
|
6
|
+
def initialize(resource, plan_identifier, simulation = nil)
|
7
|
+
@resource = resource
|
8
|
+
@plan_identifier = plan_identifier
|
9
|
+
@simulation = simulation
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
begin
|
14
|
+
ApplicationRecord.transaction do
|
15
|
+
iugu_change_subscription_plan = eval("JeraPayment::Api::Iugu::Subscription.change_plan#{@simulation.to_s}(@resource.api_id, @plan_identifier,
|
16
|
+
@resource&.customer&.sub_account&.api_token)")
|
17
|
+
|
18
|
+
raise(StandardError, iugu_change_subscription_plan[:errors]) if iugu_change_subscription_plan[:errors].present?
|
19
|
+
|
20
|
+
if @simulation.present?
|
21
|
+
@resource = iugu_change_subscription_plan
|
22
|
+
else
|
23
|
+
set_api_attributes(iugu_change_subscription_plan)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
rescue Exception => error
|
27
|
+
add_error(error.message)
|
28
|
+
end
|
29
|
+
|
30
|
+
@resource
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def set_api_attributes(attributes)
|
35
|
+
@resource.update_columns(plan_identifier: attributes[:plan_identifier])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Subscriptions
|
5
|
+
class Create < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_subscription = JeraPayment::Api::Iugu::Subscription.create(@attributes.merge({customer_id: @resource.customer.api_id}),
|
8
|
+
@resource&.customer&.sub_account&.api_token)
|
9
|
+
|
10
|
+
if iugu_subscription[:errors].present?
|
11
|
+
add_error(iugu_subscription[:errors])
|
12
|
+
else
|
13
|
+
set_api_attributes(iugu_subscription)
|
14
|
+
end
|
15
|
+
|
16
|
+
@resource.errors.blank?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def set_api_attributes(attributes)
|
21
|
+
@resource.assign_attributes(api_id: attributes[:id], active: attributes[:active],
|
22
|
+
suspended: attributes[:suspended], credits: attributes[:credits],
|
23
|
+
price_cents: attributes[:price_cents])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Subscriptions
|
5
|
+
class Destroy < JeraPayment::Services::Iugu::Base
|
6
|
+
def initialize(resource)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
iugu_subscription = JeraPayment::Api::Iugu::Subscription.destroy(@resource.api_id, @resource&.customer&.sub_account&.api_token)
|
12
|
+
|
13
|
+
if iugu_subscription[:errors].present?
|
14
|
+
add_error(iugu_subscription[:errors])
|
15
|
+
else
|
16
|
+
@resource.destroy
|
17
|
+
end
|
18
|
+
|
19
|
+
@resource.errors.blank?
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Subscriptions
|
5
|
+
class Update < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_subscription = JeraPayment::Api::Iugu::Subscription.update(@resource.api_id, @attributes.merge({customer_id: @resource.customer.api_id}),
|
8
|
+
@resource&.customer&.sub_account&.api_token)
|
9
|
+
|
10
|
+
add_error(iugu_subscription[:errors]) if iugu_subscription[:errors].present?
|
11
|
+
|
12
|
+
@resource.errors.blank?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Subscriptions
|
5
|
+
class UpdateCredits < JeraPayment::Services::Iugu::Base
|
6
|
+
def initialize(resource, credits, action)
|
7
|
+
@resource = resource
|
8
|
+
@credits = { quantity: credits }
|
9
|
+
@action = action
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
begin
|
14
|
+
ApplicationRecord.transaction do
|
15
|
+
iugu_subscription_credits = eval("JeraPayment::Api::Iugu::Subscription.#{@action.to_s}_credits(@resource.api_id, @credits,
|
16
|
+
@resource&.customer&.sub_account&.api_token)")
|
17
|
+
|
18
|
+
raise(StandardError, iugu_subscription_credits[:errors]) if iugu_subscription_credits[:errors].present?
|
19
|
+
|
20
|
+
set_api_attributes(iugu_subscription_credits)
|
21
|
+
end
|
22
|
+
rescue Exception => error
|
23
|
+
add_error(error.message)
|
24
|
+
end
|
25
|
+
|
26
|
+
@resource
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def set_api_attributes(attributes)
|
31
|
+
@resource.update_columns(credits: attributes[:credits])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Subscriptions
|
5
|
+
class UpdateSituation < JeraPayment::Services::Iugu::Base
|
6
|
+
def initialize(resource, action)
|
7
|
+
@resource = resource
|
8
|
+
@action = action
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
begin
|
13
|
+
ApplicationRecord.transaction do
|
14
|
+
iugu_subscription = eval("JeraPayment::Api::Iugu::Subscription.#{@action.to_s}(@resource.api_id,
|
15
|
+
@resource&.customer&.sub_account&.api_token)")
|
16
|
+
|
17
|
+
raise(StandardError, iugu_subscription[:errors]) if iugu_subscription[:errors].present?
|
18
|
+
|
19
|
+
set_api_attributes(iugu_subscription)
|
20
|
+
end
|
21
|
+
rescue Exception => error
|
22
|
+
add_error(error.message)
|
23
|
+
end
|
24
|
+
|
25
|
+
@resource
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def set_api_attributes(attributes)
|
30
|
+
@resource.update_columns(suspended: attributes[:suspended], active: attributes[:active])
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Transfer
|
5
|
+
class Create < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
transfer_body = JeraPayment::Parsers::Iugu::TransferParser.parse_creation(@resource)
|
8
|
+
iugu_transfer = JeraPayment::Api::Iugu::Transfer.create(transfer_body, @resource&.sub_account&.api_token)
|
9
|
+
|
10
|
+
if iugu_transfer[:errors].present?
|
11
|
+
add_error(iugu_transfer[:errors])
|
12
|
+
else
|
13
|
+
set_api_attributes(iugu_transfer)
|
14
|
+
end
|
15
|
+
|
16
|
+
@resource.errors.blank?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def set_api_attributes(attributes)
|
21
|
+
@resource.api_id = attributes[:id]
|
22
|
+
@resource.assign_attributes(attributes.slice(:amount_localized))
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module JeraPayment
|
2
|
+
module Services
|
3
|
+
module Iugu
|
4
|
+
module Withdrawals
|
5
|
+
class Create < JeraPayment::Services::Iugu::Base
|
6
|
+
def call
|
7
|
+
iugu_withdrawal = JeraPayment::Api::Iugu::Withdrawal.request_withdrawal(@resource&.sub_account&.account_id, @attributes,
|
8
|
+
@resource&.sub_account&.api_token)
|
9
|
+
|
10
|
+
if iugu_withdrawal[:errors].present?
|
11
|
+
add_error(iugu_withdrawal[:errors])
|
12
|
+
else
|
13
|
+
set_api_attributes(iugu_withdrawal)
|
14
|
+
end
|
15
|
+
|
16
|
+
@resource.errors.blank?
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def set_api_attributes(attributes)
|
21
|
+
@resource.api_id = attributes[:id]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,208 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jera_payment
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jera
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: enumerize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: httparty
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.16'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.16'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sqlite3
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
description: This gem consume the API's and integrate with your's project DB.
|
70
|
+
email:
|
71
|
+
- hospedagem@jera.com.br
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- MIT-LICENSE
|
77
|
+
- Rakefile
|
78
|
+
- app/controllers/jera_payment/callbacks_controller.rb
|
79
|
+
- app/controllers/jera_payment/jera_payment_controller.rb
|
80
|
+
- config/locale/jera_payment.pt-BR.yml
|
81
|
+
- config/routes.rb
|
82
|
+
- lib/generators/active_record/jera_payment_generator.rb
|
83
|
+
- lib/generators/active_record/templates/create_jera_payment_charges.rb
|
84
|
+
- lib/generators/active_record/templates/create_jera_payment_credit_cards.rb
|
85
|
+
- lib/generators/active_record/templates/create_jera_payment_customers.rb
|
86
|
+
- lib/generators/active_record/templates/create_jera_payment_households.rb
|
87
|
+
- lib/generators/active_record/templates/create_jera_payment_invoices.rb
|
88
|
+
- lib/generators/active_record/templates/create_jera_payment_plans.rb
|
89
|
+
- lib/generators/active_record/templates/create_jera_payment_sub_accounts.rb
|
90
|
+
- lib/generators/active_record/templates/create_jera_payment_subscriptions.rb
|
91
|
+
- lib/generators/active_record/templates/create_jera_payment_transfers.rb
|
92
|
+
- lib/generators/active_record/templates/create_jera_payment_withdrawals.rb
|
93
|
+
- lib/generators/jera_payment/install_generator.rb
|
94
|
+
- lib/generators/jera_payment/jera_payment_generator.rb
|
95
|
+
- lib/generators/jera_payment/templates/jera_payment.rb
|
96
|
+
- lib/jera_payment.rb
|
97
|
+
- lib/jera_payment/api/iugu/base.rb
|
98
|
+
- lib/jera_payment/api/iugu/charge.rb
|
99
|
+
- lib/jera_payment/api/iugu/customer.rb
|
100
|
+
- lib/jera_payment/api/iugu/household.rb
|
101
|
+
- lib/jera_payment/api/iugu/invoice.rb
|
102
|
+
- lib/jera_payment/api/iugu/payment_method.rb
|
103
|
+
- lib/jera_payment/api/iugu/payment_token.rb
|
104
|
+
- lib/jera_payment/api/iugu/plan.rb
|
105
|
+
- lib/jera_payment/api/iugu/sub_account.rb
|
106
|
+
- lib/jera_payment/api/iugu/subscription.rb
|
107
|
+
- lib/jera_payment/api/iugu/transfer.rb
|
108
|
+
- lib/jera_payment/api/iugu/withdrawal.rb
|
109
|
+
- lib/jera_payment/application.rb
|
110
|
+
- lib/jera_payment/engine.rb
|
111
|
+
- lib/jera_payment/models/charge.rb
|
112
|
+
- lib/jera_payment/models/concerns/household_methods.rb
|
113
|
+
- lib/jera_payment/models/concerns/invoice_methods.rb
|
114
|
+
- lib/jera_payment/models/concerns/resource_callbacks.rb
|
115
|
+
- lib/jera_payment/models/concerns/sub_account_methods.rb
|
116
|
+
- lib/jera_payment/models/concerns/subscription_methods.rb
|
117
|
+
- lib/jera_payment/models/concerns/transfer_methods.rb
|
118
|
+
- lib/jera_payment/models/concerns/withdrawal_methods.rb
|
119
|
+
- lib/jera_payment/models/credit_card.rb
|
120
|
+
- lib/jera_payment/models/customer.rb
|
121
|
+
- lib/jera_payment/models/household.rb
|
122
|
+
- lib/jera_payment/models/invoice.rb
|
123
|
+
- lib/jera_payment/models/plan.rb
|
124
|
+
- lib/jera_payment/models/sub_account.rb
|
125
|
+
- lib/jera_payment/models/subscription.rb
|
126
|
+
- lib/jera_payment/models/transfer.rb
|
127
|
+
- lib/jera_payment/models/withdrawal.rb
|
128
|
+
- lib/jera_payment/parsers/iugu/charge_parser.rb
|
129
|
+
- lib/jera_payment/parsers/iugu/credit_card_parser.rb
|
130
|
+
- lib/jera_payment/parsers/iugu/household_parser.rb
|
131
|
+
- lib/jera_payment/parsers/iugu/invoice_parser.rb
|
132
|
+
- lib/jera_payment/parsers/iugu/sub_account_parser.rb
|
133
|
+
- lib/jera_payment/parsers/iugu/transfer_parser.rb
|
134
|
+
- lib/jera_payment/services/iugu/base.rb
|
135
|
+
- lib/jera_payment/services/iugu/charges/create.rb
|
136
|
+
- lib/jera_payment/services/iugu/credit_cards/create.rb
|
137
|
+
- lib/jera_payment/services/iugu/credit_cards/destroy.rb
|
138
|
+
- lib/jera_payment/services/iugu/credit_cards/update.rb
|
139
|
+
- lib/jera_payment/services/iugu/customers/create.rb
|
140
|
+
- lib/jera_payment/services/iugu/customers/destroy.rb
|
141
|
+
- lib/jera_payment/services/iugu/customers/update.rb
|
142
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/base.rb
|
143
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/created.rb
|
144
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/due.rb
|
145
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/dunning_action.rb
|
146
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/installment_released.rb
|
147
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/payment_failed.rb
|
148
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/refund.rb
|
149
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/released.rb
|
150
|
+
- lib/jera_payment/services/iugu/handle_callbacks/invoice/status_changed.rb
|
151
|
+
- lib/jera_payment/services/iugu/handle_callbacks/referrals/bank_verification.rb
|
152
|
+
- lib/jera_payment/services/iugu/handle_callbacks/referrals/base.rb
|
153
|
+
- lib/jera_payment/services/iugu/handle_callbacks/referrals/verification.rb
|
154
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/activated.rb
|
155
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/base.rb
|
156
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/changed.rb
|
157
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/created.rb
|
158
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/expired.rb
|
159
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/renewed.rb
|
160
|
+
- lib/jera_payment/services/iugu/handle_callbacks/subscription/suspended.rb
|
161
|
+
- lib/jera_payment/services/iugu/handle_callbacks/withdraw_request/base.rb
|
162
|
+
- lib/jera_payment/services/iugu/handle_callbacks/withdraw_request/created.rb
|
163
|
+
- lib/jera_payment/services/iugu/handle_callbacks/withdraw_request/status_changed.rb
|
164
|
+
- lib/jera_payment/services/iugu/households/create.rb
|
165
|
+
- lib/jera_payment/services/iugu/invoices/create.rb
|
166
|
+
- lib/jera_payment/services/iugu/invoices/duplicate.rb
|
167
|
+
- lib/jera_payment/services/iugu/invoices/send_email.rb
|
168
|
+
- lib/jera_payment/services/iugu/invoices/update_status.rb
|
169
|
+
- lib/jera_payment/services/iugu/plans/create.rb
|
170
|
+
- lib/jera_payment/services/iugu/plans/destroy.rb
|
171
|
+
- lib/jera_payment/services/iugu/plans/update.rb
|
172
|
+
- lib/jera_payment/services/iugu/sub_accounts/create.rb
|
173
|
+
- lib/jera_payment/services/iugu/sub_accounts/update.rb
|
174
|
+
- lib/jera_payment/services/iugu/sub_accounts/verify.rb
|
175
|
+
- lib/jera_payment/services/iugu/subscriptions/change_plan.rb
|
176
|
+
- lib/jera_payment/services/iugu/subscriptions/create.rb
|
177
|
+
- lib/jera_payment/services/iugu/subscriptions/destroy.rb
|
178
|
+
- lib/jera_payment/services/iugu/subscriptions/update.rb
|
179
|
+
- lib/jera_payment/services/iugu/subscriptions/update_credits.rb
|
180
|
+
- lib/jera_payment/services/iugu/subscriptions/update_situation.rb
|
181
|
+
- lib/jera_payment/services/iugu/transfers/create.rb
|
182
|
+
- lib/jera_payment/services/iugu/withdrawals/create.rb
|
183
|
+
- lib/jera_payment/version.rb
|
184
|
+
homepage: https://github.com/jera/jera-payment
|
185
|
+
licenses:
|
186
|
+
- MIT
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: 2.5.0
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements: []
|
203
|
+
rubyforge_project:
|
204
|
+
rubygems_version: 2.6.11
|
205
|
+
signing_key:
|
206
|
+
specification_version: 4
|
207
|
+
summary: Gem to use Pagar.me, MercadoPago and Iugu Payment API's.
|
208
|
+
test_files: []
|