From 121019411ceb65e613ec144e55cf0840a2b685a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <2887858+deivid-rodriguez@users.noreply.github.com> Date: Wed, 22 Oct 2025 18:53:32 +0200 Subject: [PATCH] Fix spec instantiating payment method with wrong source Previous error is fixed, which allows the spec to proceed further, and reveals that the current cassettes are missing some requests: ``` 1) Stripe::PaymentIntentValidator#call as a guest when payment intent is valid valid non-3D credit cards are correctly handled behaves like payments intents from Visa returns payment intent id and does not raise Failure/Error: payment_intent_response = Stripe::PaymentIntent.retrieve( payment_intent_id, stripe_account: stripe_account_id ) VCR::Errors::UnhandledHTTPRequestError: ================================================================================ An HTTP request has been made that VCR does not know how to handle: GET https://api.stripe.com/v1/payment_intents/pi_3P8hNGKuuB1fWySn0dvhu9lG VCR is currently using the following cassette: (...) ``` --- spec/lib/stripe/payment_intent_validator_spec.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/spec/lib/stripe/payment_intent_validator_spec.rb b/spec/lib/stripe/payment_intent_validator_spec.rb index 11f11f25f1..394f8fb239 100644 --- a/spec/lib/stripe/payment_intent_validator_spec.rb +++ b/spec/lib/stripe/payment_intent_validator_spec.rb @@ -12,9 +12,11 @@ RSpec.describe Stripe::PaymentIntentValidator do let(:year_valid) { Time.zone.now.year.next } describe "#call", :vcr, :stripe_version do + let!(:user) { create(:user, email: "apple.customer@example.com") } + let(:credit_card) { create(:credit_card, user:) } let(:payment) { create(:payment, amount: payment_intent.amount, payment_method:, - response_code: payment_intent.id, source: pm_card) + response_code: payment_intent.id, source: credit_card) } let(:validator) { Stripe::PaymentIntentValidator.new(payment) } @@ -153,8 +155,6 @@ RSpec.describe Stripe::PaymentIntentValidator do context "when payment intent is valid" do let(:payment_method_id) { pm_card.id } let(:customer_id) { customer.id } - let!(:user) { create(:user, email: "apple.customer@example.com") } - let(:credit_card) { create(:credit_card, gateway_payment_profile_id: pm_card.id, user:) } let(:customer) do Stripe::Customer.create({ name: 'Apple Customer', @@ -244,8 +244,6 @@ RSpec.describe Stripe::PaymentIntentValidator do context "when payment intent is invalid" do let(:payment_method_id) { pm_card.id } let(:customer_id) { customer.id } - let!(:user) { create(:user, email: "apple.customer@example.com") } - let(:credit_card) { create(:credit_card, gateway_payment_profile_id: pm_card.id, user:) } let(:customer) do Stripe::Customer.create({ name: 'Apple Customer',