Skip to content

Instantly share code, notes, and snippets.

@ashgansh
Created November 30, 2018 11:11
Show Gist options
  • Save ashgansh/84015cb9e46813f248844c3b3df95ec9 to your computer and use it in GitHub Desktop.
Save ashgansh/84015cb9e46813f248844c3b3df95ec9 to your computer and use it in GitHub Desktop.
<script type="module">
import SimplePayment from "https://unpkg.com/payment-components@0.1.0/dist/payment-components.esm.production.js";
async function checkout() {
const response = await fetch("/pay", { method: "POST" });
const data = await response.json();
return { signedRequestData: data };
}
document.addEventListener("DOMContentLoaded", function() {
const sp = new SimplePayment(checkout, {
redirectUrl: window.location.href,
networkId: 4
});
// fil in with the id of your own button
sp.init("#checkout-button");
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment