From 64424428e7e706aa481977f7db3fafe611e9e4f0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 5 Apr 2026 07:52:15 +0000 Subject: [PATCH] Quiet optional Stripe payment link failures Agent-Logs-Url: https://github.com/we-promise/sure/sessions/8eaf6809-26d1-4b47-9d44-b15b179c18c7 Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com> --- app/models/provider/stripe.rb | 5 ++--- test/models/provider/stripe_test.rb | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/models/provider/stripe.rb b/app/models/provider/stripe.rb index 402e32134..e7621c26a 100644 --- a/app/models/provider/stripe.rb +++ b/app/models/provider/stripe.rb @@ -75,9 +75,8 @@ class Provider::Stripe return nil if payment_link_id.blank? client.v1.payment_links.retrieve(payment_link_id).url - rescue StandardError => e - Sentry.capture_exception(e) - Rails.logger.error "Error fetching payment link #{payment_link_id}: #{e.message}" + rescue Stripe::StripeError => e + Rails.logger.debug { "Unable to fetch optional Stripe payment link #{payment_link_id}: #{e.message}" } nil end diff --git a/test/models/provider/stripe_test.rb b/test/models/provider/stripe_test.rb index e8f1fe076..5e033cfa3 100644 --- a/test/models/provider/stripe_test.rb +++ b/test/models/provider/stripe_test.rb @@ -85,17 +85,25 @@ class Provider::StripeTest < ActiveSupport::TestCase payment_links = mock payment_links.expects(:retrieve) .with("plink_test123") - .raises(StandardError, "not found") + .raises(Stripe::StripeError, "not found") client = mock client.stubs(:v1).returns(OpenStruct.new(payment_links: payment_links)) + captured_message = nil + logger = Object.new + logger.define_singleton_method(:debug) do |&block| + captured_message = block.call + end + Stripe::StripeClient.stubs(:new).returns(client) - Sentry.expects(:capture_exception).with(instance_of(StandardError)) - Rails.logger.expects(:error) - .with("Error fetching payment link plink_test123: not found") + Rails.stubs(:logger).returns(logger) stripe = Provider::Stripe.new(secret_key: "foo", webhook_secret: "bar") assert_nil stripe.payment_link_url(payment_link_id: "plink_test123") + assert_equal( + "Unable to fetch optional Stripe payment link plink_test123: not found", + captured_message + ) end end