Class: Recurly::Transaction

Inherits:
Resource show all
Defined in:
lib/recurly/transaction.rb,
lib/recurly/transaction/errors.rb

Defined Under Namespace

Classes: ConfigurationError, DeclinedError, DuplicateError, Error, RetryableError

Class Attribute Summary collapse

Attributes inherited from Resource

#attributes, #etag, #response, #uri

Class Method Summary collapse

Methods inherited from Resource

#==, all, associations, belongs_to, #changed, #changed?, #changed_attributes, #changes, collection_name, count, create, create!, define_attribute_methods, #destroy, #destroyed?, embedded!, #errors, find, find_each, first, from_response, from_xml, has_many, has_one, #initialize, #inspect, #marshal_dump, #marshal_load, member_name, member_path, #new_record?, paginate, #persist!, #persisted?, #previous_changes, #read_attribute, reflect_on_association, #reload, resource_name, #save, #save!, scope, scopes, #signable_attributes, #to_param, #to_xml, #update_attributes, #update_attributes!, #valid?, #write_attribute

Constructor Details

This class inherits a constructor from Recurly::Resource

Class Attribute Details

.type"credit", ... (readonly)



42
43
44
# File 'lib/recurly/transaction.rb', line 42

def type
  @type
end

Class Method Details

.accountAccount



17
# File 'lib/recurly/transaction.rb', line 17

belongs_to :account

.authorizationsPager



8
# File 'lib/recurly/transaction.rb', line 8

scope :authorizations, :type  => 'authorization'

.failedPager



13
# File 'lib/recurly/transaction.rb', line 13

scope :failed,         :state => 'failed'

.initialize(attributes = {}) ⇒ Object



45
46
47
# File 'lib/recurly/transaction.rb', line 45

def initialize attributes = {}
  super({ :currency => Recurly.default_currency }.merge attributes)
end

.inspectString



78
79
80
81
82
83
84
# File 'lib/recurly/transaction.rb', line 78

def inspect
  attributes = self.class.attribute_names
  unless type == 'credit_card'
    attributes -= %w(cvv_result avs_result avs_result_street)
  end
  super attributes
end

.invoiceInvoice?



19
# File 'lib/recurly/transaction.rb', line 19

belongs_to :invoice

.purchasesPager



9
# File 'lib/recurly/transaction.rb', line 9

scope :purchases,      :type  => 'purchase'

.refund(amount_in_cents = nil) ⇒ Transaction, false

Refunds the transaction.

Raises:

  • (Error)

    If the refund fails.

See Also:

  • Transaction#void


66
67
68
69
70
71
# File 'lib/recurly/transaction.rb', line 66

def refund amount_in_cents = nil
  return false unless self[:refund]
  self.class.from_response(
    self[:refund].call :params => { :amount_in_cents => amount_in_cents }
  )
end

.refundsPager



10
# File 'lib/recurly/transaction.rb', line 10

scope :refunds,        :type  => 'refund'

.savetrue, false

Saves new records only.

Raises:

See Also:



54
55
56
57
# File 'lib/recurly/transaction.rb', line 54

def save
  return super if new_record?
  raise Recurly::Error, "#{self.class.collection_name} cannot be updated"
end

.signable_attributesObject



73
74
75
# File 'lib/recurly/transaction.rb', line 73

def signable_attributes
  super.merge :amount_in_cents => amount_in_cents, :currency => currency
end

.successfulPager



12
# File 'lib/recurly/transaction.rb', line 12

scope :successful,     :state => 'successful'

.voidedPager



14
# File 'lib/recurly/transaction.rb', line 14

scope :voided,         :state => 'voided'