I think the easiest way for you would be getting this data the same way you get it in the new action of your controller. Then if you don’t want to repeat the code just write it in a plug function that will be called before new and create actions.
# defining private plug function somewhere at the bottom of the controller
defp assign_payment(%{params: %{"payments_ids" => payments_ids}} = conn, _opts) do
payment = get_payment!(payments_ids)
assign(conn, :payment_id, payment)
end
# somewhere in the top of the controller before all actions definition
plug assign_payment when action in [:new, :create]
# to get payment_id in both "new" and "create" actions
conn.assigns.payment_id
Edit : Please note that with this plug, payment_id will also be available in the template linked to both actions.
or that payment_assignment which function fulfills, because I have the list of payments in new and when calling the payment_assign I get errors by the parameters