Class: Braintree::CreditCard
- Inherits:
-
Object
- Object
- Braintree::CreditCard
- Includes:
- BaseModule, Util::TokenEquality
- Defined in:
- lib/braintree/credit_card.rb
Defined Under Namespace
Modules: CardType, CardTypeIndicator, CustomerLocation, DebitNetwork
Constant Summary collapse
- Business =
Commercial = Consumer = Corporate = CountryOfIssuance = Debit = DurbinRegulated = Healthcare = IssuingBank = Payroll = Prepaid = PrepaidReloadable = ProductId = Purchase = CardTypeIndicator
Instance Attribute Summary collapse
-
#billing_address ⇒ Object
readonly
Returns the value of attribute billing_address.
-
#bin ⇒ Object
readonly
Returns the value of attribute bin.
-
#business ⇒ Object
readonly
Returns the value of attribute business.
-
#card_type ⇒ Object
readonly
Returns the value of attribute card_type.
-
#cardholder_name ⇒ Object
readonly
Returns the value of attribute cardholder_name.
-
#commercial ⇒ Object
readonly
Returns the value of attribute commercial.
-
#consumer ⇒ Object
readonly
Returns the value of attribute consumer.
-
#corporate ⇒ Object
readonly
Returns the value of attribute corporate.
-
#country_of_issuance ⇒ Object
readonly
Returns the value of attribute country_of_issuance.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#customer_id ⇒ Object
readonly
Returns the value of attribute customer_id.
-
#debit ⇒ Object
readonly
Returns the value of attribute debit.
-
#durbin_regulated ⇒ Object
readonly
Returns the value of attribute durbin_regulated.
-
#expiration_month ⇒ Object
readonly
Returns the value of attribute expiration_month.
-
#expiration_year ⇒ Object
readonly
Returns the value of attribute expiration_year.
-
#healthcare ⇒ Object
readonly
Returns the value of attribute healthcare.
-
#image_url ⇒ Object
readonly
Returns the value of attribute image_url.
-
#issuing_bank ⇒ Object
readonly
Returns the value of attribute issuing_bank.
-
#last_4 ⇒ Object
readonly
Returns the value of attribute last_4.
-
#payroll ⇒ Object
readonly
Returns the value of attribute payroll.
-
#prepaid ⇒ Object
readonly
Returns the value of attribute prepaid.
-
#prepaid_reloadable ⇒ Object
readonly
Returns the value of attribute prepaid_reloadable.
-
#product_id ⇒ Object
readonly
Returns the value of attribute product_id.
-
#purchase ⇒ Object
readonly
Returns the value of attribute purchase.
-
#subscriptions ⇒ Object
readonly
Returns the value of attribute subscriptions.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#unique_number_identifier ⇒ Object
readonly
Returns the value of attribute unique_number_identifier.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#verification ⇒ Object
readonly
Returns the value of attribute verification.
Class Method Summary collapse
- ._attributes ⇒ Object
- ._new(*args) ⇒ Object
- .create(*args) ⇒ Object
- .create!(*args) ⇒ Object
-
.credit(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.credit has been deprecated in favor of Transaction.credit.
-
.credit!(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.credit has been deprecated in favor of Transaction.credit.
- .delete(*args) ⇒ Object
- .expired(*args) ⇒ Object
- .expiring_between(*args) ⇒ Object
- .find(*args) ⇒ Object
- .from_nonce(*args) ⇒ Object
-
.sale(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.sale has been deprecated in favor of Transaction.sale.
-
.sale!(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.sale has been deprecated in favor of Transaction.sale.
- .update(*args) ⇒ Object
- .update!(*args) ⇒ Object
Instance Method Summary collapse
- #_most_recent_verification(attributes) ⇒ Object
- #default? ⇒ Boolean
-
#expiration_date ⇒ Object
Expiration date formatted as MM/YYYY.
- #expired? ⇒ Boolean
-
#initialize(gateway, attributes) ⇒ CreditCard
constructor
A new instance of CreditCard.
- #inspect ⇒ Object
- #is_network_tokenized? ⇒ Boolean
- #masked_number ⇒ Object
- #nonce ⇒ Object
-
#venmo_sdk? ⇒ Boolean
NEXT_MAJOR_VERSION can this be removed? Venmo SDK integration is no more Returns true if the card is associated with Venmo SDK NEXT_MAJOR_VERSION Remove this method The old venmo SDK class has been deprecated.
Methods included from Util::TokenEquality
Methods included from BaseModule
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) ⇒ CreditCard
Returns a new instance of CreditCard.
146 147 148 149 150 151 152 |
# File 'lib/braintree/credit_card.rb', line 146 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_address ⇒ Object (readonly)
Returns the value of attribute billing_address.
52 53 54 |
# File 'lib/braintree/credit_card.rb', line 52 def billing_address @billing_address end |
#bin ⇒ Object (readonly)
Returns the value of attribute bin.
53 54 55 |
# File 'lib/braintree/credit_card.rb', line 53 def bin @bin end |
#business ⇒ Object (readonly)
Returns the value of attribute business.
54 55 56 |
# File 'lib/braintree/credit_card.rb', line 54 def business @business end |
#card_type ⇒ Object (readonly)
Returns the value of attribute card_type.
55 56 57 |
# File 'lib/braintree/credit_card.rb', line 55 def card_type @card_type end |
#cardholder_name ⇒ Object (readonly)
Returns the value of attribute cardholder_name.
56 57 58 |
# File 'lib/braintree/credit_card.rb', line 56 def cardholder_name @cardholder_name end |
#commercial ⇒ Object (readonly)
Returns the value of attribute commercial.
57 58 59 |
# File 'lib/braintree/credit_card.rb', line 57 def commercial @commercial end |
#consumer ⇒ Object (readonly)
Returns the value of attribute consumer.
58 59 60 |
# File 'lib/braintree/credit_card.rb', line 58 def consumer @consumer end |
#corporate ⇒ Object (readonly)
Returns the value of attribute corporate.
59 60 61 |
# File 'lib/braintree/credit_card.rb', line 59 def corporate @corporate end |
#country_of_issuance ⇒ Object (readonly)
Returns the value of attribute country_of_issuance.
60 61 62 |
# File 'lib/braintree/credit_card.rb', line 60 def country_of_issuance @country_of_issuance end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
61 62 63 |
# File 'lib/braintree/credit_card.rb', line 61 def created_at @created_at end |
#customer_id ⇒ Object (readonly)
Returns the value of attribute customer_id.
62 63 64 |
# File 'lib/braintree/credit_card.rb', line 62 def customer_id @customer_id end |
#debit ⇒ Object (readonly)
Returns the value of attribute debit.
63 64 65 |
# File 'lib/braintree/credit_card.rb', line 63 def debit @debit end |
#durbin_regulated ⇒ Object (readonly)
Returns the value of attribute durbin_regulated.
64 65 66 |
# File 'lib/braintree/credit_card.rb', line 64 def durbin_regulated @durbin_regulated end |
#expiration_month ⇒ Object (readonly)
Returns the value of attribute expiration_month.
65 66 67 |
# File 'lib/braintree/credit_card.rb', line 65 def expiration_month @expiration_month end |
#expiration_year ⇒ Object (readonly)
Returns the value of attribute expiration_year.
66 67 68 |
# File 'lib/braintree/credit_card.rb', line 66 def expiration_year @expiration_year end |
#healthcare ⇒ Object (readonly)
Returns the value of attribute healthcare.
67 68 69 |
# File 'lib/braintree/credit_card.rb', line 67 def healthcare @healthcare end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
68 69 70 |
# File 'lib/braintree/credit_card.rb', line 68 def image_url @image_url end |
#issuing_bank ⇒ Object (readonly)
Returns the value of attribute issuing_bank.
69 70 71 |
# File 'lib/braintree/credit_card.rb', line 69 def issuing_bank @issuing_bank end |
#last_4 ⇒ Object (readonly)
Returns the value of attribute last_4.
70 71 72 |
# File 'lib/braintree/credit_card.rb', line 70 def last_4 @last_4 end |
#payroll ⇒ Object (readonly)
Returns the value of attribute payroll.
71 72 73 |
# File 'lib/braintree/credit_card.rb', line 71 def payroll @payroll end |
#prepaid ⇒ Object (readonly)
Returns the value of attribute prepaid.
72 73 74 |
# File 'lib/braintree/credit_card.rb', line 72 def prepaid @prepaid end |
#prepaid_reloadable ⇒ Object (readonly)
Returns the value of attribute prepaid_reloadable.
73 74 75 |
# File 'lib/braintree/credit_card.rb', line 73 def prepaid_reloadable @prepaid_reloadable end |
#product_id ⇒ Object (readonly)
Returns the value of attribute product_id.
74 75 76 |
# File 'lib/braintree/credit_card.rb', line 74 def product_id @product_id end |
#purchase ⇒ Object (readonly)
Returns the value of attribute purchase.
75 76 77 |
# File 'lib/braintree/credit_card.rb', line 75 def purchase @purchase end |
#subscriptions ⇒ Object (readonly)
Returns the value of attribute subscriptions.
76 77 78 |
# File 'lib/braintree/credit_card.rb', line 76 def subscriptions @subscriptions end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
77 78 79 |
# File 'lib/braintree/credit_card.rb', line 77 def token @token end |
#unique_number_identifier ⇒ Object (readonly)
Returns the value of attribute unique_number_identifier.
78 79 80 |
# File 'lib/braintree/credit_card.rb', line 78 def unique_number_identifier @unique_number_identifier end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
79 80 81 |
# File 'lib/braintree/credit_card.rb', line 79 def updated_at @updated_at end |
#verification ⇒ Object (readonly)
Returns the value of attribute verification.
80 81 82 |
# File 'lib/braintree/credit_card.rb', line 80 def verification @verification end |
Class Method Details
._attributes ⇒ Object
206 207 208 209 210 211 212 213 |
# File 'lib/braintree/credit_card.rb', line 206 def self._attributes [ :billing_address, :bin, :business, :card_type, :cardholder_name, :commercial, :consumer, :corporate, :country_of_issuance, :created_at, :customer_id, :debit, :durbin_regulated, :expiration_month, :expiration_year, :healthcare, :image_url, :is_network_tokenized?, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable, :product_id, :purchase, :token, :updated_at ] end |
._new(*args) ⇒ Object
215 216 217 |
# File 'lib/braintree/credit_card.rb', line 215 def self._new(*args) self.new(*args) end |
.create(*args) ⇒ Object
82 83 84 |
# File 'lib/braintree/credit_card.rb', line 82 def self.create(*args) Configuration.gateway.credit_card.create(*args) end |
.create!(*args) ⇒ Object
86 87 88 |
# File 'lib/braintree/credit_card.rb', line 86 def self.create!(*args) Configuration.gateway.credit_card.create!(*args) end |
.credit(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.credit has been deprecated in favor of Transaction.credit
92 93 94 95 |
# File 'lib/braintree/credit_card.rb', line 92 def self.credit(token, transaction_attributes) warn "[DEPRECATED] CreditCard.credit is deprecated. Use Transaction.credit instead" Transaction.credit(transaction_attributes.merge(:payment_method_token => token)) end |
.credit!(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.credit has been deprecated in favor of Transaction.credit
99 100 101 102 |
# File 'lib/braintree/credit_card.rb', line 99 def self.credit!(token, transaction_attributes) warn "[DEPRECATED] CreditCard.credit is deprecated. Use Transaction.credit instead" return_object_or_raise(:transaction) { credit(token, transaction_attributes) } end |
.delete(*args) ⇒ Object
104 105 106 |
# File 'lib/braintree/credit_card.rb', line 104 def self.delete(*args) Configuration.gateway.credit_card.delete(*args) end |
.expired(*args) ⇒ Object
108 109 110 |
# File 'lib/braintree/credit_card.rb', line 108 def self.expired(*args) Configuration.gateway.credit_card.expired(*args) end |
.expiring_between(*args) ⇒ Object
112 113 114 |
# File 'lib/braintree/credit_card.rb', line 112 def self.expiring_between(*args) Configuration.gateway.credit_card.expiring_between(*args) end |
.find(*args) ⇒ Object
116 117 118 |
# File 'lib/braintree/credit_card.rb', line 116 def self.find(*args) Configuration.gateway.credit_card.find(*args) end |
.from_nonce(*args) ⇒ Object
120 121 122 |
# File 'lib/braintree/credit_card.rb', line 120 def self.from_nonce(*args) Configuration.gateway.credit_card.from_nonce(*args) end |
.sale(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.sale has been deprecated in favor of Transaction.sale
126 127 128 129 |
# File 'lib/braintree/credit_card.rb', line 126 def self.sale(token, transaction_attributes) warn "[DEPRECATED] CreditCard.sale is deprecated. Use Transaction.sale instead" Configuration.gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token)) end |
.sale!(token, transaction_attributes) ⇒ Object
NEXT_MAJOR_VERSION remove this method CreditCard.sale has been deprecated in favor of Transaction.sale
133 134 135 136 |
# File 'lib/braintree/credit_card.rb', line 133 def self.sale!(token, transaction_attributes) warn "[DEPRECATED] CreditCard.sale is deprecated. Use Transaction.sale instead" return_object_or_raise(:transaction) { sale(token, transaction_attributes) } end |
.update(*args) ⇒ Object
138 139 140 |
# File 'lib/braintree/credit_card.rb', line 138 def self.update(*args) Configuration.gateway.credit_card.update(*args) end |
.update!(*args) ⇒ Object
142 143 144 |
# File 'lib/braintree/credit_card.rb', line 142 def self.update!(*args) Configuration.gateway.credit_card.update!(*args) end |
Instance Method Details
#_most_recent_verification(attributes) ⇒ Object
154 155 156 157 |
# File 'lib/braintree/credit_card.rb', line 154 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
159 160 161 |
# File 'lib/braintree/credit_card.rb', line 159 def default? @default end |
#expiration_date ⇒ Object
Expiration date formatted as MM/YYYY
164 165 166 |
# File 'lib/braintree/credit_card.rb', line 164 def expiration_date "#{expiration_month}/#{expiration_year}" end |
#expired? ⇒ Boolean
168 169 170 |
# File 'lib/braintree/credit_card.rb', line 168 def expired? @expired end |
#inspect ⇒ Object
172 173 174 175 176 177 178 179 |
# File 'lib/braintree/credit_card.rb', line 172 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 |
#is_network_tokenized? ⇒ Boolean
198 199 200 |
# File 'lib/braintree/credit_card.rb', line 198 def is_network_tokenized? @is_network_tokenized end |
#masked_number ⇒ Object
181 182 183 |
# File 'lib/braintree/credit_card.rb', line 181 def masked_number "#{bin}******#{last_4}" end |
#nonce ⇒ Object
185 186 187 |
# File 'lib/braintree/credit_card.rb', line 185 def nonce @nonce ||= PaymentMethodNonce.create(token) end |
#venmo_sdk? ⇒ Boolean
NEXT_MAJOR_VERSION can this be removed? Venmo SDK integration is no more Returns true if the card is associated with Venmo SDK NEXT_MAJOR_VERSION Remove this method The old venmo SDK class has been deprecated
193 194 195 196 |
# File 'lib/braintree/credit_card.rb', line 193 def venmo_sdk? warn "[DEPRECATED] The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead." @venmo_sdk end |