---
updatedAt: 2025-11-12T23:57:02.000Z
agentTools:
  projectIndex: https://docs.payb.is/llms.txt
---

# Widget Integration Example in Custom Iframe, without SDK

```shell HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no, interactive-widget=overlays-content">
    <title>Widget Integration Example | create iframe</title>

    <style>iframe{width:100%;height:100%;z-index:2147483646;background-color:#fff;position:fixed;top:0;bottom:0;left:0;right:0}</style>
  </head>
  <body>
    <div id="widget-holder"></div>

    <script>
      // @see https://docs.payb.is/docs/integration-overview
      const options = {
        requestId: '', // format: uuid
        placeholderId: 'widget-holder',
      };

      const paybisWidget = {
        namespace: 'widget',
        iframeId: 'paybis-widget',
        baseURL: 'https://widget.sandbox.paybis.com',

        init({ requestId, placeholderId }) {
          if (requestId === '') {
            throw new Error('Could not init paybisWidget: requestId is empty');
          }

          const url = new URL(this.baseURL);
          url.searchParams.append('requestId', requestId);
          
          const iframe = this.createIframe({ url: url.toString() });
          document.getElementById(placeholderId).append(iframe);

          window.addEventListener('message', this.eventHandler.bind(this));
        },

        createIframe({ url }) {
          const iframe = document.createElement('iframe');

          // For browser APIs to work correctly, all of these attributes need to be present.
          iframe.setAttribute('allow', 'clipboard-read; clipboard-write *; payment *; camera *; microphone *');
          iframe.setAttribute('allowpaymentrequest', true);
          iframe.setAttribute('id', this.iframeId);
          iframe.setAttribute('src', url);

          return iframe;
        },

        get getIframe() {
          const iframe = document.getElementById(this.iframeId);
          if (!iframe) {
            throw new Error(`Could not find element with id "${this.iframeId}"`);
          }

          return iframe;
        },

        eventHandler(event) {
          const { data: eventData } = event;
          const oData = typeof eventData === 'string' ? JSON.parse(eventData) : eventData;

          // @see https://mcson-cy.gitbook.io/bridgerpay-documentation/reporting/event-capture
          if (oData.url && oData.event === '[bp]:redirect') {
            this.getIframe.setAttribute('src', oData.url);
            return;
          }

          if (oData.namespace !== this.namespace) {
            console.debug('Unhandled event', event);
            return;
          }

          const { name: eventName, payload = {} } = oData;
          console.debug({ eventName, payload });

          // eventNames: state, error, payment-initiated, payment-redirect
          // state: initial, startLoading, loaded, error, completed, rejected, cancelled, closed, terminated
          // @see https://docs.payb.is/v3.0/docs/internal-events
          switch (eventName) {
            case 'state':
              console.debug(`Widget is in "${payload.state}" state`);
              break;
            default:
              break;
          }
        }
      };

      document.addEventListener('DOMContentLoaded', () => paybisWidget.init(options));
    </script>
  </body>
</html>

```

# Add HTML markup

<!-- shell@1-14,93-96 -->



# Create iframe and open the Widget

<!-- shell@15-35,38-59,92 -->



# Add events handling

<!-- shell@37,61-90 -->

Using the integration option without an SDK, the events sent by the widget must be processed manually. For example, without handling the "close" event, the user will not be able to close the widget.

Note that in certain payments the Bridgerpay is using. In this case, it is necessary to receive and process the events sent by the Bridgerpay iframe.

Read more: https://docs.payb.is/docs/internal-events