DEV: Guest payments follow up

Just some minor follow up changes to PR #234
This commit is contained in:
Blake Erickson 2024-08-29 13:45:05 -06:00
parent fa5e95860b
commit 9bbe78298f
2 changed files with 3 additions and 4 deletions

View File

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

View File

@ -83,7 +83,7 @@ RSpec.describe DiscourseSubscriptions::User::PaymentsController do
::Stripe::PaymentIntent
.expects(:list)
.with(customer: "c_345678")
.returns(data: [{ id: "pi_900010", invoice: nil, created: Time.now }])
.returns(data: [])
::Stripe::Charge
.expects(:list)
@ -131,7 +131,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