Skip to content

Commit

Permalink
Merge branch 'main' into feature/RUBY-2477-wcr-tech-upgrade-to-rails-7
Browse files Browse the repository at this point in the history
  • Loading branch information
jjromeo authored Oct 2, 2023
2 parents a76dbb9 + 24303e6 commit ee1af52
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 245 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ gemspec
# GOV.UK styling
gem "defra_ruby_template", "~> 3.13.0"

# GovPay integration
gem "defra_ruby_govpay"

# Use MongoDB as the database
gem "mongoid", "~> 8.0.3"

Expand Down
17 changes: 10 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ GEM
notifications-ruby-client
rails
sprockets-rails
defra_ruby_govpay (0.2.0)
rest-client (~> 2.1)
defra_ruby_style (0.3.0)
rubocop (>= 1.0, < 2.0)
defra_ruby_template (3.13.0)
defra_ruby_validators (2.5.1)
defra_ruby_validators (2.5.2)
activemodel
i18n
matrix
Expand Down Expand Up @@ -237,9 +239,9 @@ GEM
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
mime-types (3.4.1)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.0218.1)
mime-types-data (3.2023.0808)
mini_mime (1.1.2)
mini_portile2 (2.8.4)
minitest (5.19.0)
Expand All @@ -262,7 +264,7 @@ GEM
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-smtp (0.4.0)
net-protocol
netrc (0.11.0)
nio4r (2.5.9)
Expand Down Expand Up @@ -296,7 +298,7 @@ GEM
pry (>= 0.13, < 0.15)
public_suffix (5.0.3)
racc (1.7.1)
rack (2.2.7)
rack (2.2.8)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.5)
Expand Down Expand Up @@ -427,7 +429,7 @@ GEM
thor (1.2.2)
tilt (2.2.0)
timecop (0.9.8)
timeout (0.3.2)
timeout (0.4.0)
timers (4.3.5)
traces (0.11.1)
turbolinks (5.2.1)
Expand All @@ -446,7 +448,7 @@ GEM
vcr (6.2.0)
warden (1.2.9)
rack (>= 2.0.9)
web-console (4.2.0)
web-console (4.2.1)
actionview (>= 6.0.0)
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
Expand All @@ -468,6 +470,7 @@ PLATFORMS
DEPENDENCIES
cancancan (~> 3.5.0)
database_cleaner-mongoid (~> 2.0.1)
defra_ruby_govpay
defra_ruby_style (~> 0.3.0)
defra_ruby_template (~> 3.13.0)
devise (~> 4.9.2)
Expand Down
8 changes: 0 additions & 8 deletions app/models/waste_carriers_engine/govpay/error.rb

This file was deleted.

47 changes: 0 additions & 47 deletions app/models/waste_carriers_engine/govpay/object.rb

This file was deleted.

17 changes: 0 additions & 17 deletions app/models/waste_carriers_engine/govpay/payment.rb

This file was deleted.

15 changes: 0 additions & 15 deletions app/models/waste_carriers_engine/govpay/refund.rb

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def pdf_content
template: "waste_carriers_engine/pdfs/certificate",
encoding: "UTF-8",
layout: false,
locals: { presenter: certificate_presenter }
locals: { presenter: certificate_presenter },
enable_local_file_access: true,
allow: [WasteCarriersEngine::Engine.root.join("app", "assets", "images", "environment_agency_logo.png").to_s]
)
end
end
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module WasteCarriersEngine
class GovpayPaymentDetailsService
include CanSendGovpayRequest

def initialize(govpay_id: nil, is_moto: false, payment_uuid: nil,
entity: ::WasteCarriersEngine::TransientRegistration)
Expand All @@ -25,7 +24,7 @@ def govpay_payment_status
rescue StandardError => e
Rails.logger.error "#{e.class} error retrieving status for payment, " \
"uuid #{@payment_uuid}, govpay id #{govpay_id}: #{e}"
Airbrake.notify(e, message: "Failed to retrieve status for payment",
Airbrake.notify(e, message: e.message,
payment_uuid:,
govpay_id:,
entity:)
Expand All @@ -34,7 +33,7 @@ def govpay_payment_status
end

def payment
@payment ||= Govpay::Payment.new(response)
@payment ||= DefraRubyGovpay::Payment.new(response)
end

# Payment status in application terms
Expand All @@ -56,10 +55,10 @@ def self.payment_status(status)
def response
@response ||=
JSON.parse(
send_request(method: :get,
path: "/payments/#{govpay_id}",
is_moto: @is_moto,
params: nil)&.body
DefraRubyGovpayAPI.send_request(method: :get,
path: "/payments/#{govpay_id}",
is_moto: @is_moto,
params: nil)&.body
)
end

Expand Down
12 changes: 7 additions & 5 deletions app/services/waste_carriers_engine/govpay_payment_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

module WasteCarriersEngine
class GovpayPaymentService
include CanSendGovpayRequest

def initialize(transient_registration, order, current_user)
@transient_registration = transient_registration
Expand All @@ -13,10 +12,13 @@ def initialize(transient_registration, order, current_user)
end

def prepare_for_payment
response = send_request(method: :post,
path: "/payments",
is_moto: WasteCarriersEngine.configuration.host_is_back_office?,
params: payment_params)
response = DefraRubyGovpayAPI.send_request(
method: :post,
path: "/payments",
is_moto: WasteCarriersEngine.configuration.host_is_back_office?,
params: payment_params
)

response_json = JSON.parse(response.body)

govpay_payment_id = response_json["payment_id"]
Expand Down
12 changes: 12 additions & 0 deletions config/initializers/govpay.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

require "defra_ruby_govpay"

DefraRubyGovpay.configure do |config|
config.govpay_url = Rails.configuration.govpay_url
config.govpay_front_office_api_token = Rails.configuration.govpay_front_office_api_token
config.govpay_back_office_api_token = Rails.configuration.govpay_back_office_api_token
config.host_is_back_office = WasteCarriersEngine.configuration.host_is_back_office?
end

DefraRubyGovpayAPI = DefraRubyGovpay::API.new
13 changes: 10 additions & 3 deletions spec/requests/waste_carriers_engine/govpay_forms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,17 @@ module WasteCarriersEngine
let(:order_key) { "#{Rails.configuration.govpay_merchant_code}^#{order.order_code}" }

before do
allow(Rails.configuration).to receive(:govpay_url).and_return(govpay_host)
allow(Rails.configuration).to receive(:govpay_merchant_code).and_return("some_merchant_code")
allow(Rails.configuration).to receive(:govpay_front_office_api_token).and_return("some_token")
allow(Rails.configuration).to receive(:govpay_back_office_api_token).and_return("some_token")

# set these variables in govpay configuration
DefraRubyGovpay.configure do |config|
config.govpay_url = govpay_host
config.govpay_front_office_api_token = "some_token"
config.govpay_back_office_api_token = "some_token"
end

stub_const("DefraRubyGovpayAPI", DefraRubyGovpay::API.new)

allow(Airbrake).to receive(:notify)
end

Expand Down
12 changes: 0 additions & 12 deletions spec/services/waste_carriers_engine/govpay/objects/error_spec.rb

This file was deleted.

25 changes: 0 additions & 25 deletions spec/services/waste_carriers_engine/govpay/objects/payment_spec.rb

This file was deleted.

Loading

0 comments on commit ee1af52

Please sign in to comment.