Skip to content

Commit

Permalink
Fix payment/refund id lookup for govpay webhook error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulDoyle-EA committed Feb 9, 2025
1 parent 858b285 commit 1474ad1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/jobs/waste_carriers_engine/govpay_webhook_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def perform(webhook_body)
service_type = webhook_body.dig("resource", "moto") ? "back_office" : "front_office"
Rails.logger.error "Error running GovpayWebhookJob (#{service_type}): #{e}"
notification_params = {
refund_id: webhook_body["refund_id"],
payment_id: webhook_body["payment_id"],
refund_id: webhook_body.dig("resource", "refund_id"),
payment_id: webhook_body.dig("resource", "payment_id"),
service_type: service_type
}

Expand Down
8 changes: 8 additions & 0 deletions spec/jobs/waste_carriers_engine/govpay_webhook_job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ module WasteCarriersEngine
"reference" => "12345"
)
end

it "includes the payment_id outside the webhook body" do
captured_args = nil
allow(Airbrake).to receive(:notify) { |*args| captured_args = args }
perform_now

expect(captured_args[1][:payment_id]).to eq(webhook_body["resource"]["payment_id"])
end
end

it "includes webhook body in Airbrake notification" do
Expand Down

0 comments on commit 1474ad1

Please sign in to comment.