Skip to content

    Implement an Inline Widget

    How to implement an Inline Widget

    In order to use this functionality, every integrator should execute only 3 steps:

    1. Add payengine.widget.min.js (get it here)
    2. Call initAsInlineComponent() function on PayEngineWidget object to display the payment form
    3. Handle Widget initialization result in initCallback

    Here is snippet how your html could look like:

    html - code snippet - example

    <!DOCTYPE html>
    <html>
     <head>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">

    Check out all mandatory and optional parameters in Inline Widget Reference.

    Inline Widget Reference

    Here you can find all needed methods and respective parameters to further enrich your checkout workflow.

    All methods should be called on PayEngineWidget object (e.g PayEngineWidget.desiredMethod(parameters)).

    Initialize iframe

    The initAsInlineComponent key contains the information for initializing the iframe with the payment form. Always called on PayEngineWidget object. It's meant to result in a transaction.

    Signature

    initAsInlineComponent(container, publishableKey, transactionIntentId, optionalParameters, resultCallback)

    NameMandatoryTypeDefault ValueDescription
    containerYESString or DOM ElementN/AThe id of container html element or DOM Element, where iframe with payment form/s will be rendered
    publishableKeyYESStringN/AThe MerchantID given to every user on registration in Merchant Center (can be found in My Account section)
    orderIdYESStringN/AThe ID of created order object
    optionalParameters.initCallbackYESFunctionN/AFunction with following signature - callback (error, result)
    resultCallbackYESFunctionN/AFunction with following signature - callback (error, result)
    optionalParameters.productsNOArrayinherited from order objectArray with all supported payment methods. If paymentMethods is empty, null or undefined, all available payment methods for the widget are the ones, defined in order object. If paymentMethods is an array, it’s assumed that it’s a subset of payment methods array from the order object, so only defined by the integrator payment methods will be used. If there is inconsistency between the two arrays (e.g. integrator set more payment methods than defined in order object), error will be thrown.
    optionalParameters.layoutNOString“dropdown”The layout used for displaying different payment forms. Available options are: dropdown - dropdown with all available payments methods, which shows only one payment form (for the selected payment method) “full-list” - all payment forms for all available payment methods are shown one after another in same view
    optionalParameters.languageNOString“en”The language used throughout the Widget. Available options are: en - English “de” - German
    optionalParameters.customStyleIdNOStringN/AAppy custom UI appearance. Custom styles can be defined in the section Styling in the Merchant Center. Every custom style gets unique ID, which should be placeа as value for customStyleId parameter. Found out how it works here (link to Styling)

    Available values for optionalFields

    Field NameMandatoryTypeDefault ValueDescription
    autoResizeHeightNOBooleanfalseIf set to true, Widget inline resizes by adjusting its height automatically.

    pay

    paytriggers the transaction creation process. It's only relevant if the pay button of the widget is being hidden (please see initAsInlineComponent section.

    Signature

    pay(widgetReference)

    NameMandatoryTypeDefault ValueDescription
    widgetReferenceYESObjectN/AReference to the Widget inline component, which is being targeted. It's received on the initCallback as result

    validate

    This function will return validation result on the callback provided.

    Signature

    validate(widgetReference, callback)

    NameMandatoryTypeDefault ValueDescription
    widgetReferenceYESObjectN/AReference to the Widget inline component, which is being targeted. It's received on the initCallback as result
    callbackYESFunctionN/AFunction with following signature - callback (error, result)

    addValidationListener

    Registers validation listener for a certain widget inline component instance.

    Signature

    addValidationListener(widgetReference, listener)

    NameMandatoryTypeDefault ValueDescription
    widgetReferenceYESObjectN/AReference to the Widget inline component, which is being targeted. It's received on the initCallback as result
    listenerYESFunctionN/AAs a listener it takes only one parameter, which will be the result of the validation. The function will be triggered each time the widget validates the payment form fields.

    removeValidationListener

    Removes validation listener for a certain widget inline component instance.

    Signature

    removeValidationListener(widgetReference, listener)

    NameMandatoryTypeDefault ValueDescription
    widgetReferenceYESObjectN/AReference to the Widget inline component, which is being targeted. It's received on the initCallback as result
    listenerYESFunctionN/APreviously added validation listener

    Was this helpful?

    What was your feeling about it?