Sha256: ba45c3e52618564fe557393ddfae853f21a5fda30ba29a0a1b4b24167c29044a
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
require 'quick_travel/adapter' require 'quick_travel/credit_card' module QuickTravel class Payment < Adapter attr_accessor :id, :payment_type_id, :amount_in_cents, :authorization, :success, :created_at money :amount def payment_type QuickTravel::PaymentType.find(@payment_type_id) end def self.create(options = {}) post_and_validate("/front_office/bookings/#{options[:booking_id]}/payments.json", options) end def self.get_redirect_url(options) response = get_and_validate("/api/checkouts/migs_redirect_url.json", options) response[:redirect_url] end def self.handle_redirected_payment(options) get_and_validate('/api/redirected_payments', options) 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
quicktravel_client-1.1.2 | lib/quick_travel/payment.rb |
quicktravel_client-1.1.1 | lib/quick_travel/payment.rb |
quicktravel_client-1.1.0 | lib/quick_travel/payment.rb |