class Braintree::Transaction
Attributes
Public Class Methods
# File lib/braintree/transaction.rb, line 435 def self._attributes [:amount, :created_at, :credit_card_details, :customer_details, :id, :status, :subscription_details, :type, :updated_at, :processed_with_network_token?] end
# File lib/braintree/transaction.rb, line 430 def _new(*args) self.new(*args) end
# File lib/braintree/transaction.rb, line 204 def self.cancel_release(*args) Configuration.gateway.transaction.cancel_release(*args) end
# File lib/braintree/transaction.rb, line 208 def self.cancel_release!(*args) Configuration.gateway.transaction.cancel_release!(*args) end
# File lib/braintree/transaction.rb, line 212 def self.clone_transaction(*args) Configuration.gateway.transaction.clone_transaction(*args) end
# File lib/braintree/transaction.rb, line 216 def self.clone_transaction!(*args) Configuration.gateway.transaction.clone_transaction!(*args) end
# File lib/braintree/transaction.rb, line 196 def self.create(*args) Configuration.gateway.transaction.create(*args) end
# File lib/braintree/transaction.rb, line 200 def self.create!(*args) return_object_or_raise(:transaction) { create(*args) } end
# File lib/braintree/transaction.rb, line 220 def self.credit(*args) Configuration.gateway.transaction.credit(*args) end
# File lib/braintree/transaction.rb, line 224 def self.credit!(*args) Configuration.gateway.transaction.credit!(*args) end
# File lib/braintree/transaction.rb, line 228 def self.find(*args) Configuration.gateway.transaction.find(*args) end
# File lib/braintree/transaction.rb, line 236 def self.hold_in_escrow(*args) Configuration.gateway.transaction.hold_in_escrow(*args) end
# File lib/braintree/transaction.rb, line 240 def self.hold_in_escrow!(*args) Configuration.gateway.transaction.hold_in_escrow!(*args) end
# File lib/braintree/transaction.rb, line 232 def self.line_items(*args) Configuration.gateway.transaction_line_item.find_all(*args) end
# File lib/braintree/transaction.rb, line 288 def self.package_tracking(*args) Configuration.gateway.transaction.package_tracking(*args) end
# File lib/braintree/transaction.rb, line 292 def self.package_tracking!(*args) Configuration.gateway.transaction.package_tracking!(*args) end
# File lib/braintree/transaction.rb, line 244 def self.refund(*args) Configuration.gateway.transaction.refund(*args) end
# File lib/braintree/transaction.rb, line 248 def self.refund!(*args) Configuration.gateway.transaction.refund!(*args) end
# File lib/braintree/transaction.rb, line 264 def self.release_from_escrow(*args) Configuration.gateway.transaction.release_from_escrow(*args) end
# File lib/braintree/transaction.rb, line 268 def self.release_from_escrow!(*args) Configuration.gateway.transaction.release_from_escrow!(*args) end
# File lib/braintree/transaction.rb, line 252 def self.sale(*args) Configuration.gateway.transaction.sale(*args) end
# File lib/braintree/transaction.rb, line 256 def self.sale!(*args) Configuration.gateway.transaction.sale!(*args) end
# File lib/braintree/transaction.rb, line 260 def self.search(&block) Configuration.gateway.transaction.search(&block) end
# File lib/braintree/transaction.rb, line 296 def self.submit_for_partial_settlement(*args) Configuration.gateway.transaction.submit_for_partial_settlement(*args) end
# File lib/braintree/transaction.rb, line 300 def self.submit_for_partial_settlement!(*args) Configuration.gateway.transaction.submit_for_partial_settlement!(*args) end
# File lib/braintree/transaction.rb, line 272 def self.submit_for_settlement(*args) Configuration.gateway.transaction.submit_for_settlement(*args) end
# File lib/braintree/transaction.rb, line 276 def self.submit_for_settlement!(*args) Configuration.gateway.transaction.submit_for_settlement!(*args) end
# File lib/braintree/transaction.rb, line 280 def self.update_details(*args) Configuration.gateway.transaction.update_details(*args) end
# File lib/braintree/transaction.rb, line 284 def self.update_details!(*args) return_object_or_raise(:transaction) { update_details(*args) } end
# File lib/braintree/transaction.rb, line 304 def self.void(*args) Configuration.gateway.transaction.void(*args) end
# File lib/braintree/transaction.rb, line 308 def self.void!(*args) Configuration.gateway.transaction.void!(*args) end
Protected Class Methods
# File lib/braintree/transaction.rb, line 312 def initialize(gateway, attributes) @gateway = gateway set_instance_variables_from_hash(attributes) @amount = Util.to_big_decimal(amount) @apple_pay_details = ApplePayDetails.new(@apple_pay) @billing_details = AddressDetails.new(@billing) @credit_card_details = CreditCardDetails.new(@credit_card) @network_token_details = CreditCardDetails.new(@network_token) @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {} @customer_details = CustomerDetails.new(@customer) @descriptor = Descriptor.new(@descriptor) @disbursement_details = DisbursementDetails.new(@disbursement_details) @google_pay_details = GooglePayDetails.new(@google_pay_card) @local_payment_details = LocalPaymentDetails.new(@local_payment) @meta_checkout_card_details = MetaCheckoutCardDetails.new(attributes[:meta_checkout_card]) @meta_checkout_token_details = MetaCheckoutTokenDetails.new(attributes[:meta_checkout_token]) @payment_instrument_type = attributes[:payment_instrument_type] @payment_receipt = PaymentReceipt.new(attributes[:payment_receipt]) if attributes[:payment_receipt] @paypal_details = PayPalDetails.new(@paypal) @paypal_here_details = PayPalHereDetails.new(@paypal_here) @samsung_pay_card_details = SamsungPayCardDetails.new(attributes[:samsung_pay_card]) @sca_exemption_requested = attributes[:sca_exemption_requested] @sepa_direct_debit_account_details = SepaDirectDebitAccountDetails.new(@sepa_debit_account_detail) @service_fee_amount = Util.to_big_decimal(service_fee_amount) @packages = attributes[:shipments] ? attributes[:shipments].map { |pd| PackageDetails.new(pd) } : [] @shipping_details = AddressDetails.new(@shipping) @status_history = attributes[:status_history] ? attributes[:status_history].map { |s| StatusDetails.new(s) } : [] @subscription_details = SubscriptionDetails.new(@subscription) @tax_amount = Util.to_big_decimal(tax_amount) @venmo_account_details = VenmoAccountDetails.new(@venmo_account) @visa_checkout_card_details = VisaCheckoutCardDetails.new(attributes[:visa_checkout_card]) @facilitated_details = FacilitatedDetails.new(attributes[:facilitated_details]) if attributes[:facilitated_details] @facilitator_details = FacilitatorDetails.new(attributes[:facilitator_details]) if attributes[:facilitator_details] @risk_data = RiskData.new(attributes[:risk_data]) if attributes[:risk_data] @three_d_secure_info = ThreeDSecureInfo.new(attributes[:three_d_secure_info]) if attributes[:three_d_secure_info] @us_bank_account_details = UsBankAccountDetails.new(attributes[:us_bank_account]) if attributes[:us_bank_account] add_ons.map! { |attrs| AddOn._new(attrs) } if add_ons authorization_adjustments.map! { |attrs| AuthorizationAdjustment._new(attrs) } if authorization_adjustments discounts.map! { |attrs| Discount._new(attrs) } if discounts disputes.map! { |attrs| Dispute._new(attrs) } if disputes installments.map! { |attrs| Installment.new(attrs) } if installments refunded_installments.map! { |attrs| Installment.new(attrs) } if refunded_installments end
Public Instance Methods
# File lib/braintree/transaction.rb, line 380 def disbursed? @disbursement_details.valid? end
# File lib/braintree/transaction.rb, line 359 def inspect first = [:id, :type, :amount, :status] order = first + (self.class._attributes - first) nice_attributes = order.map do |attr| if attr == :amount Util.inspect_amount(self.amount) else "#{attr}: #{send(attr).inspect}" end end "#<#{self.class} #{nice_attributes.join(', ')}>" end
# File lib/braintree/transaction.rb, line 372 def line_items @gateway.transaction_line_item.find_all(id) end
# File lib/braintree/transaction.rb, line 424 def processed_with_network_token? @processed_with_network_token end
# File lib/braintree/transaction.rb, line 376 def refunded? !@refund_id.nil? end
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. NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove
# File lib/braintree/transaction.rb, line 389 def vault_billing_address return nil if billing_details.id.nil? @gateway.address.find(customer_details.id, billing_details.id) end
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. NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove
# File lib/braintree/transaction.rb, line 399 def vault_credit_card return nil if credit_card_details.token.nil? @gateway.credit_card.find(credit_card_details.token) end
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. NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove
# File lib/braintree/transaction.rb, line 409 def vault_customer return nil if customer_details.id.nil? @gateway.customer.find(customer_details.id) end
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. NEXT_MAJOR_VERSION these methods are not documented in the developer docs, remove
# File lib/braintree/transaction.rb, line 419 def vault_shipping_address return nil if shipping_details.id.nil? @gateway.address.find(customer_details.id, shipping_details.id) end