lib/braintree/transaction.rb in braintree-1.0.0 vs lib/braintree/transaction.rb in braintree-1.0.1
- old
+ new
@@ -53,20 +53,23 @@
# :extended_address => "Apt 2F",
# :locality => "Bartlett",
# :region => "IL",
# :postal_code => "60103",
# :country_name => "United States of America"
+ # },
+ # :custom_fields => {
+ # :birthdate => "11/13/1954"
# }
# )
#
# == Storing in the Vault
#
# The customer and credit card information used for
# a transaction can be stored in the vault by setting
# <tt>transaction[options][store_in_vault]</tt> to true.
#
- # transaction = Braintree::Transaction.create!(
+ # transaction = Braintree::Transaction.sale!(
# :customer => {
# :first_name => "Adam",
# :last_name => "Williams"
# },
# :credit_card => {
@@ -80,10 +83,21 @@
# transaction.customer_details.id
# # => "865534"
# transaction.credit_card_details.token
# # => "6b6m"
#
+ # To also store the billing address in the vault, pass the
+ # +add_billing_address_to_payment_method+ option.
+ #
+ # Braintree::Transaction.sale!(
+ # # ...
+ # :options => {
+ # :store_in_vault => true
+ # :add_billing_address_to_payment_method => true
+ # }
+ # )
+ #
# == Submitting for Settlement
#
# This can only be done when the transction's
# status is +authorized+. If +amount+ is not specified, the full authorized amount will be
# settled. If you would like to settle less than the full authorized amount, pass the
@@ -110,12 +124,14 @@
Sale = "sale" # :nodoc:
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, :id, :status
+ attr_reader :custom_fields
attr_reader :order_id
attr_reader :billing_details, :shipping_details
+ attr_reader :status_history
# The response code from the processor.
attr_reader :processor_response_code
# Will either be "sale" or "credit"
attr_reader :type
attr_reader :updated_at
@@ -343,18 +359,20 @@
:amount, :customer_id, :order_id, :payment_method_token, :type,
{:credit_card => [:token, :cvv, :expiration_date, :number]},
{:customer => [:id, :company, :email, :fax, :first_name, :last_name, :phone, :website]},
{:billing => [:first_name, :last_name, :company, :country_name, :extended_address, :locality, :postal_code, :region, :street_address]},
{:shipping => [:first_name, :last_name, :company, :country_name, :extended_address, :locality, :postal_code, :region, :street_address]},
- {:options => [:store_in_vault, :submit_for_settlement]}
+ {:options => [:store_in_vault, :submit_for_settlement, :add_billing_address_to_payment_method]},
+ {:custom_fields => :_any_key_}
]
end
def _init(attributes) # :nodoc:
set_instance_variables_from_hash(attributes)
@credit_card_details = CreditCardDetails.new(@credit_card)
@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) } : []
end
- end
+ end
end