Class: Recurly::Transaction
- Inherits:
-
Resource
- Object
- Resource
- Recurly::Transaction
- Defined in:
- lib/recurly/transaction.rb,
lib/recurly/transaction/errors.rb
Defined Under Namespace
Classes: ConfigurationError, DeclinedError, DuplicateError, Error, RetryableError
Instance Attribute Summary (collapse)
-
- ("credit", ...) type
readonly
The type of transaction.
Attributes inherited from Resource
#attributes, #etag, #response, #uri
Class Method Summary (collapse)
-
+ (Pager) authorizations
A pager that yields authorizations transactions.
-
+ (Pager) failed
A pager that yields failed transactions.
-
+ (Pager) purchases
A pager that yields purchases transactions.
-
+ (Pager) refunds
A pager that yields refunds transactions.
-
+ (Pager) successful
A pager that yields successful transactions.
-
+ (Pager) voided
A pager that yields voided transactions.
Instance Method Summary (collapse)
- - (Account) account
-
- (Transaction) initialize(attributes = {})
constructor
A new instance of Transaction.
- - (String) inspect
-
- (Transaction, false) refund(amount_in_cents = nil)
Refunds the transaction.
-
- (true, false) save
Saves new records only.
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, member_name, member_path, #new_record?, paginate, #persist!, #persisted?, #previous_changes, #read_attribute, reflect_on_association, #reload, resource_name, #save!, scope, scopes, #to_xml, #update_attributes, #update_attributes!, #valid?, #write_attribute
Constructor Details
- (Transaction) initialize(attributes = {})
A new instance of Transaction
43 44 45 |
# File 'lib/recurly/transaction.rb', line 43 def initialize attributes = {} super({ :currency => Recurly.default_currency }.merge attributes) end |
Instance Attribute Details
- ("credit", ...) type (readonly)
The type of transaction.
40 41 42 |
# File 'lib/recurly/transaction.rb', line 40 def type @type end |
Class Method Details
+ (Pager) authorizations
A pager that yields authorizations transactions.
8 |
# File 'lib/recurly/transaction.rb', line 8 scope :authorizations, :type => 'authorization' |
+ (Pager) failed
A pager that yields failed transactions.
13 |
# File 'lib/recurly/transaction.rb', line 13 scope :failed, :state => 'failed' |
+ (Pager) purchases
A pager that yields purchases transactions.
9 |
# File 'lib/recurly/transaction.rb', line 9 scope :purchases, :type => 'purchase' |
+ (Pager) refunds
A pager that yields refunds transactions.
10 |
# File 'lib/recurly/transaction.rb', line 10 scope :refunds, :type => 'refund' |
+ (Pager) successful
A pager that yields successful transactions.
12 |
# File 'lib/recurly/transaction.rb', line 12 scope :successful, :state => 'successful' |
+ (Pager) voided
A pager that yields voided transactions.
14 |
# File 'lib/recurly/transaction.rb', line 14 scope :voided, :state => 'voided' |
Instance Method Details
- (String) inspect
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 |
- (Transaction, false) refund(amount_in_cents = nil)
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 |
- (true, false) save
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 |