Sha256: 8c4eae0edfc410d96df3c94b8941e23d3f6ef28ab493c37e4b8b8ee0e01814ce

Contents?: true

Size: 1.38 KB

Versions: 10

Compression:

Stored size: 1.38 KB

Contents

module Braintree
  class PayPalAccount
    include BaseModule

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

    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

    # See http://www.braintreepayments.com/docs/ruby/transactions/create_from_vault
    def self.sale(token, transaction_attributes)
      Configuration.gateway.transaction.sale(transaction_attributes.merge(:payment_method_token => token))
    end

    # See http://www.braintreepayments.com/docs/ruby/transactions/create_from_vault
    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

10 entries across 10 versions & 1 rubygems

Version Path
braintree-2.40.0 lib/braintree/paypal_account.rb
braintree-2.39.0 lib/braintree/paypal_account.rb
braintree-2.38.0 lib/braintree/paypal_account.rb
braintree-2.37.0 lib/braintree/paypal_account.rb
braintree-2.36.0 lib/braintree/paypal_account.rb
braintree-2.35.0 lib/braintree/paypal_account.rb
braintree-2.34.1 lib/braintree/paypal_account.rb
braintree-2.34.0 lib/braintree/paypal_account.rb
braintree-2.33.1 lib/braintree/paypal_account.rb
braintree-2.33.0 lib/braintree/paypal_account.rb