class DidwwUps::CreditCard

Public Class Methods

new(attributes = {}, persisted = false) click to toggle source
Calls superclass method
# File lib/didww_ups/credit_card.rb, line 72
def initialize(attributes = {}, persisted = false)
  super attributes, persisted #check attributes keys
  if self['success'].to_i == 1
    @attributes['token_ref'] = self['result']
  else
    @attributes['error'] = self['result']
  end
end

Public Instance Methods

billing_address() click to toggle source

Billing Address

DidwwUps::CreditCard.new({:token_ref => "LQ8IQ4Av6hM3tgX_WLJp9w"}, true).get(:billing_address)
DidwwUps::CreditCard.find("LQ8IQ4Av6hM3tgX_WLJp9w").billing_address
# => GET "/api/rest/v1/credit_cards/LQ8IQ4Av6hM3tgX_WLJp9w/modules"
#  => "{\"bill_first_name\":\"FirstName\",\"bill_last_name\":\"SecondName\",\"city\":\"Odessa\",\"company\":\"\",\"country\":\"UA\",\"created_at\":\"2014-03-27T12:29:43Z\",\"email\":\"olga@gmail.com\",\"fax_number\":\"\",\"first_address_line\":\"Address line1\",\"id\":1070,\"phone_number\":\"3806600000000\",\"second_address_line\":\"Address line2\",\"state\":null,\"updated_at\":\"2014-03-27T12:29:43Z\",\"zip\":\"65007\",\"avs_result\":null}"
# File lib/didww_ups/credit_card.rb, line 107
def billing_address
  attribute_or_get! :billing_address
end
brand() click to toggle source
# File lib/didww_ups/credit_card.rb, line 124
def brand
  self[:credit_card_type]
end
create_payment(params={}) click to toggle source

create Payment ,

# File lib/didww_ups/credit_card.rb, line 114
def create_payment(params={})
  DidwwUps::Payment.create(params.merge({token_ref: self['token_ref']}))
end
display_name() click to toggle source
# File lib/didww_ups/credit_card.rb, line 128
def display_name
  "#{self.brand} #{self[:credit_card_number]}"
end
expired?() click to toggle source
# File lib/didww_ups/credit_card.rb, line 136
def expired?
  self[:credit_card_expired] < DateTime.now.utc.strftime("%Y-%d")
end
expired_this_month?() click to toggle source
# File lib/didww_ups/credit_card.rb, line 132
def expired_this_month?
  self[:credit_card_expired] == DateTime.now.utc.strftime("%Y-%d")
end
id()
Alias for: to_param
modules() click to toggle source

Payment Modules

DidwwUps::CreditCard.find("LQ8IQ4Av6hM3tgX_WLJp9w").get(:modules)
DidwwUps::CreditCard.find("LQ8IQ4Av6hM3tgX_WLJp9w").modules
# => GET "/api/rest/v1/credit_cards/LQ8IQ4Av6hM3tgX_WLJp9w/modules"
# => ["WorldnetTps"]
# File lib/didww_ups/credit_card.rb, line 96
def modules
  self[:modules] ||= self[:modules_tokens].present? ?
      self[:modules_tokens].collect { |t| t.module_name } :
      get(:modules)
end
properties() click to toggle source

Properties

DidwwUps::CreditCard.new({:token_ref => "LQ8IQ4Av6hM3tgX_WLJp9w"}, true).get(:properties)
DidwwUps::CreditCard.find("LQ8IQ4Av6hM3tgX_WLJp9w").properties
# => GET "/api/rest/v1/credit_cards/LQ8IQ4Av6hM3tgX_WLJp9w/properties"
# =>  {"bin"=>"510510", "bank"=>"BANK OF HAWAII", "country"=>"UNITED STATES", "card_brand"=>"MASTERCARD", "card_type"=>"CREDIT", "bank_phone"=>"1-888-643-3888 OR 1-888-643-9888", "customer_ip"=>"195.138.65.189", "fraud_level"=>nil}
# File lib/didww_ups/credit_card.rb, line 87
def properties
  attribute_or_get! :properties
end
to_param() click to toggle source
# File lib/didww_ups/credit_card.rb, line 118
def to_param
  token_ref
end
Also aliased as: id
updated_at() click to toggle source
# File lib/didww_ups/credit_card.rb, line 68
def updated_at
  Time.parse(self[:updated_at])
end

Protected Instance Methods

attribute_or_get!(name) click to toggle source
# File lib/didww_ups/credit_card.rb, line 145
def attribute_or_get!(name)
  if self.attributes.has_key? name
    return {} if  self[name].nil?
    self[name].is_a?(Hash) ? self[name] : self[name].try(:attributes)
  else
    self[name] = get(name)
  end
end
valid_callback_hash() click to toggle source
# File lib/didww_ups/credit_card.rb, line 141
def valid_callback_hash
  Digest::SHA1.hexdigest "#{self['result']}#{self['success']}#{self['customer_id']}#{self['card_id']}#{self['date_time']}#{DidwwUps.current_store['api_secret_key']}"
end