-
Notifications
You must be signed in to change notification settings - Fork 22
Transaction
lyang edited this page Mar 17, 2013
·
2 revisions
Transaction only supports create. After creation, you can only change its status through each specific method.
[
:amount, :billing, :channel, :custom_fields, :customer_id, :descriptor, :merchant_account_id,
:options, :order_id, :payment_method_token, :purchase_order_number, :recurring, :shipping,
:tax_amount, :tax_exempt, :type, :venmo_sdk_payment_method_code
]
[
:avs_error_response_code, :avs_postal_code_response_code, :avs_street_address_response_code, :billing_details,
:channel, :created_at, :credit_card, :credit_card_details, :currency_iso_code, :customer, :customer_details,
:cvv_response_code, :plan_id, :purchase_order_number, :refund_ids, :refunded_transaction_id, :settlement_batch_id,
:shipping_details, :status, :status_history, :subscription_details, :updated_at
]
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.add_ons # eager loaded collection
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.discounts # eager loaded collection
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.customer # Loaded from customer_details
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.credit_card # Loaded from credit_card_details
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.subscription # Loaded from subscription_id
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.billing # Loaded from billing_details
transaction = BraintreeRails::Transaction.find('transaction_id')
transaction.shipping # Loaded from shipping_details
[:amount, :presence => true, :numericality => {:greater_than_or_equal_to => 0}, :if => :new_record?],
[:type, :presence => true, :inclusion => {:in => %w(sale credit)}, :if => :new_record?],
[:status, :inclusion => {:in => [Braintree::Transaction::Status::Authorized]}, :on => :submit_for_settlement],
[:status, :inclusion => {:in => [Braintree::Transaction::Status::Settled, Braintree::Transaction::Status::Settling]}, :on => :refund],
[:status, :inclusion => {:in => [Braintree::Transaction::Status::Authorized, Braintree::Transaction::Status::SubmittedForSettlement]}, :on => :void]
Transactions are not updatable. You can only change its status through the following methods:
- submit_for_settlement
- refund
- void
Those method specific validations are only run when their corresponding method are called.
In addition to the above, credit card validations will also kick in when creating transactions
- must_have_credit_card
if transaction.credit_card.blank? validate_customer_have_default_credit_card(transaction) elsif transaction.credit_card.new_record? validate_new_credit_card(transaction) end
(before|after)_validate
(before|around|after)_save
(before|around|after)_create
(before|around|after)_update
(before|around|after)_destroy
(before|around|after)_submit_for_settlement
(before|around|after)_void
(before|around|after)_refund
None