This is the code in the frontend sending the request - notice the order of the params:
params = {ticket_guid: "XXX-XXX", user_name: "David", quantity: 2}
$.get('/init_stripe_transaction', params, function(data) {
This is the "Bad Request" data in the dev console on the browser showing the order of the params:
http://localhost:4000/init_stripe_transaction?ticket_guid=XXX-XXX&user_name=David&quantity=2
This is the error response in the terminal(server side), i.e phoenix elixir def logs. NOTICE - how the order of the params has now been changed for some reason:
[info] GET /init_stripe_transaction
[debug] Processing with DiceWeb.TransactionController.create_stripe_session/2
Parameters: %{"quantity" => "2", "ticket_guid" => "XXX-XXX", "user_name" => "David"}
Pipelines: [:browser]
[info] Sent 400 in 357ms
[debug] ** (Phoenix.ActionClauseError) no function clause matching in DiceWeb.TransactionController.create_stripe_session/2
This is how I am pattern matching in the controller:
def create_stripe_session(
conn,
%{ticket_guid: ticket_guid, user_name: user_name, quantity: quantity}
) do ...
EXTRA FYI: I am very new to elixir/pattern matching. So decided stack overflow was better than creating an issue on the phoenix repo. Is it OK to pattern match in this way?