Sha256: 6b5b087a518ab60aebe344ad891c708b201e7cc16879c3db4cc5faaf1bd60b86

Contents?: true

Size: 969 Bytes

Versions: 17

Compression:

Stored size: 969 Bytes

Contents

require 'quick_travel/adapter'
require 'quick_travel/credit_card'

module QuickTravel
  class Payment < Adapter
    def payment_type
      QuickTravel::PaymentType.find(@payment_type_id)
    end

    def self.charge_account(booking, payment_options = {})
      payment_type = booking.on_account_payment_type

      if payment_type.nil?
        fail ArgumentError, 'Booking not allowed to be paid on account'
      end

      agent_booking_reference = payment_options[:agent_booking_reference]
      amount                  = payment_options[:amount].presence

      options = {
        payment: {
          payment_type_id:   payment_type.id,
          uid:               SecureRandom.hex(16),
          comment:           agent_booking_reference,
          amount:            amount,
          currency_iso_code: 'AUD'
        },
        pay_balance: amount.nil?
      }

      post_and_validate("/api/bookings/#{booking.id}/payments.json", options)
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
quicktravel_client-4.7.0 lib/quick_travel/payment.rb
quicktravel_client-4.6.0 lib/quick_travel/payment.rb
quicktravel_client-4.5.0 lib/quick_travel/payment.rb
quicktravel_client-4.4.0 lib/quick_travel/payment.rb
quicktravel_client-4.3.2 lib/quick_travel/payment.rb
quicktravel_client-4.3.1 lib/quick_travel/payment.rb
quicktravel_client-4.3.0 lib/quick_travel/payment.rb
quicktravel_client-4.2.0 lib/quick_travel/payment.rb
quicktravel_client-4.1.0 lib/quick_travel/payment.rb
quicktravel_client-4.0.0 lib/quick_travel/payment.rb
quicktravel_client-3.9.0 lib/quick_travel/payment.rb
quicktravel_client-3.8.1 lib/quick_travel/payment.rb
quicktravel_client-3.8.0 lib/quick_travel/payment.rb
quicktravel_client-3.7.0 lib/quick_travel/payment.rb
quicktravel_client-3.6.1 lib/quick_travel/payment.rb
quicktravel_client-3.6.0 lib/quick_travel/payment.rb
quicktravel_client-3.5.0 lib/quick_travel/payment.rb