class JeraPayment::Services::Iugu::CreditCards::Create
Public Instance Methods
call()
click to toggle source
# File lib/jera_payment/services/iugu/credit_cards/create.rb, line 6 def call credit_card_token = create_credit_card_token add_error(credit_card_token[:errors]) and return false if credit_card_token[:errors].present? set_payment_token_attributes(credit_card_token) link_credit_card_response = link_credit_card(credit_card_token[:id]) add_error(link_credit_card_response[:errors]) and return false if link_credit_card_response[:errors].present? @resource.api_id = link_credit_card_response[:id] end
Private Instance Methods
create_credit_card_token()
click to toggle source
# File lib/jera_payment/services/iugu/credit_cards/create.rb, line 21 def create_credit_card_token JeraPayment::Api::Iugu::PaymentToken.create(JeraPayment::Parsers::Iugu::CreditCardParser.parse_payment_token(@resource), @resource.customer&.sub_account&.api_token) end
link_credit_card(credit_card_token_id)
click to toggle source
# File lib/jera_payment/services/iugu/credit_cards/create.rb, line 30 def link_credit_card(credit_card_token_id) eval("JeraPayment::Api::Iugu::PaymentMethod.create(@resource.customer.api_id, JeraPayment::Parsers::Iugu::CreditCardParser.parse_payment_method(@resource, credit_card_token_id), @resource.customer&.sub_account&.api_token)") end
set_payment_token_attributes(credit_card_token)
click to toggle source
# File lib/jera_payment/services/iugu/credit_cards/create.rb, line 26 def set_payment_token_attributes(credit_card_token) @resource.assign_attributes(brand: credit_card_token[:extra_info][:brand], number: credit_card_token[:extra_info][:display_number], cvv: nil) end