Server-Side Implementation
Your integration may be impacted by upcoming certificate changes. Visit our best practices guide to learn more.
Creating transactions
    Using
    Transaction:Sale
    is the simplest way to create a credit card transaction.You can create a transaction with just an amount and a payment_method_nonce relayed from your client and immediately submit it for settlement.
Collect device data from the client and include the device_data_from_the_client in the transaction.
- Ruby
 
result = gateway.transaction.sale(
    :amount => "10.00",
    :payment_method_nonce => nonce_from_the_client,
    :device_data => device_data_from_the_client,
    :options => {
        :submit_for_settlement => true
    }
)
if result.success?
    # See result.transaction for details
else
    # Handle errors
endCard verification
When a payment method is a credit or debit card, you can use card verification to verify that the card data matches a valid, open account before storing or updating it in the Vault.
Braintree strongly recommends verifying all cards before they are stored in your Vault by enabling card verification in the Control Panel.
If you do not want to verify all cards by default, you can run one-time requests using options.verify_card when:
In both cases, the gateway verifies cards by running either a $0 or $1 authorization and then automatically voiding it. If you'd like, you can specify a different options.verification_amount to use for the authorization.
- Ruby
 
result = gateway.payment_method.create(
    :customer_id => "the_customer_id",
    :payment_method_nonce => nonce_from_the_client,
    :options => {
        :verify_card => true,
        :verification_merchant_account_id => "the_merchant_account_id",
        :verification_amount => "2.00",
    }
)Verification results
If verification was successful, the result will contain a CreditCard response object, which will contain a CreditCardVerification response object.
- Ruby
 
result = gateway.payment_method.create(
    :customer_id => "the_customer_id",
    :payment_method_nonce => nonce_from_the_client,
    :options => {
        :verify_card => true
    }
)
if result.success?
    verification = result.payment_method.verification
end- A verification ran, and
 - It was returned with a status of processor_declined or gateway_rejected
 
Reasons for unsuccessful verification results
    You can check the
    processor_response_code
    and
    processor_response_text
    for the specific reason that a verification was processor_declined- Ruby
 
result = gateway.payment_method.create(
  :customer_id => "the_customer_id",
  :payment_method_nonce => nonce_from_the_client,
  :options => {
    :verify_card => true
  }
)
result.success?
#=> false
verification = result.credit_card_verification
verification.status
#=> "processor_declined"
verification.processor_response_type
#=> "soft_declined"
verification.processor_response_code
#=> "2000"
verification.processor_response_text
#=> "Do Not Honor"- Ruby
 
result.success? #=> false
verification = result.credit_card_verification
verification.status #=> "gateway_rejected"
verification.gateway_rejection_reason #=> "cvv"Verifications on sub-merchant accounts
For those using Braintree Marketplace, verifications can't be done using sub-merchant accounts. See Braintree Marketplace Verifications for more details.
See Also
- Creating transactions
 - Creating and updating customers
 - Creating and updating payment methods
 - Credit card verification
 - Verifying cards with Hosted Fields