Class: Braintree::Transaction
- Inherits:
-
Object
- Object
- Braintree::Transaction
- Includes:
- BaseModule
- Defined in:
- lib/braintree/transaction.rb,
lib/braintree/transaction/paypal_details.rb,
lib/braintree/transaction/status_details.rb,
lib/braintree/transaction/address_details.rb,
lib/braintree/transaction/coinbase_details.rb,
lib/braintree/transaction/customer_details.rb,
lib/braintree/transaction/apple_pay_details.rb,
lib/braintree/transaction/android_pay_details.rb,
lib/braintree/transaction/credit_card_details.rb,
lib/braintree/transaction/disbursement_details.rb,
lib/braintree/transaction/subscription_details.rb
Direct Known Subclasses
Defined Under Namespace
Modules: CreatedUsing, EscrowStatus, GatewayRejectionReason, IndustryType, Source, Status, Type Classes: AddressDetails, AndroidPayDetails, ApplePayDetails, CoinbaseDetails, CreditCardDetails, CustomerDetails, DisbursementDetails, PayPalDetails, StatusDetails, SubscriptionDetails
Instance Attribute Summary collapse
-
#add_ons ⇒ Object
readonly
Returns the value of attribute add_ons.
-
#additional_processor_response ⇒ Object
readonly
The raw response from the processor.
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#android_pay_details ⇒ Object
readonly
Returns the value of attribute android_pay_details.
-
#apple_pay_details ⇒ Object
readonly
Returns the value of attribute apple_pay_details.
-
#avs_error_response_code ⇒ Object
readonly
Returns the value of attribute avs_error_response_code.
-
#avs_postal_code_response_code ⇒ Object
readonly
Returns the value of attribute avs_postal_code_response_code.
-
#avs_street_address_response_code ⇒ Object
readonly
Returns the value of attribute avs_street_address_response_code.
-
#billing_details ⇒ Object
readonly
Returns the value of attribute billing_details.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#coinbase_details ⇒ Object
readonly
Returns the value of attribute coinbase_details.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#credit_card_details ⇒ Object
readonly
Returns the value of attribute credit_card_details.
-
#currency_iso_code ⇒ Object
readonly
Returns the value of attribute currency_iso_code.
-
#custom_fields ⇒ Object
readonly
Returns the value of attribute custom_fields.
-
#customer_details ⇒ Object
readonly
Returns the value of attribute customer_details.
-
#cvv_response_code ⇒ Object
readonly
Returns the value of attribute cvv_response_code.
-
#descriptor ⇒ Object
readonly
Returns the value of attribute descriptor.
-
#disbursement_details ⇒ Object
readonly
Returns the value of attribute disbursement_details.
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
-
#disputes ⇒ Object
readonly
Returns the value of attribute disputes.
-
#escrow_status ⇒ Object
readonly
Returns the value of attribute escrow_status.
-
#gateway_rejection_reason ⇒ Object
readonly
Returns the value of attribute gateway_rejection_reason.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#merchant_account_id ⇒ Object
readonly
Returns the value of attribute merchant_account_id.
-
#order_id ⇒ Object
readonly
Returns the value of attribute order_id.
-
#payment_instrument_type ⇒ Object
readonly
Returns the value of attribute payment_instrument_type.
-
#paypal_details ⇒ Object
readonly
Returns the value of attribute paypal_details.
-
#plan_id ⇒ Object
readonly
Returns the value of attribute plan_id.
-
#processor_authorization_code ⇒ Object
readonly
The authorization code from the processor.
-
#processor_response_code ⇒ Object
readonly
The response code from the processor.
-
#processor_response_text ⇒ Object
readonly
The response text from the processor.
-
#processor_settlement_response_code ⇒ Object
readonly
The settlement response code from the processor.
-
#processor_settlement_response_text ⇒ Object
readonly
The settlement response text from the processor.
-
#purchase_order_number ⇒ Object
readonly
Returns the value of attribute purchase_order_number.
-
#recurring ⇒ Object
readonly
Returns the value of attribute recurring.
-
#refund_ids ⇒ Object
readonly
Returns the value of attribute refund_ids.
-
#refunded_transaction_id ⇒ Object
readonly
Returns the value of attribute refunded_transaction_id.
-
#risk_data ⇒ Object
readonly
Returns the value of attribute risk_data.
-
#service_fee_amount ⇒ Object
readonly
Returns the value of attribute service_fee_amount.
-
#settlement_batch_id ⇒ Object
readonly
Returns the value of attribute settlement_batch_id.
-
#shipping_details ⇒ Object
readonly
Returns the value of attribute shipping_details.
-
#status ⇒ Object
readonly
See Transaction::Status.
-
#status_history ⇒ Object
readonly
Returns the value of attribute status_history.
-
#subscription_details ⇒ Object
readonly
Returns the value of attribute subscription_details.
-
#subscription_id ⇒ Object
readonly
Returns the value of attribute subscription_id.
-
#tax_amount ⇒ Object
readonly
Returns the value of attribute tax_amount.
-
#tax_exempt ⇒ Object
readonly
Returns the value of attribute tax_exempt.
-
#three_d_secure_info ⇒ Object
readonly
Returns the value of attribute three_d_secure_info.
-
#type ⇒ Object
readonly
Will either be “sale” or “credit”.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#voice_referral_number ⇒ Object
readonly
Returns the value of attribute voice_referral_number.
Class Method Summary collapse
-
._attributes ⇒ Object
:nodoc:.
-
._new(*args) ⇒ Object
:nodoc:.
- .cancel_release(transaction_id) ⇒ Object
- .cancel_release!(transaction_id) ⇒ Object
- .clone_transaction(transaction_id, attributes) ⇒ Object
- .clone_transaction!(transaction_id, attributes) ⇒ Object
- .create(attributes) ⇒ Object
- .create!(attributes) ⇒ Object
-
.create_from_transparent_redirect(query_string) ⇒ Object
Deprecated.
-
.create_transaction_url ⇒ Object
Deprecated.
- .credit(attributes) ⇒ Object
- .credit!(attributes) ⇒ Object
- .find(id) ⇒ Object
- .hold_in_escrow(id) ⇒ Object
- .hold_in_escrow!(id) ⇒ Object
- .refund(id, amount = nil) ⇒ Object
- .refund!(id, amount = nil) ⇒ Object
- .release_from_escrow(transaction_id) ⇒ Object
- .release_from_escrow!(transaction_id) ⇒ 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) ⇒ Object
Instance Method Summary collapse
-
#==(other) ⇒ Object
True if
otheris a Braintree::Transaction with the same id. -
#disbursed? ⇒ Boolean
Returns true if the transaction has been disbursed.
-
#initialize(gateway, attributes) ⇒ Transaction
constructor
:nodoc:.
-
#inspect ⇒ Object
:nodoc:.
-
#refund(amount = nil) ⇒ Object
Deprecated.
- #refund_id ⇒ Object
-
#refunded? ⇒ Boolean
Returns true if the transaction has been refunded.
-
#submit_for_settlement(amount = nil) ⇒ Object
Deprecated.
-
#submit_for_settlement!(amount = nil) ⇒ Object
Deprecated.
-
#vault_billing_address ⇒ Object
If this transaction was stored in the vault, or created from vault records, vault_billing_address will return the associated Braintree::Address.
-
#vault_credit_card ⇒ Object
If this transaction was stored in the vault, or created from vault records, vault_credit_card will return the associated Braintree::CreditCard.
-
#vault_customer ⇒ Object
If this transaction was stored in the vault, or created from vault records, vault_customer will return the associated Braintree::Customer.
-
#vault_shipping_address ⇒ Object
If this transaction was stored in the vault, or created from vault records, vault_shipping_address will return the associated Braintree::Address.
-
#void ⇒ Object
Deprecated.
-
#void! ⇒ Object
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
#initialize(gateway, attributes) ⇒ Transaction
:nodoc:
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
# File 'lib/braintree/transaction.rb', line 221 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) @service_fee_amount = Util.to_big_decimal(service_fee_amount) @subscription_details = SubscriptionDetails.new(@subscription) @customer_details = CustomerDetails.new(@customer) @billing_details = AddressDetails.new(@billing) @disbursement_details = DisbursementDetails.new(@disbursement_details) @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) @paypal_details = PayPalDetails.new(@paypal) @apple_pay_details = ApplePayDetails.new(@apple_pay) @android_pay_details = AndroidPayDetails.new(@android_pay_card) @coinbase_details = CoinbaseDetails.new(@coinbase_account) disputes.map! { |attrs| Dispute._new(attrs) } if disputes @custom_fields = attributes[:custom_fields].is_a?(Hash) ? attributes[:custom_fields] : {} add_ons.map! { |attrs| AddOn._new(attrs) } if add_ons discounts.map! { |attrs| Discount._new(attrs) } if discounts @payment_instrument_type = attributes[:payment_instrument_type] @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] end |
Instance Attribute Details
#add_ons ⇒ Object (readonly)
Returns the value of attribute add_ons.
116 117 118 |
# File 'lib/braintree/transaction.rb', line 116 def add_ons @add_ons end |
#additional_processor_response ⇒ Object (readonly)
The raw response from the processor.
97 98 99 |
# File 'lib/braintree/transaction.rb', line 97 def additional_processor_response @additional_processor_response end |
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def amount @amount end |
#android_pay_details ⇒ Object (readonly)
Returns the value of attribute android_pay_details.
87 88 89 |
# File 'lib/braintree/transaction.rb', line 87 def android_pay_details @android_pay_details end |
#apple_pay_details ⇒ Object (readonly)
Returns the value of attribute apple_pay_details.
86 87 88 |
# File 'lib/braintree/transaction.rb', line 86 def apple_pay_details @apple_pay_details end |
#avs_error_response_code ⇒ Object (readonly)
Returns the value of attribute avs_error_response_code.
71 72 73 |
# File 'lib/braintree/transaction.rb', line 71 def avs_error_response_code @avs_error_response_code end |
#avs_postal_code_response_code ⇒ Object (readonly)
Returns the value of attribute avs_postal_code_response_code.
71 72 73 |
# File 'lib/braintree/transaction.rb', line 71 def avs_postal_code_response_code @avs_postal_code_response_code end |
#avs_street_address_response_code ⇒ Object (readonly)
Returns the value of attribute avs_street_address_response_code.
71 72 73 |
# File 'lib/braintree/transaction.rb', line 71 def avs_street_address_response_code @avs_street_address_response_code end |
#billing_details ⇒ Object (readonly)
Returns the value of attribute billing_details.
84 85 86 |
# File 'lib/braintree/transaction.rb', line 84 def billing_details @billing_details end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
83 84 85 |
# File 'lib/braintree/transaction.rb', line 83 def channel @channel end |
#coinbase_details ⇒ Object (readonly)
Returns the value of attribute coinbase_details.
88 89 90 |
# File 'lib/braintree/transaction.rb', line 88 def coinbase_details @coinbase_details end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def created_at @created_at end |
#credit_card_details ⇒ Object (readonly)
Returns the value of attribute credit_card_details.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def credit_card_details @credit_card_details end |
#currency_iso_code ⇒ Object (readonly)
Returns the value of attribute currency_iso_code.
73 74 75 |
# File 'lib/braintree/transaction.rb', line 73 def currency_iso_code @currency_iso_code end |
#custom_fields ⇒ Object (readonly)
Returns the value of attribute custom_fields.
74 75 76 |
# File 'lib/braintree/transaction.rb', line 74 def custom_fields @custom_fields end |
#customer_details ⇒ Object (readonly)
Returns the value of attribute customer_details.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def customer_details @customer_details end |
#cvv_response_code ⇒ Object (readonly)
Returns the value of attribute cvv_response_code.
75 76 77 |
# File 'lib/braintree/transaction.rb', line 75 def cvv_response_code @cvv_response_code end |
#descriptor ⇒ Object (readonly)
Returns the value of attribute descriptor.
78 79 80 |
# File 'lib/braintree/transaction.rb', line 78 def descriptor @descriptor end |
#disbursement_details ⇒ Object (readonly)
Returns the value of attribute disbursement_details.
76 77 78 |
# File 'lib/braintree/transaction.rb', line 76 def disbursement_details @disbursement_details end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts.
116 117 118 |
# File 'lib/braintree/transaction.rb', line 116 def discounts @discounts end |
#disputes ⇒ Object (readonly)
Returns the value of attribute disputes.
77 78 79 |
# File 'lib/braintree/transaction.rb', line 77 def disputes @disputes end |
#escrow_status ⇒ Object (readonly)
Returns the value of attribute escrow_status.
79 80 81 |
# File 'lib/braintree/transaction.rb', line 79 def escrow_status @escrow_status end |
#gateway_rejection_reason ⇒ Object (readonly)
Returns the value of attribute gateway_rejection_reason.
80 81 82 |
# File 'lib/braintree/transaction.rb', line 80 def gateway_rejection_reason @gateway_rejection_reason end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def id @id end |
#merchant_account_id ⇒ Object (readonly)
Returns the value of attribute merchant_account_id.
81 82 83 |
# File 'lib/braintree/transaction.rb', line 81 def merchant_account_id @merchant_account_id end |
#order_id ⇒ Object (readonly)
Returns the value of attribute order_id.
82 83 84 |
# File 'lib/braintree/transaction.rb', line 82 def order_id @order_id end |
#payment_instrument_type ⇒ Object (readonly)
Returns the value of attribute payment_instrument_type.
117 118 119 |
# File 'lib/braintree/transaction.rb', line 117 def payment_instrument_type @payment_instrument_type end |
#paypal_details ⇒ Object (readonly)
Returns the value of attribute paypal_details.
85 86 87 |
# File 'lib/braintree/transaction.rb', line 85 def paypal_details @paypal_details end |
#plan_id ⇒ Object (readonly)
Returns the value of attribute plan_id.
89 90 91 |
# File 'lib/braintree/transaction.rb', line 89 def plan_id @plan_id end |
#processor_authorization_code ⇒ Object (readonly)
The authorization code from the processor.
91 92 93 |
# File 'lib/braintree/transaction.rb', line 91 def @processor_authorization_code end |
#processor_response_code ⇒ Object (readonly)
The response code from the processor.
93 94 95 |
# File 'lib/braintree/transaction.rb', line 93 def processor_response_code @processor_response_code end |
#processor_response_text ⇒ Object (readonly)
The response text from the processor.
95 96 97 |
# File 'lib/braintree/transaction.rb', line 95 def processor_response_text @processor_response_text end |
#processor_settlement_response_code ⇒ Object (readonly)
The settlement response code from the processor.
99 100 101 |
# File 'lib/braintree/transaction.rb', line 99 def processor_settlement_response_code @processor_settlement_response_code end |
#processor_settlement_response_text ⇒ Object (readonly)
The settlement response text from the processor.
101 102 103 |
# File 'lib/braintree/transaction.rb', line 101 def processor_settlement_response_text @processor_settlement_response_text end |
#purchase_order_number ⇒ Object (readonly)
Returns the value of attribute purchase_order_number.
103 104 105 |
# File 'lib/braintree/transaction.rb', line 103 def purchase_order_number @purchase_order_number end |
#recurring ⇒ Object (readonly)
Returns the value of attribute recurring.
104 105 106 |
# File 'lib/braintree/transaction.rb', line 104 def recurring @recurring end |
#refund_ids ⇒ Object (readonly)
Returns the value of attribute refund_ids.
105 106 107 |
# File 'lib/braintree/transaction.rb', line 105 def refund_ids @refund_ids end |
#refunded_transaction_id ⇒ Object (readonly)
Returns the value of attribute refunded_transaction_id.
105 106 107 |
# File 'lib/braintree/transaction.rb', line 105 def refunded_transaction_id @refunded_transaction_id end |
#risk_data ⇒ Object (readonly)
Returns the value of attribute risk_data.
118 119 120 |
# File 'lib/braintree/transaction.rb', line 118 def risk_data @risk_data end |
#service_fee_amount ⇒ Object (readonly)
Returns the value of attribute service_fee_amount.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def service_fee_amount @service_fee_amount end |
#settlement_batch_id ⇒ Object (readonly)
Returns the value of attribute settlement_batch_id.
106 107 108 |
# File 'lib/braintree/transaction.rb', line 106 def settlement_batch_id @settlement_batch_id end |
#shipping_details ⇒ Object (readonly)
Returns the value of attribute shipping_details.
84 85 86 |
# File 'lib/braintree/transaction.rb', line 84 def shipping_details @shipping_details end |
#status ⇒ Object (readonly)
See Transaction::Status
108 109 110 |
# File 'lib/braintree/transaction.rb', line 108 def status @status end |
#status_history ⇒ Object (readonly)
Returns the value of attribute status_history.
109 110 111 |
# File 'lib/braintree/transaction.rb', line 109 def status_history @status_history end |
#subscription_details ⇒ Object (readonly)
Returns the value of attribute subscription_details.
72 73 74 |
# File 'lib/braintree/transaction.rb', line 72 def subscription_details @subscription_details end |
#subscription_id ⇒ Object (readonly)
Returns the value of attribute subscription_id.
110 111 112 |
# File 'lib/braintree/transaction.rb', line 110 def subscription_id @subscription_id end |
#tax_amount ⇒ Object (readonly)
Returns the value of attribute tax_amount.
111 112 113 |
# File 'lib/braintree/transaction.rb', line 111 def tax_amount @tax_amount end |
#tax_exempt ⇒ Object (readonly)
Returns the value of attribute tax_exempt.
112 113 114 |
# File 'lib/braintree/transaction.rb', line 112 def tax_exempt @tax_exempt end |
#three_d_secure_info ⇒ Object (readonly)
Returns the value of attribute three_d_secure_info.
119 120 121 |
# File 'lib/braintree/transaction.rb', line 119 def three_d_secure_info @three_d_secure_info end |
#type ⇒ Object (readonly)
Will either be “sale” or “credit”
114 115 116 |
# File 'lib/braintree/transaction.rb', line 114 def type @type end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
115 116 117 |
# File 'lib/braintree/transaction.rb', line 115 def updated_at @updated_at end |
#voice_referral_number ⇒ Object (readonly)
Returns the value of attribute voice_referral_number.
102 103 104 |
# File 'lib/braintree/transaction.rb', line 102 def voice_referral_number @voice_referral_number end |
Class Method Details
._attributes ⇒ Object
:nodoc:
369 370 371 |
# File 'lib/braintree/transaction.rb', line 369 def self._attributes # :nodoc: [:amount, :created_at, :credit_card_details, :customer_details, :id, :status, :subscription_details, :type, :updated_at] end |
._new(*args) ⇒ Object
:nodoc:
364 365 366 |
# File 'lib/braintree/transaction.rb', line 364 def _new(*args) # :nodoc: self.new *args end |
.cancel_release(transaction_id) ⇒ Object
129 130 131 |
# File 'lib/braintree/transaction.rb', line 129 def self.cancel_release(transaction_id) Configuration.gateway.transaction.cancel_release(transaction_id) end |
.cancel_release!(transaction_id) ⇒ Object
133 134 135 |
# File 'lib/braintree/transaction.rb', line 133 def self.cancel_release!(transaction_id) return_object_or_raise(:transaction) { cancel_release(transaction_id) } end |
.clone_transaction(transaction_id, attributes) ⇒ Object
137 138 139 |
# File 'lib/braintree/transaction.rb', line 137 def self.clone_transaction(transaction_id, attributes) Configuration.gateway.transaction.clone_transaction(transaction_id, attributes) end |
.clone_transaction!(transaction_id, attributes) ⇒ Object
141 142 143 |
# File 'lib/braintree/transaction.rb', line 141 def self.clone_transaction!(transaction_id, attributes) return_object_or_raise(:transaction) { clone_transaction(transaction_id, attributes) } end |
.create(attributes) ⇒ Object
121 122 123 |
# File 'lib/braintree/transaction.rb', line 121 def self.create(attributes) Configuration.gateway.transaction.create(attributes) end |
.create!(attributes) ⇒ Object
125 126 127 |
# File 'lib/braintree/transaction.rb', line 125 def self.create!(attributes) return_object_or_raise(:transaction) { create(attributes) } end |
.create_from_transparent_redirect(query_string) ⇒ Object
Deprecated. Use Braintree::TransparentRedirect.confirm
146 147 148 149 |
# File 'lib/braintree/transaction.rb', line 146 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 |
.create_transaction_url ⇒ Object
Deprecated. Use Braintree::TransparentRedirect.url
152 153 154 155 |
# File 'lib/braintree/transaction.rb', line 152 def self.create_transaction_url warn "[DEPRECATED] Transaction.create_transaction_url is deprecated. Please use TransparentRedirect.url" Configuration.gateway.transaction.create_transaction_url end |
.credit(attributes) ⇒ Object
157 158 159 |
# File 'lib/braintree/transaction.rb', line 157 def self.credit(attributes) Configuration.gateway.transaction.credit(attributes) end |
.credit!(attributes) ⇒ Object
161 162 163 |
# File 'lib/braintree/transaction.rb', line 161 def self.credit!(attributes) return_object_or_raise(:transaction) { credit(attributes) } end |
.find(id) ⇒ Object
165 166 167 |
# File 'lib/braintree/transaction.rb', line 165 def self.find(id) Configuration.gateway.transaction.find(id) end |
.hold_in_escrow(id) ⇒ Object
169 170 171 |
# File 'lib/braintree/transaction.rb', line 169 def self.hold_in_escrow(id) Configuration.gateway.transaction.hold_in_escrow(id) end |
.hold_in_escrow!(id) ⇒ Object
173 174 175 |
# File 'lib/braintree/transaction.rb', line 173 def self.hold_in_escrow!(id) return_object_or_raise(:transaction) { hold_in_escrow(id) } end |
.refund(id, amount = nil) ⇒ Object
177 178 179 |
# File 'lib/braintree/transaction.rb', line 177 def self.refund(id, amount = nil) Configuration.gateway.transaction.refund(id, amount) end |
.refund!(id, amount = nil) ⇒ Object
181 182 183 |
# File 'lib/braintree/transaction.rb', line 181 def self.refund!(id, amount = nil) return_object_or_raise(:transaction) { refund(id, amount) } end |
.release_from_escrow(transaction_id) ⇒ Object
197 198 199 |
# File 'lib/braintree/transaction.rb', line 197 def self.release_from_escrow(transaction_id) Configuration.gateway.transaction.release_from_escrow(transaction_id) end |
.release_from_escrow!(transaction_id) ⇒ Object
201 202 203 |
# File 'lib/braintree/transaction.rb', line 201 def self.release_from_escrow!(transaction_id) return_object_or_raise(:transaction) { release_from_escrow(transaction_id) } end |
.sale(attributes) ⇒ Object
185 186 187 |
# File 'lib/braintree/transaction.rb', line 185 def self.sale(attributes) Configuration.gateway.transaction.sale(attributes) end |
.sale!(attributes) ⇒ Object
189 190 191 |
# File 'lib/braintree/transaction.rb', line 189 def self.sale!(attributes) return_object_or_raise(:transaction) { sale(attributes) } end |
.search(&block) ⇒ Object
193 194 195 |
# File 'lib/braintree/transaction.rb', line 193 def self.search(&block) Configuration.gateway.transaction.search(&block) end |
.submit_for_settlement(transaction_id, amount = nil) ⇒ Object
205 206 207 |
# File 'lib/braintree/transaction.rb', line 205 def self.submit_for_settlement(transaction_id, amount = nil) Configuration.gateway.transaction.submit_for_settlement(transaction_id, amount) end |
.submit_for_settlement!(transaction_id, amount = nil) ⇒ Object
209 210 211 |
# File 'lib/braintree/transaction.rb', line 209 def self.submit_for_settlement!(transaction_id, amount = nil) return_object_or_raise(:transaction) { submit_for_settlement(transaction_id, amount) } end |
.void(transaction_id) ⇒ Object
213 214 215 |
# File 'lib/braintree/transaction.rb', line 213 def self.void(transaction_id) Configuration.gateway.transaction.void(transaction_id) end |
.void!(transaction_id) ⇒ Object
217 218 219 |
# File 'lib/braintree/transaction.rb', line 217 def self.void!(transaction_id) return_object_or_raise(:transaction) { void(transaction_id) } end |
Instance Method Details
#==(other) ⇒ Object
True if other is a Braintree::Transaction with the same id.
249 250 251 252 |
# File 'lib/braintree/transaction.rb', line 249 def ==(other) return false unless other.is_a?(Transaction) id == other.id end |
#disbursed? ⇒ Boolean
Returns true if the transaction has been disbursed. False otherwise.
285 286 287 |
# File 'lib/braintree/transaction.rb', line 285 def disbursed? @disbursement_details.valid? end |
#inspect ⇒ Object
:nodoc:
254 255 256 257 258 259 260 261 262 263 264 265 |
# File 'lib/braintree/transaction.rb', line 254 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 |
#refund(amount = nil) ⇒ Object
Deprecated. Use Braintree::Transaction.refund
268 269 270 271 272 273 274 275 276 277 |
# File 'lib/braintree/transaction.rb', line 268 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 |
#refund_id ⇒ Object
289 290 291 292 |
# File 'lib/braintree/transaction.rb', line 289 def refund_id warn "[DEPRECATED] Transaction.refund_id is deprecated. Please use Transaction.refund_ids" @refund_id end |
#refunded? ⇒ Boolean
Returns true if the transaction has been refunded. False otherwise.
280 281 282 |
# File 'lib/braintree/transaction.rb', line 280 def refunded? !@refund_id.nil? end |
#submit_for_settlement(amount = nil) ⇒ Object
Deprecated. Use Braintree::Transaction.submit_for_settlement
295 296 297 298 299 300 301 302 |
# File 'lib/braintree/transaction.rb', line 295 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 |
#submit_for_settlement!(amount = nil) ⇒ Object
Deprecated. Use Braintree::Transaction.submit_for_settlement!
305 306 307 308 |
# File 'lib/braintree/transaction.rb', line 305 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 |
#vault_billing_address ⇒ Object
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.
314 315 316 317 |
# File 'lib/braintree/transaction.rb', line 314 def vault_billing_address return nil if billing_details.id.nil? @gateway.address.find(customer_details.id, billing_details.id) end |
#vault_credit_card ⇒ Object
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.
323 324 325 326 |
# File 'lib/braintree/transaction.rb', line 323 def vault_credit_card return nil if credit_card_details.token.nil? @gateway.credit_card.find(credit_card_details.token) end |
#vault_customer ⇒ Object
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.
332 333 334 335 |
# File 'lib/braintree/transaction.rb', line 332 def vault_customer return nil if customer_details.id.nil? @gateway.customer.find(customer_details.id) end |
#vault_shipping_address ⇒ Object
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.
341 342 343 344 |
# File 'lib/braintree/transaction.rb', line 341 def vault_shipping_address return nil if shipping_details.id.nil? @gateway.address.find(customer_details.id, shipping_details.id) end |
#void ⇒ Object
Deprecated. Use Braintree::Transaction.void
347 348 349 350 351 352 353 354 |
# File 'lib/braintree/transaction.rb', line 347 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 |
#void! ⇒ Object
Deprecated. Use Braintree::Transaction.void!
357 358 359 360 |
# File 'lib/braintree/transaction.rb', line 357 def void! warn "[DEPRECATED] void! as an instance method is deprecated. Please use Transaction.void!" return_object_or_raise(:transaction) { void } end |