Class: DefraRubyMocks::GovpayTestHelpersController

Inherits:
ApplicationController show all
Includes:
CanUseAwsS3
Defined in:
app/controllers/defra_ruby_mocks/govpay_test_helpers_controller.rb

Constant Summary

Constants included from CanUseAwsS3

CanUseAwsS3::DEFAULT_LAST_REFUND_REQUEST_TIME

Instance Method Summary collapse

Instance Method Details

#send_payment_webhookObject

This schedules a job to send a mock payment webhook.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/defra_ruby_mocks/govpay_test_helpers_controller.rb', line 27

def send_payment_webhook
  Rails.logger.warn "[DefraRubyMocks] [send_payment_webhook] " \
                    "params: #{params[:govpay_id]}, status #{params[:payment_status]}"

  %w[govpay_id payment_status callback_url signing_secret].each do |p|
    raise StandardError, "Missing parameter: '#{p}'" unless params[p].present?
  end

  SendPaymentWebhookJob.perform_later(
    govpay_id: params[:govpay_id],
    status: params[:payment_status],
    callback_url: params[:callback_url],
    signing_secret: params[:signing_secret]
  )

  head 200
end

#send_refund_webhookObject

This schedules a job to send a mock refund webhook.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/defra_ruby_mocks/govpay_test_helpers_controller.rb', line 46

def send_refund_webhook
  Rails.logger.warn "[DefraRubyMocks] [send_refund webhook] " \
                    "params: #{params[:govpay_id]}, status #{params[:refund_status]}"

  %w[govpay_id refund_status callback_url signing_secret].each do |p|
    raise StandardError, "Missing parameter: '#{p}'" unless params[p].present?
  end

  SendRefundWebhookJob.perform_later(
    govpay_id: params[:govpay_id],
    status: params[:refund_status],
    callback_url: params[:callback_url],
    signing_secret: params[:signing_secret]
  )

  head 200
end

#set_test_payment_response_statusObject

The mock will use the value passed in to populate the status field on all future payments.



13
14
15
16
17
# File 'app/controllers/defra_ruby_mocks/govpay_test_helpers_controller.rb', line 13

def set_test_payment_response_status
  set_response_status(response_status_filename: "test_payment_response_status", status: params[:status])

  head 200
end

#set_test_refund_response_statusObject

The mock will use the value passed in to populate the status field on all future refunds.



20
21
22
23
24
# File 'app/controllers/defra_ruby_mocks/govpay_test_helpers_controller.rb', line 20

def set_test_refund_response_status
  set_response_status(response_status_filename: "test_refund_response_status", status: params[:status])

  head 200
end