benonymus

benonymus

So the erro meassage is :

(exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in MyApiWeb.FallbackController.call/2

And the code where it is coming from is :

def create(conn, %{
  "description" => description,
  "email" => email,
  "source" => source,
  "subscriptionID" => subscriptionID
}) do
  with {:ok, %t{} = t} <- Stripe.Customer.create(%{description: description, email: email}) do
    conn
    |> IO.inspect(t)
  end
end

Thanks

Showing Posts 1 to 10

NobbZ

NobbZ

I’m not sure what you try to bind to t in the with clause. But regardless what gets bound to it, its either an atom or a map/struct, while IO.inspect/2 expects keywords as its seconds argument (where t is used).

I am totally not sure though, if that is the problem though, since your error message complains about call/2 and you have shown only the create action.

To actually find your problem you’ll probably need to show more of your controller, as call/2 is the function that should dispatch the request to your actual action, so the problem is much earlier in the stack.

benonymus

benonymus OP

I am trying to use stripity stripe, and it is form their documentation, so I am not sure myself.
currently I only have this create action in my controller

NobbZ

NobbZ

There has to be more, some use or other stuff or there wouldn’t even be the call/2 function from the error message.

So could you please share the full controller?

benonymus

benonymus OP

sure and thanks

defmodule MyApiWeb.UserController do
  use MyApiWeb, :controller
  action_fallback(MyApiWeb.FallbackController)
  require Logger

  def create(conn, %{
        "description" => description,
        "email" => email,
        "source" => source,
        "subscriptionID" => subscriptionID
      }) do
    with {:ok, %t{} = t} <- Stripe.Customer.create(%{description: description, email: email}) do
      conn
      |> IO.inspect(t)
    end
  end
end
NobbZ

NobbZ

A fallback controller will be called when your actual action fails to return a proper conn.

As the with can’t match after my understanding (I’ve explained that above), you always return nil, which isnt a valid conn. So the fallback will be called. Why that doesn’t have a clause matching, we can’t say, because you haven’t shown it.

Also can you please share a link to the resources that gave you the example?

benonymus

benonymus OP

well I tried to puzzle it out from many, beause I could not find an example that uses striptiy stripe or elixir with stripe really.

also I am assuming that I am using this wrong but I just dont really understand that what the doc is trying to say
https://github.com/code-corps/stripity_stripe

https://medium.com/@njwest/jwt-auth-with-an-elixir-on-phoenix-1-3-guardian-api-and-react-native-mobile-app-1bd00559ea51

I used this as my base, made it work earlier, so I just used it as a general guide, these were the main ones, but had some other ones too

as for my code the router:
defmodule MyApiWeb.Router do
use MyApiWeb, :router

  pipeline :api do
    plug(CORSPlug, origin: "*")
    plug(:accepts, ["json"])
  end

  scope "/api", MyApiWeb do
    pipe_through(:api)

    post("/users", UserController, :create)
    # options("/users", UserController, :create)
  end
end
NobbZ

NobbZ

Sorry I have to say, but I can’t find anything in the links that is like the snippet you posted.

So I have to ask again, where did you found the t = %t{} pattern? What are you trying to achieve by using it?

What is it you want to inspect in the withs body? t or conn?

Have you understood what with is used for?

Why do you use a fallback controller at all? Do you really need it? Do you understand what it is meant for?


PS: the router is probably unrelated, the error is raised from your fallback controller.

benonymus

benonymus OP

the fallback controller was auto generated, this t = %t{} my friend said it and what it tries to achieev is to get the created user.
I want ot inspect the created user so t in this case.
Maybe if you know an open source project that uses elixir with stripe could yo link it?
or just help me understand how to use the package?

Thank you

idi527

idi527

:waving_hand:

t = %t{} seems rather pointless to me since, for example

iex(3)> t = %t{} = %User{}
%User{id: nil}
iex(4)> t
%User{id: nil}

here the intermediate value (from %t{} = %User{} such that t = User) is lost. If you want to pattern match on a user struct, it’s usually accomplished like this

iex(3)> %User{id: user_id} = %User{}

To better understand what goes wrong with

(exit) an exception was raised:
    ** (FunctionClauseError) no function clause matching in MyApiWeb.FallbackController.call/2

we would either need to see the implementation of MyApiWeb.FallbackController or at least what’s in t that causes the “happy path” in with to fail. Try this

def create(conn, %{
  "description" => description,
  "email" => email,
  "source" => source,
  "subscriptionID" => subscriptionID
}) do
  with {:ok, t} <- Stripe.Customer.create(%{description: description, email: email}) do
    conn # are you sure you don't want to `send_resp(conn, 200, [])` at least?
  else 
    unmatched ->
      IO.inspect(unmatched, label: "unmatched")
  end
end
NobbZ

NobbZ

I wasn’t in the need of a payment provider so far.

But please try to match only {:ok, user} and then do IO.inspect user; conn.

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
achenet
Hello, I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind. However, when I launch mix phx.server, I get an error...
New
bradley
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
unaware8150
Hello folks! So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
Cxx-mlr
I’m working on a small exercise involving update_in/3, and I came up with this solution: data = %{ name: "Periodic Table", category:...
New
ChrisAmelia
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication): toke...
New
dillonoconnor
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mudasobwa
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews