Sha256: 363e2553dcd01e0efe326bee56cde1d325b99c03e4dbdc5fbbb67b919e1e3028

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

module Braintree
  # See http://www.braintreepayments.com/docs/ruby/general/result_objects
  class ErrorResult

    attr_reader :credit_card_verification, :transaction, :subscription, :errors, :params, :message
    attr_reader :payer_authentication

    def initialize(gateway, data) # :nodoc:
      @gateway = gateway
      @params = data[:params]
      @credit_card_verification = CreditCardVerification._new(data[:verification]) if data[:verification]
      @message = data[:message]
      @payer_authentication = PayerAuthentication._new(gateway, data[:payer_authentication]) if data[:payer_authentication]
      @transaction = Transaction._new(gateway, data[:transaction]) if data[:transaction]
      @subscription = Subscription._new(gateway, data[:subscription]) if data[:subscription]
      @errors = Errors.new(data[:errors])
    end

    def inspect # :nodoc:
      if @credit_card_verification
        verification_inspect = " credit_card_verification: #{@credit_card_verification.inspect}"
      end
      if @transaction
        transaction_inspect = " transaction: #{@transaction.inspect}"
      end
      "#<#{self.class} params:{...} errors:<#{@errors._inner_inspect}>#{verification_inspect}#{transaction_inspect}>"
    end

    def payer_authentication_required?
      !!@payer_authentication
    end

    # Always returns false.
    def success?
      false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
braintree-2.10.3 lib/braintree/error_result.rb
braintree-2.10.2 lib/braintree/error_result.rb