Class: Jackpot::Customer

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/jackpot/customer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credit_card_verification_valueObject

Returns the value of attribute credit_card_verification_value.



16
17
18
# File 'app/models/jackpot/customer.rb', line 16

def credit_card_verification_value
  @credit_card_verification_value
end

Instance Method Details

#expiration_dateObject



43
44
45
# File 'app/models/jackpot/customer.rb', line 43

def expiration_date
  "#{credit_card_expiry_month}/#{credit_card_expiry_year}"
end

#pay_subscriptionObject



18
19
20
21
22
23
24
25
26
# File 'app/models/jackpot/customer.rb', line 18

def pay_subscription
  if credit_card_token   
    if subscription.charge(self)
      update_attribute(:good_until, Date.today + 1.month)
    end 
  else 
    raise Jackpot::Errors::CustomerHasNoCardSaved.new
  end 
end

#update_credit_card(card) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/jackpot/customer.rb', line 29

def update_credit_card(card)  
  raise Errors::CardIsInvalid unless card.valid? 
  write_attribute  :credit_card_number            ,  card.masquerade_number
  write_attribute  :credit_card_expiry_month      ,  card.month
  write_attribute  :credit_card_expiry_year       ,  card.year

  # This should never be recorded 
  self.credit_card_verification_value = card.verification_value
  stored_card_response = Jackpot::Payment.gateway.store(card)
  write_attribute :credit_card_token , stored_card_response.params["customer_vault_id"]

  save
end