Sha256: f8b56697e57ef0a30b1a0ae418654ac6b74a75dc8513efafe25a22a1f830e208

Contents?: true

Size: 1.36 KB

Versions: 18

Compression:

Stored size: 1.36 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.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

18 entries across 18 versions & 1 rubygems

Version Path
braintree-2.80.1 lib/braintree/paypal_account.rb
braintree-2.80.0 lib/braintree/paypal_account.rb
braintree-2.79.0 lib/braintree/paypal_account.rb
braintree-2.78.0 lib/braintree/paypal_account.rb
braintree-2.77.0 lib/braintree/paypal_account.rb
braintree-2.76.0 lib/braintree/paypal_account.rb
braintree-2.75.0 lib/braintree/paypal_account.rb
braintree-2.74.0 lib/braintree/paypal_account.rb
braintree-2.73.0 lib/braintree/paypal_account.rb
braintree-2.72.0 lib/braintree/paypal_account.rb
braintree-2.71.0 lib/braintree/paypal_account.rb
braintree-2.70.0 lib/braintree/paypal_account.rb
braintree-2.69.1 lib/braintree/paypal_account.rb
braintree-2.69.0 lib/braintree/paypal_account.rb
braintree-2.68.2 lib/braintree/paypal_account.rb
braintree-2.68.1 lib/braintree/paypal_account.rb
braintree-2.68.0 lib/braintree/paypal_account.rb
braintree-2.67.0 lib/braintree/paypal_account.rb