BNPL APIRedirect URLsIntegration
FAQ
BNPL APIRedirect URLsIntegration
FAQ
milpay doc
  1. Integration
  • Product-page widget
  1. Integration

Product-page widget

The product-page widget shows instalment information on your product pages: an instalment calculation, a credit limit request or a pre-assessment (prescore). The boxes and their pop-ups are rendered by InstaCash in an iframe, so the figures, the representative example and the legal texts are always current and you don't have to maintain them.
You add one script tag and one element per box. Everything else (offers, box types, layouts, colours, allowed domains) is set up for your shop by InstaCash.

Before you start#

1.
Publishable key. Find it in the Merchant Portal under API kulcsok → Termékoldali widget. It looks like pk_live_… (or pk_test_… for testing). The key is not secret: it appears in your page source.
2.
Allowed domains. The widget only shows on the domains we have allowed for your shop, for example https://www.yourshop.hu. Send us every domain you sell on, plus the return URL(s) where shoppers should land after a pre-assessment or credit limit request.

Quick start#

For the staging environment, load the script from https://bnpl-staging.instacash.hu/widget/v1/loader.js with a key created on staging.
The loader mounts a box on #instacash-widget and on every element with the data-instacash-widget attribute, so one page can hold several boxes.

Element attributes#

AttributeRequiredDescription
data-boxoptionalcalculation (default), limit or prescore. Only the box types enabled for your shop are shown.
data-layoutoptionalfull, compact, card or badge. If omitted or not enabled for your shop, your default layout is used.
data-amountrequired for calculation and prescoreThe product's gross price in HUF, e.g. 549990.
data-product-nameoptionalProduct name, shown in the pop-ups and passed to the pre-assessment.
data-skuoptionalProduct SKU, passed to the pre-assessment.
data-quantityoptionalQuantity, passed to the pre-assessment (1–999).
data-offer-idoptionalOffer to calculate with. Must be one of the offers enabled for your shop, otherwise your default offer is used.
data-return-urloptionalWhere the shopper returns after a pre-assessment or credit limit request. Must start with one of your allowed return URLs, otherwise the first one is used.
data-keyoptionalPublishable key for this element only, e.g. a different merchant per market. Defaults to the script tag's data-key.
The loader watches data-amount, data-product-name, data-sku and data-quantity: when your theme changes them (for example on a variant change), the box recalculates by itself.

Script tag attributes#

AttributeRequiredDescription
srcrequiredhttps://bnpl.instacash.hu/widget/v1/loader.js (staging: https://bnpl-staging.instacash.hu/widget/v1/loader.js)
data-keyrequiredYour publishable key.
asyncrecommendedThe widget never blocks your page.

What the shopper sees#

Calculation box: the instalments, THM and representative example, with a link to the payment summary pop-up and a button that starts a pre-assessment for the product.
Credit limit box: what a credit limit is and a button that starts a credit limit request.
Pre-assessment box: the product and price, and a button that starts a pre-assessment.
Amount outside your offer's range: a short message, or nothing, depending on your shop's settings.
Pre-assessment and credit limit requests open on the InstaCash site, in a new tab by default. The link the box creates is signed, works once and expires after 30 minutes. When the request is done, the shopper is sent back to your return URL.

JavaScript API (optional)#

You don't need any JavaScript for a static product page. For single-page apps or custom themes, the loader exposes window.Instacash. Commands can be queued before the script has loaded:
CommandDescription
mount(element, options)Mounts a box on an element added after the page loaded. options take the same keys as the attributes: box, layout, amount, name, sku, qty, offer, returnUrl, key.
update(element, data)Changes amount, name, sku or qty of a mounted box, e.g. on a variant change.
refresh()Mounts boxes on new #instacash-widget / [data-instacash-widget] elements and forgets removed ones. Call it after your app re-renders the page.
on(event, fn) / off(event, fn)Subscribes to or unsubscribes from an event. fn receives (detail, element).
Once loaded, call them directly, e.g. Instacash.update(el, { amount: 259990 }).

Events#

Every event is also dispatched on the box's element as a bubbling DOM event named instacash:<event>, with the details in event.detail.
EventDetailWhen
ready{ box }The box has loaded.
calculation{ offerId, count, amount, thm, total }A calculation box has figures: count instalments of amount, THM in percent, total payable.
unavailable{ reason }The box is not shown. reason: BOX_NOT_ENABLED, NO_OFFER, NO_AMOUNT, AMOUNT_OUT_OF_RANGE, DISABLED, ERROR or TIMEOUT.
action{ action }The shopper opened a pop-up from the box (summary or info).
modal:open{ view }A pop-up opened.
modal:close{}The pop-up closed.

Content Security Policy#

If your site sends a Content-Security-Policy header, allow our host:
script-src https://bnpl.instacash.hu;
frame-src https://bnpl.instacash.hu;
The loader itself sends no requests: everything else happens inside the iframe.

Platforms#

Shopify: add the Hosted widget block of the app to your product template in the theme editor, set Brand to instacash, and enter your publishable key in the block settings.
Other platforms: paste the snippet into your product template and fill data-amount with the product's price.

Testing#

pk_test_… keys also work on http://localhost (ask us to allow your local origin), so you can try the widget before going live. Use the staging script URL with a key created on staging to test the whole pre-assessment and credit limit flow.
Built with