class Braintree::PayPalAccountGateway

Public Class Methods

_create_nested_signature() click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 61
def self._create_nested_signature
  [
    :email, :token, :billing_agreement_id,
    {:options => [:make_default]}
  ]
end
_create_signature() click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 53
def self._create_signature
  options = [:fail_on_duplicate_payment_method, :make_default]
  [
    :email, :token, :billing_agreement_id, :customer_id,
    {:options => options},
  ]
end
_update_signature() click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 68
def self._update_signature
  options = [:fail_on_duplicate_payment_method, :make_default]
  [:email, :token, :billing_agreement_id, {:options => options}]
end
new(gateway) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 3
def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
  @config.assert_has_access_token_or_keys
end

Public Instance Methods

_do_create(path, params) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 31
def _do_create(path, params)
  response = @config.http.post("#{@config.base_merchant_path}#{path}", 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
_do_update(http_verb, path, params) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 42
def _do_update(http_verb, path, params)
  response = @config.http.send(http_verb, "#{@config.base_merchant_path}#{path}", 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
create(attributes) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 17
def create(attributes)
  Util.verify_keys(PayPalAccountGateway._create_signature, attributes)
  _do_create("/payment_methods", :paypal_account => attributes)
end
delete(token) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 27
def delete(token)
  @config.http.delete("#{@config.base_merchant_path}/payment_methods/paypal_account/#{token}")
end
find(token) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 9
def find(token)
  raise ArgumentError if token.nil? || token.to_s.strip == ""
  response = @config.http.get("#{@config.base_merchant_path}/payment_methods/paypal_account/#{token}")
  PayPalAccount._new(@gateway, response[:paypal_account])
rescue NotFoundError
  raise NotFoundError, "payment method with token #{token.inspect} not found"
end
update(token, attributes) click to toggle source
# File lib/braintree/paypal_account_gateway.rb, line 22
def update(token, attributes)
  Util.verify_keys(PayPalAccountGateway._update_signature, attributes)
  _do_update(:put, "/payment_methods/paypal_account/#{token}", :paypal_account => attributes)
end