Skip to content

Commit

Permalink
enables slack message on fine payment
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Jun 6, 2024
1 parent a62f250 commit 2815e38
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/routes/fines_and_fees.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
post "/pay" do
fines = Fines.for(uniqname: session[:uniqname])
total_sum = fines.total_sum.to_f
# 2024-06-06 This messages mrio when there's a fine to make it easier to determine if the fines bug is still happening.
begin
HTTParty.post(S.slack_url, headers: {"Content-type" => "application/json"}, body: {text: "Someone started a fine payment attempt in account"}.to_json)
rescue
S.logger.error("Couldn't send slack message")
end

amount = (params["pay_in_full"] == "true") ? total_sum : params["partial_amount"].to_f
if amount <= total_sum
nelnet = Nelnet.new(amount_due: amount.to_currency)
Expand Down
4 changes: 4 additions & 0 deletions lib/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,8 @@
SemanticLogger["account"]
end

S.register(:slack_url) do
ENV["SLACK_URL"] || "https://hooks.slack.com/services/WHATEVERELSE"
end

SemanticLogger.add_appender(io: S.log_stream, level: :info) unless ENV["APP_ENV"] == "test"
1 change: 1 addition & 0 deletions models/fines/receipt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def self.for(uniqname:, nelnet_params:, order_number:, is_valid: Nelnet.verify(n
S.logger.error("Fine payment error: order number #{order_number}; message: #{error.message}")
ErrorReceipt.new("#{error.message}<br>Your payment order number is: #{order_number}")
else
S.logger.info("Fine payment success")
Receipt.new(payment: payment, balance: resp.parsed_response["total_sum"])
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/requests/fines_and_fees_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
context "post /fines-and-fees/pay" do
before(:each) do
@stub = stub_alma_get_request(url: "users/tutor/fees", body: File.read("./spec/fixtures/jbister_fines.json"), query: {limit: 100, offset: 0})
stub_request(:post, S.slack_url) # Don't care about the slack url for testing purposes
end
it "for pay in full redirects to nelnet with total amountDue" do
post "/fines-and-fees/pay", {"pay_in_full" => "true", "partial_amount" => "0.00"}
Expand Down

0 comments on commit 2815e38

Please sign in to comment.