class JeraPayment::Services::Iugu::Charges::Create
Public Instance Methods
call()
click to toggle source
# File lib/jera_payment/services/iugu/charges/create.rb, line 6 def call charge_body = JeraPayment::Parsers::Iugu::ChargeParser.charge_body(@resource) charge_body.merge!({ method: @resource.method}) if @resource.method.present? charge_body.merge!({ token: @resource.token}) if @resource.token.present? iugu_charge = JeraPayment::Api::Iugu::Charge.create(charge_body, @resource&.sub_account&.api_token) if iugu_charge[:errors].present? add_error(iugu_charge[:errors]) else set_api_attributes(iugu_charge) end @resource.errors.blank? end
Private Instance Methods
set_api_attributes(attributes)
click to toggle source
# File lib/jera_payment/services/iugu/charges/create.rb, line 23 def set_api_attributes(attributes) @resource.assign_attributes(attributes.slice(:url, :pdf, :identification)) end