Class: Braintree::VisaCheckoutCard

Inherits:
Object
  • Object
show all
Includes:
BaseModule, Util::TokenEquality
Defined in:
lib/braintree/visa_checkout_card.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util::TokenEquality

#==

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(gateway, attributes) ⇒ VisaCheckoutCard

Returns a new instance of VisaCheckoutCard.



33
34
35
36
37
38
39
# File 'lib/braintree/visa_checkout_card.rb', line 33

def initialize(gateway, attributes)
  @gateway = gateway
  set_instance_variables_from_hash(attributes)
  @billing_address = attributes[:billing_address] ? Address._new(@gateway, attributes[:billing_address]) : nil
  @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
  @verification = _most_recent_verification(attributes)
end

Instance Attribute Details

#billing_addressObject (readonly)

Returns the value of attribute billing_address.



6
7
8
# File 'lib/braintree/visa_checkout_card.rb', line 6

def billing_address
  @billing_address
end

#binObject (readonly)

Returns the value of attribute bin.



7
8
9
# File 'lib/braintree/visa_checkout_card.rb', line 7

def bin
  @bin
end

#call_idObject (readonly)

Returns the value of attribute call_id.



8
9
10
# File 'lib/braintree/visa_checkout_card.rb', line 8

def call_id
  @call_id
end

#card_typeObject (readonly)

Returns the value of attribute card_type.



9
10
11
# File 'lib/braintree/visa_checkout_card.rb', line 9

def card_type
  @card_type
end

#cardholder_nameObject (readonly)

Returns the value of attribute cardholder_name.



10
11
12
# File 'lib/braintree/visa_checkout_card.rb', line 10

def cardholder_name
  @cardholder_name
end

#commercialObject (readonly)

Returns the value of attribute commercial.



11
12
13
# File 'lib/braintree/visa_checkout_card.rb', line 11

def commercial
  @commercial
end

#country_of_issuanceObject (readonly)

Returns the value of attribute country_of_issuance.



12
13
14
# File 'lib/braintree/visa_checkout_card.rb', line 12

def country_of_issuance
  @country_of_issuance
end

#created_atObject (readonly)

Returns the value of attribute created_at.



13
14
15
# File 'lib/braintree/visa_checkout_card.rb', line 13

def created_at
  @created_at
end

#customer_idObject (readonly)

Returns the value of attribute customer_id.



14
15
16
# File 'lib/braintree/visa_checkout_card.rb', line 14

def customer_id
  @customer_id
end

#customer_locationObject (readonly)

Returns the value of attribute customer_location.



15
16
17
# File 'lib/braintree/visa_checkout_card.rb', line 15

def customer_location
  @customer_location
end

#debitObject (readonly)

Returns the value of attribute debit.



16
17
18
# File 'lib/braintree/visa_checkout_card.rb', line 16

def debit
  @debit
end

#durbin_regulatedObject (readonly)

Returns the value of attribute durbin_regulated.



17
18
19
# File 'lib/braintree/visa_checkout_card.rb', line 17

def durbin_regulated
  @durbin_regulated
end

#expiration_monthObject (readonly)

Returns the value of attribute expiration_month.



18
19
20
# File 'lib/braintree/visa_checkout_card.rb', line 18

def expiration_month
  @expiration_month
end

#expiration_yearObject (readonly)

Returns the value of attribute expiration_year.



19
20
21
# File 'lib/braintree/visa_checkout_card.rb', line 19

def expiration_year
  @expiration_year
end

#healthcareObject (readonly)

Returns the value of attribute healthcare.



20
21
22
# File 'lib/braintree/visa_checkout_card.rb', line 20

def healthcare
  @healthcare
end

#image_urlObject (readonly)

Returns the value of attribute image_url.



21
22
23
# File 'lib/braintree/visa_checkout_card.rb', line 21

def image_url
  @image_url
end

#issuing_bankObject (readonly)

Returns the value of attribute issuing_bank.



22
23
24
# File 'lib/braintree/visa_checkout_card.rb', line 22

def issuing_bank
  @issuing_bank
end

#last_4Object (readonly)

Returns the value of attribute last_4.



23
24
25
# File 'lib/braintree/visa_checkout_card.rb', line 23

def last_4
  @last_4
end

#payrollObject (readonly)

Returns the value of attribute payroll.



24
25
26
# File 'lib/braintree/visa_checkout_card.rb', line 24

def payroll
  @payroll
end

#prepaidObject (readonly)

Returns the value of attribute prepaid.



25
26
27
# File 'lib/braintree/visa_checkout_card.rb', line 25

def prepaid
  @prepaid
end

#product_idObject (readonly)

Returns the value of attribute product_id.



26
27
28
# File 'lib/braintree/visa_checkout_card.rb', line 26

def product_id
  @product_id
end

#subscriptionsObject (readonly)

Returns the value of attribute subscriptions.



27
28
29
# File 'lib/braintree/visa_checkout_card.rb', line 27

def subscriptions
  @subscriptions
end

#tokenObject (readonly)

Returns the value of attribute token.



28
29
30
# File 'lib/braintree/visa_checkout_card.rb', line 28

def token
  @token
end

#unique_number_identifierObject (readonly)

Returns the value of attribute unique_number_identifier.



29
30
31
# File 'lib/braintree/visa_checkout_card.rb', line 29

def unique_number_identifier
  @unique_number_identifier
end

#updated_atObject (readonly)

Returns the value of attribute updated_at.



30
31
32
# File 'lib/braintree/visa_checkout_card.rb', line 30

def updated_at
  @updated_at
end

#verificationObject (readonly)

Returns the value of attribute verification.



31
32
33
# File 'lib/braintree/visa_checkout_card.rb', line 31

def verification
  @verification
end

Class Method Details

._attributesObject



76
77
78
79
80
81
82
83
84
# File 'lib/braintree/visa_checkout_card.rb', line 76

def self._attributes
  [
    :billing_address, :bin, :card_type, :cardholder_name, :created_at,
    :customer_id, :customer_location, :expiration_month, :expiration_year,
    :last_4, :token, :updated_at, :prepaid, :payroll, :product_id,
    :commercial, :debit, :durbin_regulated, :healthcare,
    :country_of_issuance, :issuing_bank, :image_url, :call_id
  ]
end

._new(*args) ⇒ Object



86
87
88
# File 'lib/braintree/visa_checkout_card.rb', line 86

def self._new(*args)
  self.new(*args)
end

Instance Method Details

#_most_recent_verification(attributes) ⇒ Object



41
42
43
44
# File 'lib/braintree/visa_checkout_card.rb', line 41

def _most_recent_verification(attributes)
  sorted_verifications = (attributes[:verifications] || []).sort_by { |verification| verification[:created_at] }.reverse.first
  CreditCardVerification._new(sorted_verifications) if sorted_verifications
end

#default?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/braintree/visa_checkout_card.rb', line 46

def default?
  @default
end

#expiration_dateObject

Expiration date formatted as MM/YYYY



51
52
53
# File 'lib/braintree/visa_checkout_card.rb', line 51

def expiration_date
  "#{expiration_month}/#{expiration_year}"
end

#expired?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/braintree/visa_checkout_card.rb', line 55

def expired?
  @expired
end

#inspectObject



59
60
61
62
63
64
65
66
# File 'lib/braintree/visa_checkout_card.rb', line 59

def inspect
  first = [:token]
  order = first + (self.class._attributes - first)
  nice_attributes = order.map do |attr|
    "#{attr}: #{send(attr).inspect}"
  end
  "#<#{self.class} #{nice_attributes.join(', ')}>"
end

#masked_numberObject



68
69
70
# File 'lib/braintree/visa_checkout_card.rb', line 68

def masked_number
  "#{bin}******#{last_4}"
end