我正在使用此软件包将Stripe合并到phoenix应用程序中:
https://github.com/sikanhe/stripe-elixir
我正在尝试创建一个订阅计划的客户。
defmodule StripeTestWeb.PaymentController do
use StripeTestWeb, :controller
use Stripe.API
def index(conn, %{"stripeEmail" => 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
已创建客户,但尝试创建订阅时请求返回错误。错误是:
{
"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"
}
}
我不知道API希望我作为“付款来源”发送什么,也不清楚在创建客户或创建订阅时是否应该发送此消息。
我正在使用JavaScript嵌入式代码来创建付款弹出窗口:
<form action="payment" method="POST">
<input type="hidden" name="_csrf_token" value="<%= Plug.CSRFProtection.get_csrf_token()%>">
<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">
</script>
</form>
答案 0 :(得分:1)
我对Stripe Elixir不熟悉,但是在Stripe上创建客户时,您可以传递Vendor: 22113
and mark "Adress" press ENTER
Delete the Mobile Phone" and press ENTER, then the error message pops up:
Internal error - access to IXADRU
,因此请尝试通过create调用传递它。
source