Handle missing Stripe payment link gracefully

Agent-Logs-Url: https://github.com/we-promise/sure/sessions/efba0c75-5f82-41a1-b618-532d38e222da

Co-authored-by: jjmata <187772+jjmata@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-04 12:33:37 +00:00
committed by GitHub
parent e0d2150e2d
commit f1f1bc91cc
3 changed files with 36 additions and 0 deletions

View File

@@ -60,4 +60,20 @@ class Provider::StripeTest < ActiveSupport::TestCase
stripe.payment_link_url(payment_link_id: "plink_test123")
)
end
test "returns nil when payment link retrieval fails" do
payment_links = mock
payment_links.expects(:retrieve)
.with("plink_test123")
.raises(StandardError, "not found")
client = mock
client.stubs(:v1).returns(OpenStruct.new(payment_links: payment_links))
Stripe::StripeClient.stubs(:new).returns(client)
Sentry.expects(:capture_exception).with(instance_of(StandardError))
stripe = Provider::Stripe.new(secret_key: "foo", webhook_secret: "bar")
assert_nil stripe.payment_link_url(payment_link_id: "plink_test123")
end
end