Class: 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
-
#type ⇒ "credit", ...
readonly
The type of transaction.
Attributes inherited from Resource
#attributes, #etag, #response, #uri
Class Method Summary collapse
-
.authorizations ⇒ Pager
A pager that yields authorizations transactions.
-
.failed ⇒ Pager
A pager that yields failed transactions.
-
.purchases ⇒ Pager
A pager that yields purchases transactions.
-
.refunds ⇒ Pager
A pager that yields refunds transactions.
-
.successful ⇒ Pager
A pager that yields successful transactions.
- .to_xml(attrs) ⇒ Object
-
.voided ⇒ Pager
A pager that yields voided transactions.
Instance Method Summary collapse
- #account ⇒ Account
-
#initialize(attributes = {}) ⇒ Transaction
constructor
A new instance of Transaction.
- #inspect ⇒ String
- #invoice ⇒ Invoice?
- #original_transaction ⇒ Transaction?
-
#refund(amount_in_cents = nil) ⇒ Transaction, false
Refunds the transaction.
-
#save ⇒ true, false
Saves new records only.
- #signable_attributes ⇒ Object
- #subscriptions ⇒ Pager<Subscription>?
Methods inherited from Resource
#==, all, #apply_errors, #as_json, association_class_name, associations, associations_for_relation, associations_helper, belongs_to, #changed, #changed?, #changed_attributes, #changes, collection_name, count, create, create!, define_attribute_methods, #destroy, #destroyed?, embedded!, #errors, find, find_association, find_each, find_resource_class, first, #follow_link, from_response, from_xml, has_many, has_one, #link?, #links, #marshal_dump, #marshal_load, member_name, member_path, #new_record?, paginate, #persist!, #persisted?, #previous_changes, #read_attribute, reflect_on_association, #reload, resource_name, #save!, scope, scopes, scopes_helper, #to_xml, #update_attributes, #update_attributes!, #valid?, #write_attribute
Constructor Details
#initialize(attributes = {}) ⇒ Transaction
Returns a new instance of Transaction
73 74 75 |
# File 'lib/recurly/transaction.rb', line 73 def initialize(attributes = {}) super({ :currency => Recurly.default_currency }.merge attributes) end |
Instance Attribute Details
#type ⇒ "credit", ... (readonly)
Returns The type of transaction.
70 71 72 |
# File 'lib/recurly/transaction.rb', line 70 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.
12 |
# File 'lib/recurly/transaction.rb', line 12 scope :failed, state: 'failed' |
.purchases ⇒ Pager
Returns a pager that yields purchases transactions.
9 |
# File 'lib/recurly/transaction.rb', line 9 scope :purchases, type: 'purchase' |
.refunds ⇒ Pager
Returns a pager that yields refunds transactions.
10 |
# File 'lib/recurly/transaction.rb', line 10 scope :refunds, type: 'refund' |
.successful ⇒ Pager
Returns a pager that yields successful transactions.
11 |
# File 'lib/recurly/transaction.rb', line 11 scope :successful, state: 'successful' |
.to_xml(attrs) ⇒ Object
64 65 66 67 |
# File 'lib/recurly/transaction.rb', line 64 def self.to_xml(attrs) transaction = new attrs transaction.to_xml end |
.voided ⇒ Pager
Returns a pager that yields voided transactions.
13 |
# File 'lib/recurly/transaction.rb', line 13 scope :voided, state: 'voided' |
Instance Method Details
#inspect ⇒ String
108 109 110 111 112 113 114 |
# File 'lib/recurly/transaction.rb', line 108 def inspect attributes = self.class.attribute_names unless type == 'credit_card' attributes -= %w(cvv_result avs_result avs_result_street) end super attributes end |
#original_transaction ⇒ Transaction?
24 |
# File 'lib/recurly/transaction.rb', line 24 has_one :original_transaction, class_name: :Transaction, readonly: true |
#refund(amount_in_cents = nil) ⇒ Transaction, false
Refunds the transaction.
95 96 97 98 99 100 101 |
# File 'lib/recurly/transaction.rb', line 95 def refund amount_in_cents = nil return false unless link? :refund refund = self.class.from_response( follow_link :refund, :params => { :amount_in_cents => amount_in_cents } ) refund.uuid == uuid ? copy_from(refund) && self : refund end |
#save ⇒ true, false
Saves new records only.
82 83 84 85 |
# File 'lib/recurly/transaction.rb', line 82 def save return super if new_record? raise Recurly::Error, "#{self.class.collection_name} cannot be updated" end |
#signable_attributes ⇒ Object
103 104 105 |
# File 'lib/recurly/transaction.rb', line 103 def signable_attributes super.merge :amount_in_cents => amount_in_cents, :currency => currency end |
#subscriptions ⇒ Pager<Subscription>?
21 |
# File 'lib/recurly/transaction.rb', line 21 has_many :subscriptions |