Class: VaultedBilling::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/vaulted_billing/customer.rb

Overview

An intermediary object for VaultedBilling which represents a single customer on the gateway.

Many gateways support you in defining multiple credit cards or payment methods under a single customer object. To support this, they will generate one identifier for the top-level customer, and then separate identifiers for each payment method (see VaultedBilling::CreditCard).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Customer

You can mass assign the attributes by passing a hash with keys matching attributes of the Customer:

Customer.new(:merchant_id => 1)


22
23
24
25
26
27
# File 'lib/vaulted_billing/customer.rb', line 22

def initialize(attributes = {})
  attributes = HashWithIndifferentAccess.new(attributes)
  @vault_id = attributes[:vault_id]
  @merchant_id = attributes[:merchant_id]
  @email = attributes[:email]
end

Instance Attribute Details

#emailObject

Optional email address for the customer.



12
13
14
# File 'lib/vaulted_billing/customer.rb', line 12

def email
  @email
end

#merchant_idObject

Optional custom identifier for the customer (i.e. your database key).



13
14
15
# File 'lib/vaulted_billing/customer.rb', line 13

def merchant_id
  @merchant_id
end

#vault_idObject

Gateway generated unique identifier for this customer in their system.



14
15
16
# File 'lib/vaulted_billing/customer.rb', line 14

def vault_id
  @vault_id
end

Instance Method Details

#==(o) ⇒ Object



31
32
33
# File 'lib/vaulted_billing/customer.rb', line 31

def ==(o)
  self.attributes == o.attributes
end

#attributesObject



35
36
37
38
39
40
41
# File 'lib/vaulted_billing/customer.rb', line 35

def attributes
  {
    :vault_id => vault_id,
    :merchant_id => merchant_id,
    :email => email
  }
end

#to_vaulted_billingObject



29
# File 'lib/vaulted_billing/customer.rb', line 29

def to_vaulted_billing; self; end