Class: Braintree::Transaction
- Inherits:
-
Object
- Object
- Braintree::Transaction
- Includes:
- BaseModule
- Defined in:
- lib/braintree/transaction.rb,
lib/braintree/transaction/status_details.rb,
lib/braintree/transaction/address_details.rb,
lib/braintree/transaction/customer_details.rb,
lib/braintree/transaction/credit_card_details.rb,
lib/braintree/transaction/subscription_details.rb
Overview
Defined Under Namespace
Modules: CreatedUsing, GatewayRejectionReason, Source, Status, Type Classes: AddressDetails, CreditCardDetails, CustomerDetails, StatusDetails, SubscriptionDetails
Instance Attribute Summary (collapse)
-
- (Object) add_ons
readonly
Returns the value of attribute add_ons.
-
- (Object) amount
readonly
Returns the value of attribute amount.
-
- (Object) avs_error_response_code
readonly
Returns the value of attribute avs_error_response_code.
-
- (Object) avs_postal_code_response_code
readonly
Returns the value of attribute avs_postal_code_response_code.
-
- (Object) avs_street_address_response_code
readonly
Returns the value of attribute avs_street_address_response_code.
-
- (Object) billing_details
readonly
Returns the value of attribute billing_details.
-
- (Object) created_at
readonly
Returns the value of attribute created_at.
-
- (Object) credit_card_details
readonly
Returns the value of attribute credit_card_details.
-
- (Object) currency_iso_code
readonly
Returns the value of attribute currency_iso_code.
-
- (Object) custom_fields
readonly
Returns the value of attribute custom_fields.
-
- (Object) customer_details
readonly
Returns the value of attribute customer_details.
-
- (Object) cvv_response_code
readonly
Returns the value of attribute cvv_response_code.
-
- (Object) descriptor
readonly
Returns the value of attribute descriptor.
-
- (Object) discounts
readonly
Returns the value of attribute discounts.
-
- (Object) gateway_rejection_reason
readonly
Returns the value of attribute gateway_rejection_reason.
-
- (Object) id
readonly
Returns the value of attribute id.
-
- (Object) merchant_account_id
readonly
Returns the value of attribute merchant_account_id.
-
- (Object) order_id
readonly
Returns the value of attribute order_id.
-
- (Object) processor_authorization_code
readonly
The authorization code from the processor.
-
- (Object) processor_response_code
readonly
The response code from the processor.
-
- (Object) processor_response_text
readonly
The response text from the processor.
-
- (Object) purchase_order_number
readonly
Returns the value of attribute purchase_order_number.
-
- (Object) refund_ids
readonly
Returns the value of attribute refund_ids.
-
- (Object) refunded_transaction_id
readonly
Returns the value of attribute refunded_transaction_id.
-
- (Object) settlement_batch_id
readonly
Returns the value of attribute settlement_batch_id.
-
- (Object) shipping_details
readonly
Returns the value of attribute shipping_details.
-
- (Object) status
readonly
See Transaction::Status.
-
- (Object) status_history
readonly
Returns the value of attribute status_history.
-
- (Object) subscription_details
readonly
Returns the value of attribute subscription_details.
-
- (Object) subscription_id
readonly
Returns the value of attribute subscription_id.
-
- (Object) tax_amount
readonly
Returns the value of attribute tax_amount.
-
- (Object) tax_exempt
readonly
Returns the value of attribute tax_exempt.
-
- (Object) type
readonly
Will either be "sale" or "credit".
-
- (Object) updated_at
readonly
Returns the value of attribute updated_at.
Class Method Summary (collapse)
-
+ (Object) _attributes
:nodoc:.
-
+ (Object) _new(*args)
:nodoc:.
- + (Object) create(attributes)
- + (Object) create!(attributes)
-
+ (Object) create_from_transparent_redirect(query_string)
Deprecated.
-
+ (Object) create_transaction_url
Deprecated.
- + (Object) credit(attributes)
- + (Object) credit!(attributes)
- + (Object) find(id)
- + (Object) refund(id, amount = nil)
- + (Object) sale(attributes)
- + (Object) sale!(attributes)
- + (Object) search(&block)
- + (Object) submit_for_settlement(transaction_id, amount = nil)
- + (Object) submit_for_settlement!(transaction_id, amount = nil)
- + (Object) void(transaction_id)
- + (Object) void!(transaction_id)
Instance Method Summary (collapse)
-
- (Object) ==(other)
True if other is a Braintree::Transaction with the same id.
-
- (Transaction) initialize(gateway, attributes)
constructor
:nodoc:.
-
- (Object) inspect
:nodoc:.
-
- (Object) refund(amount = nil)
Deprecated.
- - (Object) refund_id
-
- (Boolean) refunded?
Returns true if the transaction has been refunded.
-
- (Object) submit_for_settlement(amount = nil)
Deprecated.
-
- (Object) submit_for_settlement!(amount = nil)
Deprecated.
-
- (Object) vault_billing_address
If this transaction was stored in the vault, or created from vault records, vault_billing_address will return the associated Braintree::Address.
-
- (Object) vault_credit_card
If this transaction was stored in the vault, or created from vault records, vault_credit_card will return the associated Braintree::CreditCard.
-
- (Object) vault_customer
If this transaction was stored in the vault, or created from vault records, vault_customer will return the associated Braintree::Customer.
-
- (Object) vault_shipping_address
If this transaction was stored in the vault, or created from vault records, vault_shipping_address will return the associated Braintree::Address.
-
- (Object) void
Deprecated.
-
- (Object) void!
Deprecated.
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
- (Transaction) initialize(gateway, attributes)
:nodoc:
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/braintree/transaction.rb', line 153 def initialize(gateway, attributes) # :nodoc: @gateway = gateway set_instance_variables_from_hash(attributes) @amount = Util.to_big_decimal(amount) @credit_card_details = CreditCardDetails.new(@credit_card) @subscription_details = SubscriptionDetails.new(@subscription) @customer_details = CustomerDetails.new(@customer) @billing_details = AddressDetails.new(@billing) @shipping_details = AddressDetails.new(@shipping) @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : [] @tax_amount = Util.to_big_decimal(tax_amount) @descriptor = Descriptor.new(@descriptor) add_ons.map! { |attrs| AddOn._new(attrs) } if add_ons discounts.map! { |attrs| Discount._new(attrs) } if discounts end |
Instance Attribute Details
- (Object) add_ons (readonly)
Returns the value of attribute add_ons
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def add_ons @add_ons end |
- (Object) amount (readonly)
Returns the value of attribute amount
45 46 47 |
# File 'lib/braintree/transaction.rb', line 45 def amount @amount end |
- (Object) avs_error_response_code (readonly)
Returns the value of attribute avs_error_response_code
44 45 46 |
# File 'lib/braintree/transaction.rb', line 44 def avs_error_response_code @avs_error_response_code end |
- (Object) avs_postal_code_response_code (readonly)
Returns the value of attribute avs_postal_code_response_code
44 45 46 |
# File 'lib/braintree/transaction.rb', line 44 def avs_postal_code_response_code @avs_postal_code_response_code end |
- (Object) avs_street_address_response_code (readonly)
Returns the value of attribute avs_street_address_response_code
44 45 46 |
# File 'lib/braintree/transaction.rb', line 44 def avs_street_address_response_code @avs_street_address_response_code end |
- (Object) billing_details (readonly)
Returns the value of attribute billing_details
53 54 55 |
# File 'lib/braintree/transaction.rb', line 53 def billing_details @billing_details end |
- (Object) created_at (readonly)
Returns the value of attribute created_at
45 46 47 |
# File 'lib/braintree/transaction.rb', line 45 def created_at @created_at end |
- (Object) credit_card_details (readonly)
Returns the value of attribute credit_card_details
45 46 47 |
# File 'lib/braintree/transaction.rb', line 45 def credit_card_details @credit_card_details end |
- (Object) currency_iso_code (readonly)
Returns the value of attribute currency_iso_code
46 47 48 |
# File 'lib/braintree/transaction.rb', line 46 def currency_iso_code @currency_iso_code end |
- (Object) custom_fields (readonly)
Returns the value of attribute custom_fields
47 48 49 |
# File 'lib/braintree/transaction.rb', line 47 def custom_fields @custom_fields end |
- (Object) customer_details (readonly)
Returns the value of attribute customer_details
45 46 47 |
# File 'lib/braintree/transaction.rb', line 45 def customer_details @customer_details end |
- (Object) cvv_response_code (readonly)
Returns the value of attribute cvv_response_code
48 49 50 |
# File 'lib/braintree/transaction.rb', line 48 def cvv_response_code @cvv_response_code end |
- (Object) descriptor (readonly)
Returns the value of attribute descriptor
49 50 51 |
# File 'lib/braintree/transaction.rb', line 49 def descriptor @descriptor end |
- (Object) discounts (readonly)
Returns the value of attribute discounts
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def discounts @discounts end |
- (Object) gateway_rejection_reason (readonly)
Returns the value of attribute gateway_rejection_reason
50 51 52 |
# File 'lib/braintree/transaction.rb', line 50 def gateway_rejection_reason @gateway_rejection_reason end |
- (Object) id (readonly)
Returns the value of attribute id
45 46 47 |
# File 'lib/braintree/transaction.rb', line 45 def id @id end |
- (Object) merchant_account_id (readonly)
Returns the value of attribute merchant_account_id
51 52 53 |
# File 'lib/braintree/transaction.rb', line 51 def merchant_account_id @merchant_account_id end |
- (Object) order_id (readonly)
Returns the value of attribute order_id
52 53 54 |
# File 'lib/braintree/transaction.rb', line 52 def order_id @order_id end |
- (Object) processor_authorization_code (readonly)
The authorization code from the processor.
55 56 57 |
# File 'lib/braintree/transaction.rb', line 55 def @processor_authorization_code end |
- (Object) processor_response_code (readonly)
The response code from the processor.
57 58 59 |
# File 'lib/braintree/transaction.rb', line 57 def processor_response_code @processor_response_code end |
- (Object) processor_response_text (readonly)
The response text from the processor.
59 60 61 |
# File 'lib/braintree/transaction.rb', line 59 def processor_response_text @processor_response_text end |
- (Object) purchase_order_number (readonly)
Returns the value of attribute purchase_order_number
60 61 62 |
# File 'lib/braintree/transaction.rb', line 60 def purchase_order_number @purchase_order_number end |
- (Object) refund_ids (readonly)
Returns the value of attribute refund_ids
61 62 63 |
# File 'lib/braintree/transaction.rb', line 61 def refund_ids @refund_ids end |
- (Object) refunded_transaction_id (readonly)
Returns the value of attribute refunded_transaction_id
61 62 63 |
# File 'lib/braintree/transaction.rb', line 61 def refunded_transaction_id @refunded_transaction_id end |
- (Object) settlement_batch_id (readonly)
Returns the value of attribute settlement_batch_id
62 63 64 |
# File 'lib/braintree/transaction.rb', line 62 def settlement_batch_id @settlement_batch_id end |
- (Object) shipping_details (readonly)
Returns the value of attribute shipping_details
53 54 55 |
# File 'lib/braintree/transaction.rb', line 53 def shipping_details @shipping_details end |
- (Object) status (readonly)
See Transaction::Status
64 65 66 |
# File 'lib/braintree/transaction.rb', line 64 def status @status end |
- (Object) status_history (readonly)
Returns the value of attribute status_history
65 66 67 |
# File 'lib/braintree/transaction.rb', line 65 def status_history @status_history end |
- (Object) subscription_details (readonly)
Returns the value of attribute subscription_details
45 46 47 |
# File 'lib/braintree/transaction.rb', line 45 def subscription_details @subscription_details end |
- (Object) subscription_id (readonly)
Returns the value of attribute subscription_id
66 67 68 |
# File 'lib/braintree/transaction.rb', line 66 def subscription_id @subscription_id end |
- (Object) tax_amount (readonly)
Returns the value of attribute tax_amount
67 68 69 |
# File 'lib/braintree/transaction.rb', line 67 def tax_amount @tax_amount end |
- (Object) tax_exempt (readonly)
Returns the value of attribute tax_exempt
68 69 70 |
# File 'lib/braintree/transaction.rb', line 68 def tax_exempt @tax_exempt end |
- (Object) type (readonly)
Will either be "sale" or "credit"
70 71 72 |
# File 'lib/braintree/transaction.rb', line 70 def type @type end |
- (Object) updated_at (readonly)
Returns the value of attribute updated_at
71 72 73 |
# File 'lib/braintree/transaction.rb', line 71 def updated_at @updated_at end |
Class Method Details
+ (Object) _attributes
:nodoc:
295 296 297 |
# File 'lib/braintree/transaction.rb', line 295 def self._attributes # :nodoc: [:amount, :created_at, :credit_card_details, :customer_details, :id, :status, :subscription_details, :type, :updated_at] end |
+ (Object) _new(*args)
:nodoc:
290 291 292 |
# File 'lib/braintree/transaction.rb', line 290 def _new(*args) # :nodoc: self.new *args end |
+ (Object) create(attributes)
75 76 77 |
# File 'lib/braintree/transaction.rb', line 75 def self.create(attributes) Configuration.gateway.transaction.create(attributes) end |
+ (Object) create!(attributes)
80 81 82 |
# File 'lib/braintree/transaction.rb', line 80 def self.create!(attributes) return_object_or_raise(:transaction) { create(attributes) } end |
+ (Object) create_from_transparent_redirect(query_string)
Deprecated. Use Braintree::TransparentRedirect.confirm
See www.braintreepayments.com/docs/ruby/transactions/create_tr
87 88 89 90 |
# File 'lib/braintree/transaction.rb', line 87 def self.create_from_transparent_redirect(query_string) warn "[DEPRECATED] Transaction.create_from_transparent_redirect is deprecated. Please use TransparentRedirect.confirm" Configuration.gateway.transaction.create_from_transparent_redirect(query_string) end |
+ (Object) create_transaction_url
Deprecated. Use Braintree::TransparentRedirect.url
See www.braintreepayments.com/docs/ruby/transactions/create_tr
95 96 97 98 |
# File 'lib/braintree/transaction.rb', line 95 def self.create_transaction_url warn "[DEPRECATED] Transaction.create_transaction_url is deprecated. Please use TransparentRedirect.url" Configuration.gateway.transaction.create_transaction_url end |
+ (Object) credit(attributes)
100 101 102 |
# File 'lib/braintree/transaction.rb', line 100 def self.credit(attributes) Configuration.gateway.transaction.credit(attributes) end |
+ (Object) credit!(attributes)
104 105 106 |
# File 'lib/braintree/transaction.rb', line 104 def self.credit!(attributes) return_object_or_raise(:transaction) { credit(attributes) } end |
+ (Object) find(id)
109 110 111 |
# File 'lib/braintree/transaction.rb', line 109 def self.find(id) Configuration.gateway.transaction.find(id) end |
+ (Object) refund(id, amount = nil)
114 115 116 |
# File 'lib/braintree/transaction.rb', line 114 def self.refund(id, amount = nil) Configuration.gateway.transaction.refund(id, amount) end |
+ (Object) sale(attributes)
119 120 121 |
# File 'lib/braintree/transaction.rb', line 119 def self.sale(attributes) Configuration.gateway.transaction.sale(attributes) end |
+ (Object) sale!(attributes)
124 125 126 |
# File 'lib/braintree/transaction.rb', line 124 def self.sale!(attributes) return_object_or_raise(:transaction) { sale(attributes) } end |
+ (Object) search(&block)
129 130 131 |
# File 'lib/braintree/transaction.rb', line 129 def self.search(&block) Configuration.gateway.transaction.search(&block) end |
+ (Object) submit_for_settlement(transaction_id, amount = nil)
134 135 136 |
# File 'lib/braintree/transaction.rb', line 134 def self.submit_for_settlement(transaction_id, amount = nil) Configuration.gateway.transaction.submit_for_settlement(transaction_id, amount) end |
+ (Object) submit_for_settlement!(transaction_id, amount = nil)
139 140 141 |
# File 'lib/braintree/transaction.rb', line 139 def self.submit_for_settlement!(transaction_id, amount = nil) return_object_or_raise(:transaction) { submit_for_settlement(transaction_id, amount) } end |
+ (Object) void(transaction_id)
144 145 146 |
# File 'lib/braintree/transaction.rb', line 144 def self.void(transaction_id) Configuration.gateway.transaction.void(transaction_id) end |
+ (Object) void!(transaction_id)
149 150 151 |
# File 'lib/braintree/transaction.rb', line 149 def self.void!(transaction_id) return_object_or_raise(:transaction) { void(transaction_id) } end |
Instance Method Details
- (Object) ==(other)
True if other is a Braintree::Transaction with the same id.
170 171 172 173 |
# File 'lib/braintree/transaction.rb', line 170 def ==(other) return false unless other.is_a?(Transaction) id == other.id end |
- (Object) inspect
:nodoc:
175 176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/braintree/transaction.rb', line 175 def inspect # :nodoc: first = [:id, :type, :amount, :status] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| if attr == :amount self.amount ? "amount: #{self.amount.to_s("F").inspect}" : "amount: nil" else "#{attr}: #{send(attr).inspect}" end end "#<#{self.class} #{nice_attributes.join(', ')}>" end |
- (Object) refund(amount = nil)
Deprecated. Use Braintree::Transaction.refund
191 192 193 194 195 196 197 198 199 200 |
# File 'lib/braintree/transaction.rb', line 191 def refund(amount = nil) warn "[DEPRECATED] refund as an instance method is deprecated. Please use Transaction.refund" result = @gateway.transaction.refund(id, amount) if result.success? SuccessfulResult.new(:new_transaction => result.transaction) else result end end |
- (Object) refund_id
207 208 209 210 |
# File 'lib/braintree/transaction.rb', line 207 def refund_id warn "[DEPRECATED] Transaction.refund_id is deprecated. Please use TransparentRedirect.refund_ids" @refund_id end |
- (Boolean) refunded?
Returns true if the transaction has been refunded. False otherwise.
203 204 205 |
# File 'lib/braintree/transaction.rb', line 203 def refunded? !@refund_id.nil? end |
- (Object) submit_for_settlement(amount = nil)
Deprecated. Use Braintree::Transaction.submit_for_settlement
See www.braintreepayments.com/docs/ruby/transactions/submit_for_settlement
215 216 217 218 219 220 221 222 |
# File 'lib/braintree/transaction.rb', line 215 def submit_for_settlement(amount = nil) warn "[DEPRECATED] submit_for_settlement as an instance method is deprecated. Please use Transaction.submit_for_settlement" result = @gateway.transaction.submit_for_settlement(id, amount) if result.success? copy_instance_variables_from_object result.transaction end result end |
- (Object) submit_for_settlement!(amount = nil)
Deprecated. Use Braintree::Transaction.submit_for_settlement!
See www.braintreepayments.com/docs/ruby/transactions/submit_for_settlement
227 228 229 230 |
# File 'lib/braintree/transaction.rb', line 227 def submit_for_settlement!(amount = nil) warn "[DEPRECATED] submit_for_settlement! as an instance method is deprecated. Please use Transaction.submit_for_settlement!" return_object_or_raise(:transaction) { submit_for_settlement(amount) } end |
- (Object) vault_billing_address
If this transaction was stored in the vault, or created from vault records, vault_billing_address will return the associated Braintree::Address. Because the vault billing address can be updated after the transaction was created, the attributes on vault_billing_address may not match the attributes on billing_details.
236 237 238 239 |
# File 'lib/braintree/transaction.rb', line 236 def vault_billing_address return nil if billing_details.id.nil? @gateway.address.find(customer_details.id, billing_details.id) end |
- (Object) vault_credit_card
If this transaction was stored in the vault, or created from vault records, vault_credit_card will return the associated Braintree::CreditCard. Because the vault credit card can be updated after the transaction was created, the attributes on vault_credit_card may not match the attributes on credit_card_details.
245 246 247 248 |
# File 'lib/braintree/transaction.rb', line 245 def vault_credit_card return nil if credit_card_details.token.nil? @gateway.credit_card.find(credit_card_details.token) end |
- (Object) vault_customer
If this transaction was stored in the vault, or created from vault records, vault_customer will return the associated Braintree::Customer. Because the vault customer can be updated after the transaction was created, the attributes on vault_customer may not match the attributes on customer_details.
254 255 256 257 |
# File 'lib/braintree/transaction.rb', line 254 def vault_customer return nil if customer_details.id.nil? @gateway.customer.find(customer_details.id) end |
- (Object) vault_shipping_address
If this transaction was stored in the vault, or created from vault records, vault_shipping_address will return the associated Braintree::Address. Because the vault shipping address can be updated after the transaction was created, the attributes on vault_shipping_address may not match the attributes on shipping_details.
263 264 265 266 |
# File 'lib/braintree/transaction.rb', line 263 def vault_shipping_address return nil if shipping_details.id.nil? @gateway.address.find(customer_details.id, shipping_details.id) end |
- (Object) void
Deprecated. Use Braintree::Transaction.void
271 272 273 274 275 276 277 278 |
# File 'lib/braintree/transaction.rb', line 271 def void warn "[DEPRECATED] void as an instance method is deprecated. Please use Transaction.void" result = @gateway.transaction.void(id) if result.success? copy_instance_variables_from_object result.transaction end result end |
- (Object) void!
Deprecated. Use Braintree::Transaction.void!
283 284 285 286 |
# File 'lib/braintree/transaction.rb', line 283 def void! warn "[DEPRECATED] void! as an instance method is deprecated. Please use Transaction.void!" return_object_or_raise(:transaction) { void } end |