Sha256: c326542b18e29476e80d09a9b73f44dcf65437ec3e5af4410b5a24e83cb5c654

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

module Workarea
  class Payment
    class Refund
      class Sezzle
        include OperationImplementation
        include CreditCardOperation

        def complete!
          response = gateway.refund(tender.sezzle_id, transaction_options)
          if response.success?
            transaction.response = ActiveMerchant::Billing::Response.new(
              true,
              I18n.t(
                'workarea.sezzle.refund',
                amount: transaction.amount
              ),
              response.body
            )
          else
            transaction.response = ActiveMerchant::Billing::Response.new(
              false,
              I18n.t('workarea.sezzle.refund'),
              response.body
            )
          end
        end

        def cancel!
          #no-op - nothing to role back on refund.
        end

        private

        def gateway
          Workarea::Sezzle.gateway
        end

        def transaction_options
          {
            amount_in_cents: transaction.amount.cents,
            currency: transaction.amount.currency.iso_code
          }
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
workarea-sezzle-1.0.6 app/models/workarea/payment/refund/sezzle.rb
workarea-sezzle-1.0.5 app/models/workarea/payment/refund/sezzle.rb
workarea-sezzle-1.0.4 app/models/workarea/payment/refund/sezzle.rb
workarea-sezzle-1.0.3 app/models/workarea/payment/refund/sezzle.rb
workarea-sezzle-1.0.2 app/models/workarea/payment/refund/sezzle.rb
workarea-sezzle-1.0.1 app/models/workarea/payment/refund/sezzle.rb
workarea-sezzle-1.0.0 app/models/workarea/payment/refund/sezzle.rb