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
- Commercial =
CountryOfIssuance = Debit = DurbinRegulated = Healthcare = IssuingBank = Payroll = Prepaid = PrepaidReloadable = ProductId = 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.
-
#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.
-
#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.
-
#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.
141 142 143 144 145 146 147 |
# File 'lib/braintree/credit_card.rb', line 141 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.
51 52 53 |
# File 'lib/braintree/credit_card.rb', line 51 def billing_address @billing_address end |
#bin ⇒ Object (readonly)
Returns the value of attribute bin.
52 53 54 |
# File 'lib/braintree/credit_card.rb', line 52 def bin @bin end |
#card_type ⇒ Object (readonly)
Returns the value of attribute card_type.
53 54 55 |
# File 'lib/braintree/credit_card.rb', line 53 def card_type @card_type end |
#cardholder_name ⇒ Object (readonly)
Returns the value of attribute cardholder_name.
54 55 56 |
# File 'lib/braintree/credit_card.rb', line 54 def cardholder_name @cardholder_name end |
#commercial ⇒ Object (readonly)
Returns the value of attribute commercial.
55 56 57 |
# File 'lib/braintree/credit_card.rb', line 55 def commercial @commercial end |
#country_of_issuance ⇒ Object (readonly)
Returns the value of attribute country_of_issuance.
56 57 58 |
# File 'lib/braintree/credit_card.rb', line 56 def country_of_issuance @country_of_issuance end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
57 58 59 |
# File 'lib/braintree/credit_card.rb', line 57 def created_at @created_at end |
#customer_id ⇒ Object (readonly)
Returns the value of attribute customer_id.
58 59 60 |
# File 'lib/braintree/credit_card.rb', line 58 def customer_id @customer_id end |
#debit ⇒ Object (readonly)
Returns the value of attribute debit.
59 60 61 |
# File 'lib/braintree/credit_card.rb', line 59 def debit @debit end |
#durbin_regulated ⇒ Object (readonly)
Returns the value of attribute durbin_regulated.
60 61 62 |
# File 'lib/braintree/credit_card.rb', line 60 def durbin_regulated @durbin_regulated end |
#expiration_month ⇒ Object (readonly)
Returns the value of attribute expiration_month.
61 62 63 |
# File 'lib/braintree/credit_card.rb', line 61 def expiration_month @expiration_month end |
#expiration_year ⇒ Object (readonly)
Returns the value of attribute expiration_year.
62 63 64 |
# File 'lib/braintree/credit_card.rb', line 62 def expiration_year @expiration_year end |
#healthcare ⇒ Object (readonly)
Returns the value of attribute healthcare.
63 64 65 |
# File 'lib/braintree/credit_card.rb', line 63 def healthcare @healthcare end |
#image_url ⇒ Object (readonly)
Returns the value of attribute image_url.
64 65 66 |
# File 'lib/braintree/credit_card.rb', line 64 def image_url @image_url end |
#issuing_bank ⇒ Object (readonly)
Returns the value of attribute issuing_bank.
65 66 67 |
# File 'lib/braintree/credit_card.rb', line 65 def issuing_bank @issuing_bank end |
#last_4 ⇒ Object (readonly)
Returns the value of attribute last_4.
66 67 68 |
# File 'lib/braintree/credit_card.rb', line 66 def last_4 @last_4 end |
#payroll ⇒ Object (readonly)
Returns the value of attribute payroll.
67 68 69 |
# File 'lib/braintree/credit_card.rb', line 67 def payroll @payroll end |
#prepaid ⇒ Object (readonly)
Returns the value of attribute prepaid.
68 69 70 |
# File 'lib/braintree/credit_card.rb', line 68 def prepaid @prepaid end |
#prepaid_reloadable ⇒ Object (readonly)
Returns the value of attribute prepaid_reloadable.
69 70 71 |
# File 'lib/braintree/credit_card.rb', line 69 def prepaid_reloadable @prepaid_reloadable end |
#product_id ⇒ Object (readonly)
Returns the value of attribute product_id.
70 71 72 |
# File 'lib/braintree/credit_card.rb', line 70 def product_id @product_id end |
#subscriptions ⇒ Object (readonly)
Returns the value of attribute subscriptions.
71 72 73 |
# File 'lib/braintree/credit_card.rb', line 71 def subscriptions @subscriptions end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
72 73 74 |
# File 'lib/braintree/credit_card.rb', line 72 def token @token end |
#unique_number_identifier ⇒ Object (readonly)
Returns the value of attribute unique_number_identifier.
73 74 75 |
# File 'lib/braintree/credit_card.rb', line 73 def unique_number_identifier @unique_number_identifier end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
74 75 76 |
# File 'lib/braintree/credit_card.rb', line 74 def updated_at @updated_at end |
#verification ⇒ Object (readonly)
Returns the value of attribute verification.
75 76 77 |
# File 'lib/braintree/credit_card.rb', line 75 def verification @verification end |
Class Method Details
._attributes ⇒ Object
201 202 203 204 205 206 207 |
# File 'lib/braintree/credit_card.rb', line 201 def self._attributes [ :billing_address, :bin, :card_type, :cardholder_name, :commercial, :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, :token, :updated_at ] end |
._new(*args) ⇒ Object
209 210 211 |
# File 'lib/braintree/credit_card.rb', line 209 def self._new(*args) self.new(*args) end |
.create(*args) ⇒ Object
77 78 79 |
# File 'lib/braintree/credit_card.rb', line 77 def self.create(*args) Configuration.gateway.credit_card.create(*args) end |
.create!(*args) ⇒ Object
81 82 83 |
# File 'lib/braintree/credit_card.rb', line 81 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
87 88 89 90 |
# File 'lib/braintree/credit_card.rb', line 87 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
94 95 96 97 |
# File 'lib/braintree/credit_card.rb', line 94 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
99 100 101 |
# File 'lib/braintree/credit_card.rb', line 99 def self.delete(*args) Configuration.gateway.credit_card.delete(*args) end |
.expired(*args) ⇒ Object
103 104 105 |
# File 'lib/braintree/credit_card.rb', line 103 def self.expired(*args) Configuration.gateway.credit_card.expired(*args) end |
.expiring_between(*args) ⇒ Object
107 108 109 |
# File 'lib/braintree/credit_card.rb', line 107 def self.expiring_between(*args) Configuration.gateway.credit_card.expiring_between(*args) end |
.find(*args) ⇒ Object
111 112 113 |
# File 'lib/braintree/credit_card.rb', line 111 def self.find(*args) Configuration.gateway.credit_card.find(*args) end |
.from_nonce(*args) ⇒ Object
115 116 117 |
# File 'lib/braintree/credit_card.rb', line 115 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
121 122 123 124 |
# File 'lib/braintree/credit_card.rb', line 121 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
128 129 130 131 |
# File 'lib/braintree/credit_card.rb', line 128 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
133 134 135 |
# File 'lib/braintree/credit_card.rb', line 133 def self.update(*args) Configuration.gateway.credit_card.update(*args) end |
.update!(*args) ⇒ Object
137 138 139 |
# File 'lib/braintree/credit_card.rb', line 137 def self.update!(*args) Configuration.gateway.credit_card.update!(*args) end |
Instance Method Details
#_most_recent_verification(attributes) ⇒ Object
149 150 151 152 |
# File 'lib/braintree/credit_card.rb', line 149 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
154 155 156 |
# File 'lib/braintree/credit_card.rb', line 154 def default? @default end |
#expiration_date ⇒ Object
Expiration date formatted as MM/YYYY
159 160 161 |
# File 'lib/braintree/credit_card.rb', line 159 def expiration_date "#{expiration_month}/#{expiration_year}" end |
#expired? ⇒ Boolean
163 164 165 |
# File 'lib/braintree/credit_card.rb', line 163 def expired? @expired end |
#inspect ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'lib/braintree/credit_card.rb', line 167 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
193 194 195 |
# File 'lib/braintree/credit_card.rb', line 193 def is_network_tokenized? @is_network_tokenized end |
#masked_number ⇒ Object
176 177 178 |
# File 'lib/braintree/credit_card.rb', line 176 def masked_number "#{bin}******#{last_4}" end |
#nonce ⇒ Object
180 181 182 |
# File 'lib/braintree/credit_card.rb', line 180 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
188 189 190 191 |
# File 'lib/braintree/credit_card.rb', line 188 def venmo_sdk? warn "[DEPRECATED] The Venmo SDK integration is Unsupported. Please update your integration to use Pay with Venmo instead." @venmo_sdk end |