Class: Kaui::Transaction
- Inherits:
-
KillBillClient::Model::Transaction
- Object
- KillBillClient::Model::Transaction
- Kaui::Transaction
- Defined in:
- app/models/kaui/transaction.rb
Class Method Summary collapse
Instance Method Summary collapse
- #amount_to_money ⇒ Object
- #create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object
Class Method Details
.amount_to_money(transaction) ⇒ Object
27 28 29 |
# File 'app/models/kaui/transaction.rb', line 27 def self.amount_to_money(transaction) self.new(:amount => transaction.amount, :currency => transaction.currency).amount_to_money end |
Instance Method Details
#amount_to_money ⇒ Object
23 24 25 |
# File 'app/models/kaui/transaction.rb', line 23 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
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/models/kaui/transaction.rb', line 3 def create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, = {}) if transaction_type == 'AUTHORIZE' auth(account_id, payment_method_id, user, reason, comment, ) elsif transaction_type == 'CAPTURE' capture(user, reason, comment, ) elsif transaction_type == 'CHARGEBACK' chargeback(user, reason, comment, ) elsif transaction_type == 'CREDIT' credit(account_id, payment_method_id, user, reason, comment, ) elsif transaction_type == 'PURCHASE' purchase(account_id, payment_method_id, user, reason, comment, ) elsif transaction_type == 'REFUND' refund(user, reason, comment, ) elsif transaction_type == 'VOID' void(user, reason, comment, ) else raise ArgumentError.new("Unknown transaction type #{transaction_type}") end end |