Sha256: 08dd1a981ab18670398b37f5b59d0dc574a72fac86a75f598a76027007843ca2

Contents?: true

Size: 1.51 KB

Versions: 31

Compression:

Stored size: 1.51 KB

Contents

module Braintree
  class PayPalAccount
    include BaseModule

    attr_reader :billing_agreement_id
    attr_reader :created_at
    attr_reader :customer_id
    attr_reader :email
    attr_reader :image_url
    attr_reader :payer_id
    attr_reader :revoked_at
    attr_reader :subscriptions
    attr_reader :token
    attr_reader :updated_at

    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.create(attributes)
      Configuration.gateway.paypal_account.create(attributes)
    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

31 entries across 31 versions & 1 rubygems

Version Path
braintree-4.15.0 lib/braintree/paypal_account.rb
braintree-4.14.0 lib/braintree/paypal_account.rb
braintree-4.13.0 lib/braintree/paypal_account.rb
braintree-4.12.0 lib/braintree/paypal_account.rb
braintree-4.11.0 lib/braintree/paypal_account.rb
braintree-4.10.0 lib/braintree/paypal_account.rb
braintree-4.9.0 lib/braintree/paypal_account.rb
braintree-4.8.0 lib/braintree/paypal_account.rb
braintree-4.7.0 lib/braintree/paypal_account.rb
braintree-4.6.0 lib/braintree/paypal_account.rb
braintree-4.5.0 lib/braintree/paypal_account.rb
braintree-4.4.0 lib/braintree/paypal_account.rb
braintree-4.3.0 lib/braintree/paypal_account.rb
braintree-4.2.0 lib/braintree/paypal_account.rb
braintree-4.1.0 lib/braintree/paypal_account.rb
braintree-4.0.0 lib/braintree/paypal_account.rb
braintree-3.4.0 lib/braintree/paypal_account.rb
braintree-3.3.0 lib/braintree/paypal_account.rb
braintree-3.2.0 lib/braintree/paypal_account.rb
braintree-3.1.0 lib/braintree/paypal_account.rb