Sha256: 48c51b90a28df6804d074ad0eb6bc5f4e9cf07933e20bc1ee719b3ae474ad2ec

Contents?: true

Size: 1.77 KB

Versions: 4

Compression:

Stored size: 1.77 KB

Contents

module SolidusSixSaferpay
  class PaymentPageGateway < Gateway

    def inquire(saferpay_payment, options = {})
      inquire_response = perform_assert_request(saferpay_payment, options)

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

    # NOTE: Since PaymentPage payments are automatically authorized,
    # the passed amount has no effect because the payment is automatically
    # authorized for the full amount
    def authorize(_amount, saferpay_payment, options = {})
      assert(saferpay_payment, options)
    end

    def assert(saferpay_payment, options = {})
      assert_response = perform_assert_request(saferpay_payment, options)

      response(
        true,
        "Saferpay Payment Page assert response: #{assert_response.to_h}",
        assert_response
      )
    rescue SixSaferpay::Error => e
      handle_error(e, assert_response)
    end

    private

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

    def return_urls(order)
      SixSaferpay::ReturnUrls.new(
        success: url_helpers.solidus_six_saferpay_payment_page_success_url(order.number),
        fd_fail: url_helpers.solidus_six_saferpay_payment_page_fail_url(order.number),
        fd_abort: url_helpers.solidus_six_saferpay_payment_page_fail_url(order.number)
      )
    end

    def perform_assert_request(saferpay_payment, options = {})
      payment_page_assert = SixSaferpay::SixPaymentPage::Assert.new(token: saferpay_payment.token)
      SixSaferpay::Client.post(payment_page_assert)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_six_saferpay-0.5.0 lib/solidus_six_saferpay/payment_page_gateway.rb
solidus_six_saferpay-0.4.0 lib/solidus_six_saferpay/payment_page_gateway.rb
solidus_six_saferpay-0.3.0 lib/solidus_six_saferpay/payment_page_gateway.rb
solidus_six_saferpay-0.2.0 lib/solidus_six_saferpay/payment_page_gateway.rb