Class: Recurly::Transaction
- Defined in:
- lib/recurly/transaction.rb,
lib/recurly/transaction/errors.rb
Defined Under Namespace
Classes: ConfigurationError, DeclinedError, DuplicateError, Error, RetryableError
Class Attribute Summary collapse
-
.type ⇒ "credit", ...
readonly
The type of transaction.
Attributes inherited from Resource
#attributes, #etag, #response, #uri
Class Method Summary collapse
- .account ⇒ Account
-
.authorizations ⇒ Pager
A pager that yields
authorizations
transactions. -
.failed ⇒ Pager
A pager that yields
failed
transactions. - .initialize(attributes = {}) ⇒ Object
- .inspect ⇒ String
-
.purchases ⇒ Pager
A pager that yields
purchases
transactions. -
.refund(amount_in_cents = nil) ⇒ Transaction, false
Refunds the transaction.
-
.refunds ⇒ Pager
A pager that yields
refunds
transactions. -
.save ⇒ true, false
Saves new records only.
-
.successful ⇒ Pager
A pager that yields
successful
transactions. -
.voided ⇒ Pager
A pager that yields
voided
transactions.
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, #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)
Returns The type of transaction.
40 41 42 |
# File 'lib/recurly/transaction.rb', line 40 def type @type end |
Class Method Details
.authorizations ⇒ Pager
Returns a pager that yields authorizations
transactions.
8 |
# File 'lib/recurly/transaction.rb', line 8 scope :authorizations, :type => 'authorization' |
.failed ⇒ Pager
Returns a pager that yields failed
transactions.
13 |
# File 'lib/recurly/transaction.rb', line 13 scope :failed, :state => 'failed' |
.initialize(attributes = {}) ⇒ Object
43 44 45 |
# File 'lib/recurly/transaction.rb', line 43 def initialize attributes = {} super({ :currency => Recurly.default_currency }.merge attributes) end |
.inspect ⇒ String
72 73 74 75 76 77 78 |
# File 'lib/recurly/transaction.rb', line 72 def inspect attributes = self.class.attribute_names unless type == 'credit_card' attributes -= %w(cvv_result avs_result avs_result_street) end super attributes end |
.purchases ⇒ Pager
Returns a pager that yields purchases
transactions.
9 |
# File 'lib/recurly/transaction.rb', line 9 scope :purchases, :type => 'purchase' |
.refund(amount_in_cents = nil) ⇒ Transaction, false
Refunds the transaction.
64 65 66 67 68 69 |
# File 'lib/recurly/transaction.rb', line 64 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 |
.refunds ⇒ Pager
Returns a pager that yields refunds
transactions.
10 |
# File 'lib/recurly/transaction.rb', line 10 scope :refunds, :type => 'refund' |
.save ⇒ true, false
Saves new records only.
52 53 54 55 |
# File 'lib/recurly/transaction.rb', line 52 def save return super if new_record? raise Recurly::Error, "#{self.class.collection_name} cannot be updated" end |
.successful ⇒ Pager
Returns a pager that yields successful
transactions.
12 |
# File 'lib/recurly/transaction.rb', line 12 scope :successful, :state => 'successful' |
.voided ⇒ Pager
Returns a pager that yields voided
transactions.
14 |
# File 'lib/recurly/transaction.rb', line 14 scope :voided, :state => 'voided' |