Sha256: 1d96993c4a111ee5e91a21806c19d78a82df71bca14a280a22bc8e3d94a8a716

Contents?: true

Size: 1.04 KB

Versions: 1

Compression:

Stored size: 1.04 KB

Contents

module Workarea
  class Payment
    class Capture
      class Affirm
        include OperationImplementation
        include CreditCardOperation

        def complete!
          response = gateway.capture(charge_id, transaction.amount, tender.payment.id)

          transaction.response = if response.success?
            ActiveMerchant::Billing::Response.new(
              true,
              I18n.t(
                'workarea.affirm.capture',
               amount: transaction.amount
              ),
              response.body
            )
            else
              ActiveMerchant::Billing::Response.new(
                false,
                I18n.t('workarea.affirm.capture_failure'),
                response.body
              )
            end
        end

        def cancel!
          # No op - no cancel functionality available.
        end

        private

        def charge_id
          transaction.reference.response.params['id']
        end

        def gateway
          Workarea::Affirm.gateway
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
workarea-affirm-1.0.0 app/models/workarea/payment/capture/affirm.rb