window.Scalev from browser JavaScript. The runtime gives your page safe page context, selected store context, checkout helpers, analytics forwarding, form prefill helpers, and diagnostics while keeping private API tokens server-side.
This page is written for developers and AI agents that generate HTML Mode files. Use these methods instead of calling private Scalev URLs directly.
Availability
The runtime is available on rendered HTML Mode pages. In local editor previews, some methods can return stubbed preview data.Promise. Scalev.data.get() and Scalev.diagnostics.get() are synchronous.
Runtime method payloads and responses use camelCase object keys. The runtime handles the backend casing internally, so page JavaScript should not send snake_case keys. Runtime methods also return the JavaScript-visible result directly. They remove backend collection containers such as data and is_paginated before returning arrays.
String enum values and provider-owned blobs keep their original values. For example, success_page, direct_to_whatsapp, analytics parameters, metadata, and customData are not renamed.
Store context
When Store Context is selected,Scalev.data.get().store includes only the selected store summary, products, and bundle price options. Treat it as the page-specific checkout catalog.
When HTML Checkout Page is selected, Scalev.data.get().afterCheckout includes the selected after-checkout success type and its public destination config.
When Store Context is unselected, treat store as unavailable. Build a regular landing page and rely only on page-safe methods such as Scalev.data.get(), Scalev.analytics.track(), and Scalev.prefill.get().
Security rules
- Keep API keys, business-user JWTs, storefront API keys, customer tokens, cookies, and credentials out of page JavaScript.
- Use documented
window.Scalevmethods instead of private Scalev URLs or private APIs. - Create orders only after a visitor intentionally submits a form.
- Prefer
Scalev.checkout.createOrder()on submit; it validates the payload before the order is persisted. - Use only selected products, bundles, prices, inventory, payment methods, shipping options, and customer identity values present in the runtime data.
Scalev.data.get()
Returns public page data injected into the rendered page.
store.paymentMethodOptions to render payment choices. Render display, show logoUrl, and submit the selected value as paymentMethod.
Payment option values are already flattened:
va:BRImeans virtual account for BRI.bt:BCA:paymentAccountUidmeans manual bank transfer for the represented BCA account.- Regular values such as
cod,qris,invoice,alfamart, orgopaykeep their original values.
Location methods
Use these methods for address and shipping forms.provinces, cities, and subdistricts accept optional query objects:
{ id, name }. Subdistrict responses use id and name for the subdistrict, plus cityName, provinceName, and display for address labels.
Response examples:
Scalev.checkout.validateDiscount(payload)
Validates a discount code for a checkout payload.
Scalev.checkout.shippingOptions(payload)
Returns shipping options for the selected items, destination, and payment method. Use this as the only shipping lookup method.
shipping field in estimateSummary and createOrder. The runtime prepares the checkout request from that option. Options include logoUrl when a courier code is available.
Response example:
Scalev.checkout.estimateSummary(payload)
Returns a checkout summary for pages that show a buyer-facing breakdown before submit.
This method is optional. Pass the same item, destination, payment, and shipping that you will send to Scalev.checkout.createOrder(payload).
The result does not replace order creation validation. Scalev still validates and applies final shipping, discount, extra-fee, and total amounts during order creation before the order is persisted.
estimateSummary only when the checkout UI displays totals before submit. Do not calculate or submit otherIncome or otherIncomeName; Scalev calculates store-configured extra fees in estimateSummary and applies them again during createOrder.
Scalev.checkout.createOrder(payload)
Creates a real public order and validates the payload. Call this only after a visitor intentionally submits the form.
- Customer object:
customer.name,customer.phone,customer.email - Destination object:
destination.address,destination.subdistrictId,destination.postalCode - Payment field:
paymentMethod - Items list:
items[]with{ type: "product", variantUniqueId, quantity }or{ type: "bundle", bundlePriceOptionUniqueId, quantity } - Discount field:
discountCode
items[] when needed. Use validateDiscount to preview eligible discount code amounts, then pass the selected code as discountCode to createOrder.
For shipping selection, call Scalev.checkout.shippingOptions(payload), let the visitor choose one option, then pass that whole option as shipping into summary and order calls.
Recommended method payload:
store.paymentMethodOptions[].display, render payment images from store.paymentMethodOptions[].logoUrl, and submit only the selected option value as paymentMethod.
Response example:
Error handling
Runtime methods reject thePromise with a JavaScript Error. Use error.message for UI copy. Use error.status, error.data, and Scalev.diagnostics.get() only for debugging.
Scalev.analytics.track(provider, payload)
Forwards configured analytics events through Scalev.
facebooktiktokkwai
Scalev.prefill.get()
Reads safe browser-scoped form prefill data.
Scalev.prefill.save(form, metadata)
Persists safe browser-scoped form prefill data in the encrypted scv_fd cookie. This is handled locally by fe-public and does not call a Storefront or page runtime API endpoint.

