我的令牌未与表单的其余部分一起发送。希望所有这些都作为一个表单发送。据我所知,它只在我执行表单时显示。不太了解js,非常感谢任何帮助
<form action="/pay/" method="POST">
<%= hidden_field_tag :authenticity_token, form_authenticity_token -%>
<input type="hidden" name="token" />
<div class="group">
<label>
<span>Card</span>
<div id="card-element" class="field"></div>
</label>
</div>
<div class="group">
<label>
<span>Address</span>
<input id="address-line1" name="address_line1" class="field" placeholder="77 Winchester Lane" />
</label>
<label>
<span>Stad</span>
<input id="address-city" name="address_city" class="field" placeholder="Coachella" />
</label>
<label>
<span>Postnummer</span>
<input id="address-zip" name="address_zip" class="field" placeholder="92236" />
</label>
</div>
<button type="submit">Betala</button>
<div class="outcome">
<div class="error"></div>
<div class="success">
Success! Your Stripe token is <span class="token"></span>
</div>
</div>
</form>
</main>
这是直接从https://jsfiddle.net/ywain/dheyftzp/复制的,只是进行了一些细微的更改以适应我,并且标准表格也从上面的链接中复制了
html, body {
-webkit-overflow-scrolling : touch !important;
overflow: auto !important;
height: 100% !important;
}
答案 0 :(得分:1)
很抱歉打扰实际找到了答案,未选中将令牌添加到表单的其中一行。
form.querySelector('input[name="token"]').setAttribute('value', result.token.id);