Class: SpreeCmCommissioner::LoadTest::GenerateBookingTicketData
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::LoadTest::GenerateBookingTicketData
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/load_test/generate_booking_ticket_data.rb
Overview
Generates the cash_on_booking_ticket_flow / aba_booking_ticket_flow load-test data for one variant so it can be used by the k6 booking flow. An admin/organizer picks a ticket variant in the dashboard; this reads its product / variant / event straight off the models and returns the payload the flow needs, plus a "can this actually be booked?" check so the tester knows it will drive the flow. Mirrors GenerateVotingFixtureData's cash-on/ABA payment resolution (gems/spree_cm_commissioner/app/services/spree_cm_commissioner/load_test/ generate_voting_fixture_data.rb) for the same two payment methods, applied to a variant instead of a voting session.
Flow: pick a ticket variant in admin/organizer -> copy this payload into
load_testing/config/fixture/<platform|tenant>/
Returns success({ data: ..., issues: [...] }). issues is empty when the variant is ready
to load-test; otherwise it lists why the booking flow would fail — including "no payment
method configured" for whichever flow you asked for. issues (plus a ready flag) are
duplicated into data[:metadata] so they travel with the copied JSON — the k6 flow ignores
that key, it's there for a human to read later.
Constant Summary collapse
- FLOWS =
%w[cash_on_booking_ticket_flow aba_booking_ticket_flow].freeze
- PAYWAY_CHECKOUT_PATH =
ABA's checkout endpoint is fixed regardless of tenant/environment — only
host(sandbox vs production) differs, and that comes off the payment method. See Vpago::PaywayV2::Checkout#checkout_url in gems/spree_vpago. Mirrors GenerateVotingFixtureData::PAYWAY_CHECKOUT_PATH. '/api/payment-gateway/v1/payments/purchase'.freeze
Instance Method Summary collapse
-
#call(variant:, flow: 'cash_on_booking_ticket_flow') ⇒ Object
flow: which payment method to resolve — 'cash_on_booking_ticket_flow' (the default) or 'aba_booking_ticket_flow' (ABA/PayWay v2, adds a
paywayblock).
Instance Method Details
#call(variant:, flow: 'cash_on_booking_ticket_flow') ⇒ Object
flow: which payment method to resolve — 'cash_on_booking_ticket_flow' (the default) or
'aba_booking_ticket_flow' (ABA/PayWay v2, adds a payway block).
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/services/spree_cm_commissioner/load_test/generate_booking_ticket_data.rb', line 38 def call(variant:, flow: 'cash_on_booking_ticket_flow') raise ArgumentError, "Unknown flow: #{flow.inspect} (expected one of: #{FLOWS.join(', ')})" unless FLOWS.include?(flow) product = variant.product event = product.event issues = issues_for(variant, event) data = { event_permalink: event&.permalink, product_slug: product.slug, product_id: product.id, variant_id: variant.id } issues.concat(payment_method_issues(variant, flow, data)) # Informational only — the k6 flow never reads this. Carries the readiness check into # the copied JSON itself, so it's visible later without regenerating from admin/organizer. data[:metadata] = { ready: issues.empty?, issues: issues } success(data: data, issues: issues) rescue StandardError => e failure(nil, e.) end |