Sha256: 99ff5e485c352a3294434f7b2364b3a65360cd2a8f4d8c178b72adc55c7b498b

Contents?: true

Size: 1.36 KB

Versions: 16

Compression:

Stored size: 1.36 KB

Contents

module Braintree
  class PayPalAccountGateway
    def initialize(gateway)
      @gateway = gateway
      @config = gateway.config
    end

    def find(token)
      raise ArgumentError if token.nil? || token.to_s.strip == ""
      response = @config.http.get "/payment_methods/paypal_account/#{token}"
      PayPalAccount._new(@gateway, response[:paypal_account])
    rescue NotFoundError
      raise NotFoundError, "payment method with token #{token.inspect} not found"
    end

    def update(token, attributes)
      Util.verify_keys(PayPalAccountGateway._update_signature, attributes)
      _do_update(:put, "/payment_methods/paypal_account/#{token}", :paypal_account => attributes)
    end

    def delete(token)
      @config.http.delete("/payment_methods/paypal_account/#{token}")
    end

    def _do_update(http_verb, url, params) # :nodoc:
      response = @config.http.send http_verb, url, params
      if response[:paypal_account]
        SuccessfulResult.new(:paypal_account => PayPalAccount._new(@gateway, response[:paypal_account]))
      elsif response[:api_error_response]
        ErrorResult.new(@gateway, response[:api_error_response])
      else
        raise UnexpectedError, "expected :paypal_account or :api_error_response"
      end
    end

    def self._update_signature # :nodoc:
      options = [:make_default]
      [:token, {:options => options}]
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
braintree-2.45.0 lib/braintree/paypal_account_gateway.rb
braintree-2.44.0 lib/braintree/paypal_account_gateway.rb
braintree-2.43.0 lib/braintree/paypal_account_gateway.rb
braintree-2.42.0 lib/braintree/paypal_account_gateway.rb
braintree-2.41.0 lib/braintree/paypal_account_gateway.rb
braintree-2.40.0 lib/braintree/paypal_account_gateway.rb
braintree-2.39.0 lib/braintree/paypal_account_gateway.rb
braintree-2.38.0 lib/braintree/paypal_account_gateway.rb
braintree-2.37.0 lib/braintree/paypal_account_gateway.rb
braintree-2.36.0 lib/braintree/paypal_account_gateway.rb
braintree-2.35.0 lib/braintree/paypal_account_gateway.rb
braintree-2.34.1 lib/braintree/paypal_account_gateway.rb
braintree-2.34.0 lib/braintree/paypal_account_gateway.rb
braintree-2.33.1 lib/braintree/paypal_account_gateway.rb
braintree-2.33.0 lib/braintree/paypal_account_gateway.rb
braintree-2.32.1 lib/braintree/paypal_account_gateway.rb