lib/braintree/transaction.rb in braintree-2.24.0 vs lib/braintree/transaction.rb in braintree-2.25.0

- old
+ new

@@ -6,10 +6,18 @@ module CreatedUsing FullInformation = 'full_information' Token = 'token' end + module EscrowStatus + HoldPending = 'hold_pending' + Held = 'held' + ReleasePending = 'release_pending' + Released = 'released' + Refunded = 'refunded' + end + module GatewayRejectionReason AVS = "avs" AVSAndCVV = "avs_and_cvv" CVV = "cvv" Duplicate = "duplicate" @@ -42,16 +50,17 @@ All = constants.map { |c| const_get(c) } end attr_reader :avs_error_response_code, :avs_postal_code_response_code, :avs_street_address_response_code - attr_reader :amount, :created_at, :credit_card_details, :customer_details, :subscription_details, :id + attr_reader :amount, :created_at, :credit_card_details, :customer_details, :subscription_details, :service_fee_amount, :id attr_reader :currency_iso_code attr_reader :custom_fields attr_reader :cvv_response_code attr_reader :disbursement_details attr_reader :descriptor + attr_reader :escrow_status attr_reader :gateway_rejection_reason attr_reader :merchant_account_id attr_reader :order_id attr_reader :channel attr_reader :billing_details, :shipping_details @@ -85,10 +94,18 @@ # See http://www.braintreepayments.com/docs/ruby/transactions/create def self.create!(attributes) return_object_or_raise(:transaction) { create(attributes) } end + def self.cancel_release(transaction_id) + Configuration.gateway.transaction.cancel_release(transaction_id) + end + + def self.cancel_release!(transaction_id) + return_object_or_raise(:transaction) { cancel_release(transaction_id) } + end + def self.clone_transaction(transaction_id, attributes) Configuration.gateway.transaction.clone_transaction(transaction_id, attributes) end def self.clone_transaction!(transaction_id, attributes) @@ -122,10 +139,18 @@ # See http://www.braintreepayments.com/docs/ruby/transactions/search def self.find(id) Configuration.gateway.transaction.find(id) end + def self.hold_in_escrow(id) + Configuration.gateway.transaction.hold_in_escrow(id) + end + + def self.hold_in_escrow!(id) + return_object_or_raise(:transaction) { hold_in_escrow(id) } + end + # See http://www.braintreepayments.com/docs/ruby/transactions/refund def self.refund(id, amount = nil) Configuration.gateway.transaction.refund(id, amount) end @@ -147,10 +172,18 @@ # See http://www.braintreepayments.com/docs/ruby/transactions/search def self.search(&block) Configuration.gateway.transaction.search(&block) end + def self.release_from_escrow(transaction_id) + Configuration.gateway.transaction.release_from_escrow(transaction_id) + end + + def self.release_from_escrow!(transaction_id) + return_object_or_raise(:transaction) { release_from_escrow(transaction_id) } + end + # See http://www.braintreepayments.com/docs/ruby/transactions/submit_for_settlement def self.submit_for_settlement(transaction_id, amount = nil) Configuration.gateway.transaction.submit_for_settlement(transaction_id, amount) end @@ -172,9 +205,10 @@ 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)