diff --git a/app/controllers/discourse_subscriptions/user/payments_controller.rb b/app/controllers/discourse_subscriptions/user/payments_controller.rb index 4325759..7bc4712 100644 --- a/app/controllers/discourse_subscriptions/user/payments_controller.rb +++ b/app/controllers/discourse_subscriptions/user/payments_controller.rb @@ -102,14 +102,13 @@ module DiscourseSubscriptions end # Check if there are more charges to fetch - break if charges[:data].empty? break if charges[:data].count < 100 # Set starting_after to the last charge's ID for the next batch starting_after = charges[:data].last[:id] end rescue ::Stripe::StripeError => e - Rails.logger.error("Stripe API error: #{e.message}") + render_json_error e.message end guest_payments diff --git a/spec/requests/user/payments_controller_spec.rb b/spec/requests/user/payments_controller_spec.rb index 4697808..80a843f 100644 --- a/spec/requests/user/payments_controller_spec.rb +++ b/spec/requests/user/payments_controller_spec.rb @@ -80,10 +80,7 @@ RSpec.describe DiscourseSubscriptions::User::PaymentsController do SiteSetting.discourse_subscriptions_pricing_table_enabled = true ::Stripe::Invoice.expects(:list).with(customer: "c_345678").returns(data: []) - ::Stripe::PaymentIntent - .expects(:list) - .with(customer: "c_345678") - .returns(data: [{ id: "pi_900010", invoice: nil, created: Time.now }]) + ::Stripe::PaymentIntent.expects(:list).with(customer: "c_345678").returns(data: []) ::Stripe::Charge .expects(:list) @@ -131,7 +128,7 @@ RSpec.describe DiscourseSubscriptions::User::PaymentsController do parsed_body = response.parsed_body # Validate that only guest payments with the specified email are returned - expect(parsed_body.count).to eq(2) + expect(parsed_body.count).to eq(1) expect(parsed_body.first["id"]).to eq("ch_1HtGz2GHcn71qeAp4YjA2oB4") expect(parsed_body.first["customer"]).to be_nil end