At minimum, an amount, credit card number, and credit card expiration date are required. Minimalistic example:
Braintree::Transaction.sale!(
:amount => "100.00",
:credit_card => {
:number => "5105105105105100",
:expiration_date => "05/2012"
}
)
Full example:
Braintree::Transaction.sale!(
:amount => "100.00",
:order_id => "123",
:credit_card => {
# if :token is omitted, the gateway will generate a token
:token => "credit_card_123",
:number => "5105105105105100",
:expiration_date => "05/2011",
:cvv => "123"
},
:customer => {
# if :id is omitted, the gateway will generate an id
:id => "customer_123",
:first_name => "Dan",
:last_name => "Smith",
:company => "Braintree Payment Solutions",
:email => "dan@example.com",
:phone => "419-555-1234",
:fax => "419-555-1235",
:website => "http://braintreepaymentsolutions.com"
},
:billing => {
:first_name => "Carl",
:last_name => "Jones",
:company => "Braintree",
:street_address => "123 E Main St",
:extended_address => "Suite 403",
:locality => "Chicago",
:region => "IL",
:postal_code => "60622",
:country_name => "United States of America"
},
:shipping => {
:first_name => "Andrew",
:last_name => "Mason",
:company => "Braintree",
:street_address => "456 W Main St",
:extended_address => "Apt 2F",
:locality => "Bartlett",
:region => "IL",
:postal_code => "60103",
:country_name => "United States of America"
},
:custom_fields => {
:birthdate => "11/13/1954"
}
)
The customer and credit card information used for a transaction can be stored in the vault by setting transaction[options][store_in_vault] to true.
transaction = Braintree::Transaction.sale!(
:customer => {
:first_name => "Adam",
:last_name => "Williams"
},
:credit_card => {
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:options => {
:store_in_vault => true
}
)
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
}
)
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 desired amount. You cannot settle more than the authorized amount.
A transaction can be submitted for settlement when created by setting transaction[options][submit_for_settlement] to true.
transaction = Braintree::Transaction.sale!(
:amount => "100.00",
:credit_card => {
:number => "5105105105105100",
:expiration_date => "05/2012"
},
:options => {
:submit_for_settlement => true
}
)
For more detailed documentation on Transactions, see www.braintreepaymentsolutions.com/gateway/transaction-api
| [R] | amount | |
| [R] | avs_error_response_code | |
| [R] | avs_postal_code_response_code | |
| [R] | avs_street_address_response_code | |
| [R] | billing_details | |
| [R] | created_at | |
| [R] | credit_card_details | |
| [R] | currency_iso_code | |
| [R] | custom_fields | |
| [R] | customer_details | |
| [R] | cvv_response_code | |
| [R] | gateway_rejection_reason | |
| [R] | id | |
| [R] | merchant_account_id | |
| [R] | order_id | |
| [R] | processor_authorization_code | The authorization code from the processor. |
| [R] | processor_response_code | The response code from the processor. |
| [R] | processor_response_text | The response text from the processor. |
| [R] | refund_id | |
| [R] | refunded_transaction_id | |
| [R] | shipping_details | |
| [R] | status | See Transaction::Status |
| [R] | status_history | |
| [R] | subscription_id | |
| [R] | type | Will either be "sale" or "credit" |
| [R] | updated_at |
The URL to use to create transactions via transparent redirect.
Creates a credit transaction.
Finds the transaction with the given id. Raises a Braintree::NotFoundError if the transaction cannot be found.
Creates a sale transaction.
Returns a ResourceCollection of transactions matching the search query. If query is a string, the search will be a basic search. If query is a hash, the search will be an advanced search. See: www.braintreepaymentsolutions.com/gateway/transaction-api#searching
Submits transaction with transaction_id for settlement.
True if other is a Braintree::Transaction with the same id.
Creates a credit transaction that refunds this transaction.
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.
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.
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.
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.