### Home Classes Methods

### In Files

- lib/active_merchant/billing/gateways/braintree_blue.rb

### Parent

ActiveMerchant::Billing::Gateway

### Methods

- ::new
- #authorize
- #capture
- #credit
- #delete
- #purchase
- #refund
- #store
- #unstore
- #update
- #void

### Included Modules

- BraintreeCommon

### Class/Module Index

Quicksearch

- ActiveMerchant
- ActiveMerchant::Billing
- ActiveMerchant::Billing::AVSResult
- ActiveMerchant::Billing::BarclaysEpdqGateway
- ActiveMerchant::Billing::BarclaysEpdqGateway::Document
- ActiveMerchant::Billing::BarclaysEpdqGateway::Parser
- ActiveMerchant::Billing::Base
- ActiveMerchant::Billing::BeanstreamGateway
- ActiveMerchant::Billing::BeanstreamInteracGateway
- ActiveMerchant::Billing::BeanstreamInteracResponse
- ActiveMerchant::Billing::BluePayGateway
- ActiveMerchant::Billing::BogusGateway
- ActiveMerchant::Billing::BraintreeBlueGateway
- ActiveMerchant::Billing::BraintreeGateway
- ActiveMerchant::Billing::BraintreeOrangeGateway
- ActiveMerchant::Billing::CVVResult
- ActiveMerchant::Billing::CardSaveGateway
- ActiveMerchant::Billing::CardStreamGateway
- ActiveMerchant::Billing::Check
- ActiveMerchant::Billing::CreditCard
- ActiveMerchant::Billing::CreditCardFormatting
- ActiveMerchant::Billing::CreditCardMethods
- ActiveMerchant::Billing::CreditCardMethods::ClassMethods
- ActiveMerchant::Billing::CyberSourceGateway
- ActiveMerchant::Billing::DataCashGateway
- ActiveMerchant::Billing::EfsnetGateway
- ActiveMerchant::Billing::ElavonGateway
- ActiveMerchant::Billing::EpayGateway
- ActiveMerchant::Billing::EwayGateway
- ActiveMerchant::Billing::EwayManagedGateway
- ActiveMerchant::Billing::EwayManagedGateway::EwayResponse
- ActiveMerchant::Billing::ExactGateway
- ActiveMerchant::Billing::FederatedCanadaGateway
- ActiveMerchant::Billing::FirstPayGateway
- ActiveMerchant::Billing::FirstPayGateway::FirstPayPostData
- ActiveMerchant::Billing::GarantiGateway
- ActiveMerchant::Billing::Gateway
- ActiveMerchant::Billing::IdealBaseGateway
- ActiveMerchant::Billing::IdealRabobankGateway
- ActiveMerchant::Billing::IdealResponse
- ActiveMerchant::Billing::InspireGateway
- ActiveMerchant::Billing::InstapayGateway
- ActiveMerchant::Billing::Integrations
- ActiveMerchant::Billing::Integrations::ActionViewHelper
- ActiveMerchant::Billing::Integrations::Bogus
- ActiveMerchant::Billing::Integrations::Bogus::Helper
- ActiveMerchant::Billing::Integrations::Bogus::Notification
- ActiveMerchant::Billing::Integrations::Bogus::Return
- ActiveMerchant::Billing::Integrations::Chronopay
- ActiveMerchant::Billing::Integrations::Chronopay::Helper
- ActiveMerchant::Billing::Integrations::Chronopay::Return
- ActiveMerchant::Billing::Integrations::DirecPay
- ActiveMerchant::Billing::Integrations::DirecPay::Helper
- ActiveMerchant::Billing::Integrations::DirecPay::Notification
- ActiveMerchant::Billing::Integrations::DirecPay::Return
- ActiveMerchant::Billing::Integrations::DirecPay::Status
- ActiveMerchant::Billing::Integrations::Directebanking
- ActiveMerchant::Billing::Integrations::Directebanking::Helper
- ActiveMerchant::Billing::Integrations::Directebanking::Notification
- ActiveMerchant::Billing::Integrations::Directebanking::Return
- ActiveMerchant::Billing::Integrations::Dwolla
- ActiveMerchant::Billing::Integrations::Dwolla::Helper
- ActiveMerchant::Billing::Integrations::Dwolla::Notification
- ActiveMerchant::Billing::Integrations::Dwolla::Return
- ActiveMerchant::Billing::Integrations::EPaymentPlans
- ActiveMerchant::Billing::Integrations::EPaymentPlans::Helper
- ActiveMerchant::Billing::Integrations::EPaymentPlans::Notification
- ActiveMerchant::Billing::Integrations::Gestpay
- ActiveMerchant::Billing::Integrations::Gestpay::Common
- ActiveMerchant::Billing::Integrations::Gestpay::Helper
- ActiveMerchant::Billing::Integrations::Gestpay::Notification
- ActiveMerchant::Billing::Integrations::Gestpay::Return
- ActiveMerchant::Billing::Integrations::HiTrust
- ActiveMerchant::Billing::Integrations::HiTrust::Notification
- ActiveMerchant::Billing::Integrations::HiTrust::Return
- ActiveMerchant::Billing::Integrations::Moneybookers
- ActiveMerchant::Billing::Integrations::Moneybookers::Helper
- ActiveMerchant::Billing::Integrations::Nochex
- ActiveMerchant::Billing::Integrations::Nochex::Helper
- ActiveMerchant::Billing::Integrations::Nochex::Notification
- ActiveMerchant::Billing::Integrations::Nochex::Return
- ActiveMerchant::Billing::Integrations::Notification
- ActiveMerchant::Billing::Integrations::PayflowLink
- ActiveMerchant::Billing::Integrations::PayflowLink::Helper
- ActiveMerchant::Billing::Integrations::PayflowLink::Notification
- ActiveMerchant::Billing::Integrations::Paypal
- ActiveMerchant::Billing::Integrations::Paypal::Helper
- ActiveMerchant::Billing::Integrations::Paypal::Notification
- ActiveMerchant::Billing::Integrations::Paypal::Return
- ActiveMerchant::Billing::Integrations::Quickpay
- ActiveMerchant::Billing::Integrations::Quickpay::Helper
- ActiveMerchant::Billing::Integrations::Quickpay::Notification
- ActiveMerchant::Billing::Integrations::Return
- ActiveMerchant::Billing::Integrations::SagePayForm
- ActiveMerchant::Billing::Integrations::SagePayForm::Encryption
- ActiveMerchant::Billing::Integrations::SagePayForm::Helper
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::CryptError
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::InvalidCryptData
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::MissingCryptData
- ActiveMerchant::Billing::Integrations::SagePayForm::Notification::MissingCryptKey
- ActiveMerchant::Billing::Integrations::SagePayForm::Return
- ActiveMerchant::Billing::Integrations::TwoCheckout
- ActiveMerchant::Billing::Integrations::TwoCheckout::Helper
- ActiveMerchant::Billing::Integrations::TwoCheckout::Notification
- ActiveMerchant::Billing::Integrations::TwoCheckout::Return
- ActiveMerchant::Billing::Integrations::Valitor
- ActiveMerchant::Billing::Integrations::Valitor::Helper
- ActiveMerchant::Billing::Integrations::Valitor::Notification
- ActiveMerchant::Billing::Integrations::Valitor::ResponseFields
- ActiveMerchant::Billing::Integrations::Valitor::Return
- ActiveMerchant::Billing::Integrations::WorldPay
- ActiveMerchant::Billing::Integrations::WorldPay::Helper
- ActiveMerchant::Billing::Integrations::WorldPay::Notification
- ActiveMerchant::Billing::IridiumGateway
- ActiveMerchant::Billing::JetpayGateway
- ActiveMerchant::Billing::LinkpointGateway
- ActiveMerchant::Billing::MerchantESolutionsGateway
- ActiveMerchant::Billing::MerchantWareGateway
- ActiveMerchant::Billing::ModernPaymentsGateway
- ActiveMerchant::Billing::MonerisGateway
- ActiveMerchant::Billing::NetRegistryGateway
- ActiveMerchant::Billing::NetaxeptGateway
- ActiveMerchant::Billing::NetaxeptGateway::Response
- ActiveMerchant::Billing::NetbillingGateway
- ActiveMerchant::Billing::NmiGateway
- ActiveMerchant::Billing::OptimalPaymentGateway
- ActiveMerchant::Billing::OrbitalSoftDescriptors
- ActiveMerchant::Billing::PayJunctionGateway
- ActiveMerchant::Billing::PaySecureGateway
- ActiveMerchant::Billing::PayboxDirectGateway
- ActiveMerchant::Billing::PayflowCommonAPI
- ActiveMerchant::Billing::PayflowExpressResponse
- ActiveMerchant::Billing::PayflowExpressUkGateway
- ActiveMerchant::Billing::PayflowGateway
- ActiveMerchant::Billing::PayflowResponse
- ActiveMerchant::Billing::PayflowUkGateway
- ActiveMerchant::Billing::PaymentExpressGateway
- ActiveMerchant::Billing::PaymentExpressResponse
- ActiveMerchant::Billing::PaypalCaGateway
- ActiveMerchant::Billing::PaypalCommonAPI
- ActiveMerchant::Billing::PaypalExpressCommon
- ActiveMerchant::Billing::PaypalExpressGateway
- ActiveMerchant::Billing::PaypalExpressResponse
- ActiveMerchant::Billing::PaypalGateway
- ActiveMerchant::Billing::PlugnpayGateway
- ActiveMerchant::Billing::PlugnpayGateway::PlugnpayPostData
- ActiveMerchant::Billing::PsigateGateway
- ActiveMerchant::Billing::QbmsGateway
- ActiveMerchant::Billing::QuantumGateway
- ActiveMerchant::Billing::QuickpayGateway
- ActiveMerchant::Billing::RealexGateway
- ActiveMerchant::Billing::Response
- ActiveMerchant::Billing::SageGateway
- ActiveMerchant::Billing::SagePayGateway
- ActiveMerchant::Billing::SallieMaeGateway
- ActiveMerchant::Billing::SamuraiGateway
- ActiveMerchant::Billing::SecureNetGateway
- ActiveMerchant::Billing::SecurePayAuGateway
- ActiveMerchant::Billing::SecurePayGateway
- ActiveMerchant::Billing::SecurePayTechGateway
- ActiveMerchant::Billing::SecurePayTechGateway::SecurePayTechPostData
- ActiveMerchant::Billing::SkipJackGateway
- ActiveMerchant::Billing::StripeGateway
- ActiveMerchant::Billing::TransFirstGateway
- ActiveMerchant::Billing::TransaxGateway
- ActiveMerchant::Billing::TrustCommerceGateway
- ActiveMerchant::Billing::UsaEpayAdvancedGateway
- ActiveMerchant::Billing::UsaEpayGateway
- ActiveMerchant::Billing::UsaEpayTransactionGateway
- ActiveMerchant::Billing::VerifiGateway
- ActiveMerchant::Billing::VerifiGateway::VerifiPostData
- ActiveMerchant::Billing::ViaklixGateway
- ActiveMerchant::Billing::WirecardGateway
- ActiveMerchant::Billing::WorldpayGateway
- ActiveMerchant::Billing::WorldpayGateway::MultiResponse
- BraintreeCommon
- OutboundHosts

No matching classes.

# ActiveMerchant::Billing::BraintreeBlueGateway

### Public Class Methods

new(options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 18
    def initialize(options = {})
      requires!(options, :merchant_id, :public_key, :private_key)
      @options = options
      @merchant_account_id = options[:merchant_account_id]
      Braintree::Configuration.merchant_id = options[:merchant_id]
      Braintree::Configuration.public_key = options[:public_key]
      Braintree::Configuration.private_key = options[:private_key]
      Braintree::Configuration.environment = (options[:environment] || (test? ? :sandbox : :production)).to_sym
      Braintree::Configuration.logger.level = Logger::ERROR if Braintree::Configuration.logger
      Braintree::Configuration.custom_user_agent = "ActiveMerchant #{ActiveMerchant::VERSION}"
      super
    end

### Public Instance Methods

authorize(money, credit_card_or_vault_id, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 31
    def authorize(money, credit_card_or_vault_id, options = {})
      create_transaction(:sale, money, credit_card_or_vault_id, options)
    end

capture(money, authorization, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 35
    def capture(money, authorization, options = {})
      commit do
        result = Braintree::Transaction.submit_for_settlement(authorization, amount(money).to_s)
        Response.new(result.success?, message_from_result(result))
      end
    end

credit(money, credit_card_or_vault_id, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 46
    def credit(money, credit_card_or_vault_id, options = {})
      create_transaction(:credit, money, credit_card_or_vault_id, options)
    end

delete(customer_vault_id) click to toggle source
Alias for: unstore
purchase(money, credit_card_or_vault_id, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 42
    def purchase(money, credit_card_or_vault_id, options = {})
      authorize(money, credit_card_or_vault_id, options.merge(:submit_for_settlement => true))
    end

refund(*args) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 50
    def refund(*args)
      # legacy signature: #refund(transaction_id, options = {})
      # new signature: #refund(money, transaction_id, options = {})
      money, transaction_id, options = extract_refund_args(args)
      money = amount(money).to_s if money

      commit do
        result = Braintree::Transaction.refund(transaction_id, money)
        Response.new(result.success?, message_from_result(result),
          {:braintree_transaction => (transaction_hash(result.transaction) if result.success?)},
          {:authorization => (result.transaction.id if result.success?)}
         )
      end
    end

store(creditcard, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 75
    def store(creditcard, options = {})
      commit do
        result = Braintree::Customer.create(
          :first_name => creditcard.first_name,
          :last_name => creditcard.last_name,
          :email => options[:email],
          :credit_card => {
            :number => creditcard.number,
            :cvv => creditcard.verification_value,
            :expiration_month => creditcard.month.to_s.rjust(2, "0"),
            :expiration_year => creditcard.year.to_s
          }
        )
        Response.new(result.success?, message_from_result(result),
          {
            :braintree_customer => (customer_hash(result.customer) if result.success?),
            :customer_vault_id => (result.customer.id if result.success?)
          }
        )
      end
    end

unstore(customer_vault_id) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 124
    def unstore(customer_vault_id)
      commit do
        Braintree::Customer.delete(customer_vault_id)
        Response.new(true, "OK")
      end
    end

Also aliased as: delete
update(vault_id, creditcard, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 97
    def update(vault_id, creditcard, options = {})
      braintree_credit_card = nil
      customer_update_result = commit do
        braintree_credit_card = Braintree::Customer.find(vault_id).credit_cards.detect { |cc| cc.default? }
        return Response.new(false, 'Braintree::NotFoundError') if braintree_credit_card.nil?
        result = Braintree::Customer.update(vault_id,
          :first_name => creditcard.first_name,
          :last_name => creditcard.last_name,
          :email => options[:email]
        )
        Response.new(result.success?, message_from_result(result),
          :braintree_customer => (customer_hash(Braintree::Customer.find(vault_id)) if result.success?)
        )
      end
      return customer_update_result unless customer_update_result.success?
      credit_card_update_result = commit do
        result = Braintree::CreditCard.update(braintree_credit_card.token,
            :number => creditcard.number,
            :expiration_month => creditcard.month.to_s.rjust(2, "0"),
            :expiration_year => creditcard.year.to_s
        )
        Response.new(result.success?, message_from_result(result),
          :braintree_customer => (customer_hash(Braintree::Customer.find(vault_id)) if result.success?)
        )
      end
    end

void(authorization, options = {}) click to toggle source

    # File lib/active_merchant/billing/gateways/braintree_blue.rb, line 65
    def void(authorization, options = {})
      commit do
        result = Braintree::Transaction.void(authorization)
        Response.new(result.success?, message_from_result(result),
          {:braintree_transaction => (transaction_hash(result.transaction) if result.success?)},
          {:authorization => (result.transaction.id if result.success?)}
        )
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.