Sha256: 69dea211647b0c2b50e8837482bfe459fd8db4bc110e64fb8279ff634e74683f
Contents?: true
Size: 799 Bytes
Versions: 34
Compression:
Stored size: 799 Bytes
Contents
module Workarea class Checkout class CollectPayment delegate :payment, to: :@checkout def initialize(checkout) @checkout = checkout @order = checkout.order end def valid? if balance > 0 payment.errors.add( :base, I18n.t('workarea.payment.insufficient_payment', balance: balance) ) return false end true end def balance @order.total_price - payment.tendered_amount end def purchase return true if @order.total_price.zero? return false unless valid? payment.send(action, checkout: @checkout) end def action Workarea.config.auto_capture ? 'purchase!' : 'authorize!' end end end end
Version data entries
34 entries across 34 versions & 1 rubygems