Sha256: 1673003bd4eafb011e822f755475cc25838d8cc37af3355168de1de9bfab54b8

Contents?: true

Size: 1.33 KB

Versions: 15

Compression:

Stored size: 1.33 KB

Contents

module VaultedBilling
  ##
  # 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).
  #
  class Customer
    attr_accessor :email # Optional email address for the customer.
    attr_accessor :merchant_id # Optional custom identifier for the customer (i.e. your database key).
    attr_accessor :vault_id # Gateway generated unique identifier for this customer in their system.

    ##
    # You can mass assign the attributes by passing a hash with keys
    # matching attributes of the Customer:
    #
    #     Customer.new(:merchant_id => 1)
    #
    def initialize(attributes = {})
      attributes = HashWithIndifferentAccess.new(attributes)
      @vault_id = attributes[:vault_id]
      @merchant_id = attributes[:merchant_id]
      @email = attributes[:email]
    end

    def to_vaulted_billing; self; end

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vaulted_billing-1.4.0 lib/vaulted_billing/customer.rb
vaulted_billing-1.3.1 lib/vaulted_billing/customer.rb
vaulted_billing-1.3.0 lib/vaulted_billing/customer.rb
vaulted_billing-1.2.1 lib/vaulted_billing/customer.rb
vaulted_billing-1.2.0 lib/vaulted_billing/customer.rb
vaulted_billing-1.1.6 lib/vaulted_billing/customer.rb
vaulted_billing-1.1.5 lib/vaulted_billing/customer.rb
vaulted_billing-1.1.4 lib/vaulted_billing/customer.rb
vaulted_billing-1.1.3 lib/vaulted_billing/customer.rb
vaulted_billing-1.1.2 lib/vaulted_billing/customer.rb
vaulted_billing-1.1.0 lib/vaulted_billing/customer.rb
vaulted_billing-1.0.2 lib/vaulted_billing/customer.rb
vaulted_billing-1.0.1 lib/vaulted_billing/customer.rb
vaulted_billing-1.0.0 lib/vaulted_billing/customer.rb
vaulted_billing-0.0.15 lib/vaulted_billing/customer.rb