Sha256: ab08b7ea3afd2e6adcaa68aab844245429c808956f479de9180227282ccf9f82

Contents?: true

Size: 774 Bytes

Versions: 1

Compression:

Stored size: 774 Bytes

Contents

# frozen_string_literal: true

module DefraRubyMocks
  class WorldpayController < ApplicationController

    before_action :set_default_response_format

    def payments_service
      response_values = WorldpayRequestService.run(request.body.read)

      @merchant_code = response_values[:merchant_code]
      @order_code = response_values[:order_code]
      @worldpay_id = response_values[:id]
      @worldpay_url = response_values[:url]

      respond_to :xml
    rescue StandardError
      head 500
    end

    def dispatcher
      success_url = params[:successURL]
      redirect_to WorldpayResponseService.run(success_url)
    rescue StandardError
      head 500
    end

    private

    def set_default_response_format
      request.format = :xml
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
defra_ruby_mocks-1.1.0 app/controllers/defra_ruby_mocks/worldpay_controller.rb