buyCredit = {
function buy(price) {
stripe.redirectToCheckout({
lineItems: [{ price: price, quantity: 1}],
mode: 'payment',
successUrl: `https://observablehq.com/@tomlarkworthy/minecraft-servers`,
cancelUrl: `https://observablehq.com/@tomlarkworthy/saas-tutorial#buyCredit`,
clientReferenceId: user.uid,
customerEmail: user.email,
})
}
return html`
<div class="field has-addons has-addons-centered">
<p class="control">
<span class="select">
<select id="product_choice">
<option value="price_1HeSBJHGNosi6Ft0qX1mdn61">€5</option>
<option value="price_1HeSBJHGNosi6Ft0Dr3APW9w">€10</option>
<option value="price_1HeSBJHGNosi6Ft0KGlUEjwz">€20</option>
<option value="price_1HeSBJHGNosi6Ft0z0fiZAnq">€50</option>
</select>
</span>
</p>
<p class="control">
<button class="button is-primary"
onclick=${() => buy(document.getElementById("product_choice").value)}>
Buy more credit
</button>
</p>
</div>
`
}