beam-community / stripity-stripe

An Elixir Library for Stripe
Other
985 stars 353 forks source link

Malformed Endpoints for attach/detach Payment Methods #713

Closed pointerish closed 2 years ago

pointerish commented 2 years ago

The Stripe.PaymentMethod.attach/2 and Stripe.PaymentMethod.detach/2 seem to be incorrectly creating their endpoints. Whenever I attempt to attach a Payment Method to a Customer I get the following error:

image

Notice the part where it says "Unrecognized request URL (POST: /v1/payment_methods//attach). The //attach is wrong.

They run fine if I remove the prepended / from the /attach and /detach strings and recompile the following code:

image

I'm using the latest 2.12.1 version. It'd be awesome if someone could double-check this. I'd be happy to create the PR if needed.

snewcomer commented 2 years ago

@pointerish Yep it looks like the latter is the cause. What was "params". Looks like it was something but didn't match payment_method.

  defp plural_endpoint() do
    "payment_methods"
  end

  defp plural_endpoint(%{payment_method: payment_method}) do
    plural_endpoint() <> "/" <> get_id!(payment_method)
  end
snewcomer commented 2 years ago

Looks like your payment_method argument to attach is missing. Lmk if that isn't the case!