Sha256: daa3501398b2845e7f3c9a14c60b81ecae30ce7e3a0dfa37592bfb8ed988d965

Contents?: true

Size: 1.26 KB

Versions: 16

Compression:

Stored size: 1.26 KB

Contents

module Braintree
  class PayPalAccount
    include BaseModule

    attr_reader :email, :token, :image_url, :created_at, :updated_at, :subscriptions, :billing_agreement_id, :customer_id

    def initialize(gateway, attributes) # :nodoc:
      @gateway = gateway
      set_instance_variables_from_hash(attributes)
      @subscriptions = (@subscriptions || []).map { |subscription_hash| Subscription._new(@gateway, subscription_hash) }
    end

    class << self
      protected :new
    end

    def self._new(*args)
      self.new(*args)
    end

    def self.find(token)
      Configuration.gateway.paypal_account.find(token)
    end

    def self.update(token, attributes)
      Configuration.gateway.paypal_account.update(token, attributes)
    end

    def self.delete(token)
      Configuration.gateway.paypal_account.delete(token)
    end

    def self.sale(token, transaction_attributes)
      Configuration.gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token))
    end

    def self.sale!(token, transaction_attributes)
      return_object_or_raise(:transaction) { sale(token, transaction_attributes) }
    end

    # Returns true if this paypal account is the customer's default payment method.
    def default?
      @default
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
braintree-2.66.0 lib/braintree/paypal_account.rb
braintree-2.65.0 lib/braintree/paypal_account.rb
braintree-2.64.0 lib/braintree/paypal_account.rb
braintree-2.63.0 lib/braintree/paypal_account.rb
braintree-2.62.0 lib/braintree/paypal_account.rb
braintree-2.61.1 lib/braintree/paypal_account.rb
braintree-2.61.0 lib/braintree/paypal_account.rb
braintree-2.60.0 lib/braintree/paypal_account.rb
braintree-2.59.0 lib/braintree/paypal_account.rb
braintree-2.58.0 lib/braintree/paypal_account.rb
braintree-2.57.0 lib/braintree/paypal_account.rb
braintree-2.56.0 lib/braintree/paypal_account.rb
braintree-2.55.0 lib/braintree/paypal_account.rb
braintree-2.54.0 lib/braintree/paypal_account.rb
braintree-2.50.0 lib/braintree/paypal_account.rb
braintree-2.49.0 lib/braintree/paypal_account.rb