class Braintree::Customer
Attributes
addresses[R]
apple_pay_cards[R]
company[R]
created_at[R]
credit_cards[R]
custom_fields[R]
email[R]
fax[R]
first_name[R]
google_pay_cards[R]
graphql_id[R]
id[R]
international_phone[R]
last_name[R]
paypal_accounts[R]
phone[R]
samsung_pay_cards[R]
sepa_direct_debit_accounts[R]
tax_identifiers[R]
updated_at[R]
us_bank_accounts[R]
venmo_accounts[R]
visa_checkout_cards[R]
website[R]
Public Class Methods
_attributes()
click to toggle source
# File lib/braintree/customer.rb, line 151 def self._attributes [ :addresses, :company, :credit_cards, :email, :fax, :first_name, :id, :international_phone, :last_name, :phone, :website, :created_at, :updated_at, :tax_identifiers ] end
_new(*args)
click to toggle source
# File lib/braintree/customer.rb, line 147 def self._new(*args) self.new(*args) end
_now_timestamp()
click to toggle source
# File lib/braintree/customer.rb, line 158 def self._now_timestamp Time.now.to_i end
all()
click to toggle source
# File lib/braintree/customer.rb, line 31 def self.all Configuration.gateway.customer.all end
create(*args)
click to toggle source
# File lib/braintree/customer.rb, line 35 def self.create(*args) Configuration.gateway.customer.create(*args) end
create!(*args)
click to toggle source
# File lib/braintree/customer.rb, line 39 def self.create!(*args) Configuration.gateway.customer.create!(*args) end
credit(customer_id, transaction_attributes)
click to toggle source
# File lib/braintree/customer.rb, line 43 def self.credit(customer_id, transaction_attributes) Transaction.credit(transaction_attributes.merge(:customer_id => customer_id)) end
credit!(customer_id, transaction_attributes)
click to toggle source
# File lib/braintree/customer.rb, line 47 def self.credit!(customer_id, transaction_attributes) return_object_or_raise(:transaction) { credit(customer_id, transaction_attributes) } end
delete(*args)
click to toggle source
# File lib/braintree/customer.rb, line 51 def self.delete(*args) Configuration.gateway.customer.delete(*args) end
find(*args)
click to toggle source
# File lib/braintree/customer.rb, line 55 def self.find(*args) Configuration.gateway.customer.find(*args) end
sale(customer_id, transaction_attributes)
click to toggle source
# File lib/braintree/customer.rb, line 59 def self.sale(customer_id, transaction_attributes) Transaction.sale(transaction_attributes.merge(:customer_id => customer_id)) end
sale!(customer_id, transaction_attributes)
click to toggle source
# File lib/braintree/customer.rb, line 63 def self.sale!(customer_id, transaction_attributes) return_object_or_raise(:transaction) { sale(customer_id, transaction_attributes) } end
search(&block)
click to toggle source
# File lib/braintree/customer.rb, line 67 def self.search(&block) Configuration.gateway.customer.search(&block) end
transactions(*args)
click to toggle source
# File lib/braintree/customer.rb, line 71 def self.transactions(*args) Configuration.gateway.customer.transactions(*args) end
update(*args)
click to toggle source
# File lib/braintree/customer.rb, line 75 def self.update(*args) Configuration.gateway.customer.update(*args) end
update!(*args)
click to toggle source
# File lib/braintree/customer.rb, line 79 def self.update!(*args) Configuration.gateway.customer.update!(*args) end
Protected Class Methods
new(gateway, attributes)
click to toggle source
NEXT_MAJOR_VERSION remove samsung_pay_cards
# File lib/braintree/customer.rb, line 84 def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @credit_cards = (@credit_cards || []).map { |pm| CreditCard._new gateway, pm } @paypal_accounts = (@paypal_accounts || []).map { |pm| PayPalAccount._new gateway, pm } @apple_pay_cards = (@apple_pay_cards || []).map { |pm| ApplePayCard._new gateway, pm } @google_pay_cards = (@google_pay_cards || []).map { |pm| GooglePayCard._new gateway, pm } @venmo_accounts = (@venmo_accounts || []).map { |pm| VenmoAccount._new gateway, pm } @us_bank_accounts = (@us_bank_accounts || []).map { |pm| UsBankAccount._new gateway, pm } @visa_checkout_cards = (@visa_checkout_cards|| []).map { |pm| VisaCheckoutCard._new gateway, pm } @sepa_direct_debit_accounts = (@sepa_debit_accounts || []).map { |pm| SepaDirectDebitAccount._new gateway, pm } @samsung_pay_cards = (@samsung_pay_cards|| []).map { |pm| SamsungPayCard._new gateway, pm } # Deprecated @addresses = (@addresses || []).map { |addr| Address._new gateway, addr } @tax_identifiers = (@tax_identifiers || []).map { |addr| TaxIdentifier._new gateway, addr } @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {} end
Public Instance Methods
credit(transaction_attributes)
click to toggle source
# File lib/braintree/customer.rb, line 101 def credit(transaction_attributes) @gateway.transaction.credit(transaction_attributes.merge(:customer_id => id)) end
credit!(transaction_attributes)
click to toggle source
# File lib/braintree/customer.rb, line 105 def credit!(transaction_attributes) return_object_or_raise(:transaction) { credit(transaction_attributes) } end
default_payment_method()
click to toggle source
# File lib/braintree/customer.rb, line 109 def default_payment_method payment_methods.find { |payment_instrument| payment_instrument.default? } end
delete()
click to toggle source
# File lib/braintree/customer.rb, line 113 def delete @gateway.customer.delete(id) end
inspect()
click to toggle source
# File lib/braintree/customer.rb, line 129 def inspect first = [:id] last = [:addresses, :credit_cards, :paypal_accounts, :tax_identifiers] order = first + (self.class._attributes - first - last) + last nice_attributes = order.map do |attr| "#{attr}: #{send(attr).inspect}" end "#<#{self.class} #{nice_attributes.join(', ')}>" end
payment_methods()
click to toggle source
# File lib/braintree/customer.rb, line 117 def payment_methods @credit_cards + @paypal_accounts + @apple_pay_cards + @google_pay_cards + @venmo_accounts + @us_bank_accounts + @visa_checkout_cards + @samsung_pay_cards + @sepa_direct_debit_accounts end
transactions(options = {})
click to toggle source
# File lib/braintree/customer.rb, line 139 def transactions(options = {}) @gateway.customer.transactions(id, options) end