title: Stripe-Elixir How to get "payment source"
body: <p>I am using this package to incorporate Stripe into a phoenix app:</p>
  
  <p><a href="https://github.com/sikanhe/stripe-elixir" rel="nofollow noreferrer">https://github.com/sikanhe/stripe-elixir</a></p>
  
  <hr>
  
  <p>I am trying to create a customer that subscribes to a plan.</p>
  
  <pre><code>defmodule StripeTestWeb.PaymentController do
    use StripeTestWeb, :controller
    use Stripe.API
  
    def index(conn, %{"stripeEmail" =&gt; email} = _params) do
      {:ok, customer_data} = Stripe.Customer.create(%{email: email})
  
      Stripe.Subscription.create(%{
        customer: customer_data["id"],
        items: [%{plan: "plan_D9JehUOiyPGtgp"}]
      })
  
      render(conn, "index.html")
    end
  end
  </code></pre>
  
  <p>The customer is created but the request returns an error when trying to create the subscription. The error is: </p>
  
  <pre><code>{
    "error": {
      "code": "resource_missing",
      "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
      "message": "This customer has no attached payment source",
      "type": "invalid_request_error"
    }
  }
  </code></pre>
  
  <p>I don't know what the API expects me to send as "payment source" nor am I clear if this is supposed to be sent when creating the customer or when creating the subscription. </p>
  
  <p>I am using the JavaScript embedded code to create the payment pop up:</p>
  
  <pre><code>  &lt;form action="payment" method="POST"&gt;
        &lt;input type="hidden" name="_csrf_token" value="&lt;%= Plug.CSRFProtection.get_csrf_token()%&gt;"&gt;
  
        &lt;script
        src="https://checkout.stripe.com/checkout.js" class="stripe-button"
        data-key="pk_test_2vzqy4IW9zHAYyKSjDNZkd2l"
        data-amount="14900"
        data-name="Demo Site"
        data-description="Subscription $149"
        data-locale="auto"&gt;
        &lt;/script&gt;
  
    &lt;/form&gt;
  </code></pre>