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:

       (...)
```
This commit is contained in:
David Rodríguez
2025-10-22 18:53:32 +02:00
parent 1a5eb5b39a
commit 121019411c

View File

@@ -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',