Class: Kaui::Transaction
- Inherits:
-
KillBillClient::Model::Transaction
- Object
- KillBillClient::Model::Transaction
- Kaui::Transaction
- Defined in:
- app/models/kaui/transaction.rb
Instance Attribute Summary collapse
-
#next_retry_date ⇒ Object
Returns the value of attribute next_retry_date.
Class Method Summary collapse
- .amount_to_money(transaction) ⇒ Object
- .build_from_raw_transaction(raw_transaction) ⇒ Object
- .processed_amount_to_money(transaction) ⇒ Object
Instance Method Summary collapse
- #amount_to_money ⇒ Object
- #create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
- #processed_amount_to_money ⇒ Object
Instance Attribute Details
#next_retry_date ⇒ Object
Returns the value of attribute next_retry_date.
5 6 7 |
# File 'app/models/kaui/transaction.rb', line 5 def next_retry_date @next_retry_date end |
Class Method Details
.amount_to_money(transaction) ⇒ Object
44 45 46 |
# File 'app/models/kaui/transaction.rb', line 44 def self.amount_to_money(transaction) new(amount: transaction.amount, currency: transaction.currency).amount_to_money end |
.build_from_raw_transaction(raw_transaction) ⇒ Object
7 8 9 10 11 12 13 |
# File 'app/models/kaui/transaction.rb', line 7 def self.build_from_raw_transaction(raw_transaction) result = Kaui::Transaction.new KillBillClient::Model::PaymentTransactionAttributes.instance_variable_get('@json_attributes').each do |attr| result.send("#{attr}=", raw_transaction.send(attr)) end result end |
.processed_amount_to_money(transaction) ⇒ Object
48 49 50 |
# File 'app/models/kaui/transaction.rb', line 48 def self.processed_amount_to_money(transaction) new(processed_amount: transaction.processed_amount, processed_currency: transaction.processed_currency).processed_amount_to_money end |
Instance Method Details
#amount_to_money ⇒ Object
36 37 38 |
# File 'app/models/kaui/transaction.rb', line 36 def amount_to_money Kaui::Base.to_money(amount, currency) end |
#create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/kaui/transaction.rb', line 15 def create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, = {}) case transaction_type when 'AUTHORIZE' auth(account_id, payment_method_id, user, reason, comment, ) when 'CAPTURE' capture(user, reason, comment, ) when 'CHARGEBACK' chargeback(user, reason, comment, ) when 'CREDIT' credit(account_id, payment_method_id, user, reason, comment, ) when 'PURCHASE' purchase(account_id, payment_method_id, user, reason, comment, ) when 'REFUND' refund(user, reason, comment, ) when 'VOID' void(user, reason, comment, ) else raise ArgumentError, "Unknown transaction type #{transaction_type}" end end |