Sha256: 12b0ba92827152da6df7f593d6ff22bca79a4f3f0e2b2b81927f0b1967a9aab7
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
module Laundry module PaymentsGateway class Account < ResponseModel def initialize_with_response(response) self.record = response[:get_payment_method_response][:get_payment_method_result][:payment_method] end # EFT TRANSACTION_CODES EFT_SALE = 20 EFT_AUTH_ONLY = 21 EFT_CAPTURE = 22 EFT_CREDIT = 23 EFT_VOID = 24 EFT_FORCE = 25 EFT_VERIFY_ONLY = 26 def debit_cents(cents, *args) debit_dollars(dollarize(cents), *args) end def credit_cents(cents, *args) credit_dollars(dollarize(cents), *args) end def debit_dollars(dollars, *args) perform_transaction(dollars, EFT_SALE, *args) end def credit_dollars(dollars, *args) perform_transaction(dollars, EFT_CREDIT, *args) end def perform_transaction(dollars, type, options = {}) require_merchant! options = { 'pg_merchant_id' => self.merchant.id, 'pg_password' => self.merchant.transaction_password, 'pg_total_amount' => dollars, 'pg_client_id' => self.client_id, 'pg_payment_method_id' => self.id, 'pg_transaction_type' => type }.merge(options) r = self.merchant.socket_driver.exec(options) TransactionResponse.from_response(r, self.merchant) end def id payment_method_id end private def dollarize(cents) cents.to_f / 100.0 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
laundry-0.0.8 | lib/laundry/payments_gateway/models/account.rb |
laundry-0.0.7 | lib/laundry/payments_gateway/models/account.rb |
laundry-0.0.6 | lib/laundry/payments_gateway/models/account.rb |