Class: Spree::Refund
- Includes:
- Metadata
- Defined in:
- app/models/spree/refund.rb
Instance Attribute Summary collapse
-
#perform_response ⇒ Object
readonly
Returns the value of attribute perform_response.
Class Method Summary collapse
Instance Method Summary collapse
-
#amount=(price) ⇒ Object
Sets this price’s amount to a new value, parsing it if the new value is a string.
- #description ⇒ Object
- #money ⇒ Object (also: #display_amount)
-
#perform! ⇒ Object
Must be called for the refund transaction to be processed.
Methods inherited from Base
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Instance Attribute Details
#perform_response ⇒ Object (readonly)
Returns the value of attribute perform_response.
19 20 21 |
# File 'app/models/spree/refund.rb', line 19 def perform_response @perform_response end |
Class Method Details
.total_amount_reimbursed_for(reimbursement) ⇒ Object
31 32 33 |
# File 'app/models/spree/refund.rb', line 31 def total_amount_reimbursed_for(reimbursement) reimbursement.refunds.to_a.sum(&:amount) end |
Instance Method Details
#amount=(price) ⇒ Object
Sets this price’s amount to a new value, parsing it if the new value is a string.
40 41 42 |
# File 'app/models/spree/refund.rb', line 40 def amount=(price) self[:amount] = Spree::LocalizedNumber.parse(price) end |
#description ⇒ Object
44 45 46 |
# File 'app/models/spree/refund.rb', line 44 def description payment.payment_method.name end |
#money ⇒ Object Also known as: display_amount
25 26 27 |
# File 'app/models/spree/refund.rb', line 25 def money Spree::Money.new(amount, { currency: }) end |
#perform! ⇒ Object
Must be called for the refund transaction to be processed.
Attempts to perform the refund, raises an error if the refund fails.
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/models/spree/refund.rb', line 52 def perform! return true if transaction_id.present? credit_cents = money.cents @perform_response = process!(credit_cents) log_entries.build(parsed_payment_response_details_with_fallback: perform_response) self.transaction_id = perform_response. save! update_order end |