SDK and widgets
Early accessSDK: pay-js
Shell
# npm install @terrawallet/pay-js (not published yet; name may change)What it will include#
- Checkout as a modal or inline on your own page, for a payment intent your server created.
- A subscribe button for plans.
- The same security rules as hosted checkout: the full address always shown, your payout wallet verified on the page, and Terra's prompts impossible to hide or restyle.
- Embedded checkout can be framed only by the origins you allowlist.
A preview of the shape#
JavaScript
// Preview API, not installable. Names may change.import { TerraPay } from "@terrawallet/pay-js"; document.querySelector("#checkout").addEventListener("click", async () => { // Your server creates the payment intent with its secret key and returns the pi_ id. const { paymentIntentId } = await fetch("/api/checkout", { method: "POST" }).then((r) => r.json()); TerraPay.open({ paymentId: paymentIntentId, theme: { mode: "auto" } });});The flow that works today#
JavaScript
// Works with the v1 API once your account has access: redirect to hosted checkout.document.querySelector("#checkout").addEventListener("click", async () => { const res = await fetch("/api/checkout", { method: "POST" }); // your server endpoint const { checkoutUrl } = await res.json(); // the intent's checkout_url window.location.assign(checkoutUrl);});