Sha256: 176b325c08fb1616f7d7157c63d3f09db65f65c6c7fa7f4078ecbbcc62727082

Contents?: true

Size: 1.52 KB

Versions: 9

Compression:

Stored size: 1.52 KB

Contents

module SolidusSixSaferpay
  class TransactionGateway < Gateway

    def initialize(options = {})
      super(
        options.merge(
          success_url: url_helpers.solidus_six_saferpay_transaction_success_url,
          fail_url: url_helpers.solidus_six_saferpay_transaction_fail_url
        )
      )
    end

    def inquire(saferpay_payment, options = {})
      transaction_inquire = SixSaferpay::SixTransaction::Inquire.new(transaction_reference: saferpay_payment.transaction_id)
      inquire_response = SixSaferpay::Client.post(transaction_inquire)

      response(
        true,
        "Saferpay Transaction inquire response: #{inquire_response.to_h}",
        inquire_response
      )
    rescue SixSaferpay::Error => e
      handle_error(e, inquire_response)
    end

    # NOTE: Saferpay does not allow authorization for partial amounts.
    # Therefore, the given amount is ignored
    def authorize(_amount, saferpay_payment, options = {})
      transaction_authorize = SixSaferpay::SixTransaction::Authorize.new(token: saferpay_payment.token)
      authorize_response = SixSaferpay::Client.post(transaction_authorize)

      response(
        true,
        "Saferpay Transaction authorize response: #{authorize_response.to_h}",
        authorize_response
      )
    rescue SixSaferpay::Error => e
      handle_error(e, authorize_response)
    end

    private

    def interface_initialize_object(order, payment_method)
      SixSaferpay::SixTransaction::Initialize.new(interface_initialize_params(order, payment_method))
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
solidus_six_saferpay-0.1.8.1 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.8 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.7 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.5 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.4 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.3 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.2 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.1 lib/solidus_six_saferpay/transaction_gateway.rb
solidus_six_saferpay-0.1.0 lib/solidus_six_saferpay/transaction_gateway.rb