Embedded UI components are a JavaScript-based collection and tokenization system and a full payments API. You can use the embedded components in conjunction with the Payabli API to submit transactions or for other Payabli services that use payment information.

Choose a component

To decide which embedded component to use, consider the functionality you need for your app. Payabli offers embedded components tailored to different use cases:

Which component is right for you depends on whether you need to make transactions, save payment method data, or both. For example, if you need to both save a payment method and execute payments, the EmbeddedMethod UI might be the best choice. If you just need to make transactions from your website or app, the VirtualTerminal UI could be the right choice. Overall, the EmbeddedMethod UI is our most popular and flexible option.

You can extend the EmbeddedMethod UI and PayMethod UI components even further by using a flow designed around returning a temporary payment token. See Extend Embedded Components with the Temporary Token Flow for more.

Library URLs

See the component.js Changelog to see the latest changes.

Beginning October 22, 2023 embedded components no longer supports versions older than 1.9.0.

The sandbox and production library URLs are evergreen, meaning that the URL always points to the latest version.

  • Sandbox: https://embedded-component-sandbox.payabli.com/component.js
  • Production: https://embedded-component.payabli.com/component.js

You must add the data-test configuration variable to your script tag when using the sandbox library. Don’t include data-test when working with the production library.

Usage

Component configuration is covered in the Configuration reference section of the documentation for each component type.

Payabli designed the embedded components for flexibility. Implementation can be as uncomplicated as pasting a single script tag to your checkout page, or you can customize them to interact with your website. The components require loading the component.js library to work.

The component.js contains the code for the PayabliComponent className. You can use several instances of the PayabliComponent className in the same page extending the functionality provided in your application.

Sandbox
<script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
<script>
	var configuration = { ....};
	var payablicomponent = new PayabliComponent(configuration);
</script>

Authentication

Authenticate via token key passed in the embedded component’s configuration. Configuration is covered in the documentation for each component.

The API token you use must be public, and if you are using a Creator component, the token must be set up for use with Creator. Learn more about Payabli API tokens.

PayabliComponent className

The PayabliComponent className has the following methods:

showModal()

Shows the component if it’s hidden.

closeModal()

Hides the component.

updateConfig()

Replaces the component configuration. See this CodePen for an example.

payabliExec(action, parameters)

Triggers an action. Valid actions are method, pay, auth and reinit. parameters is an optional structure that lets you dynamically overwrite the matching fields passed via configuration for customerData and paymentDetail.

Here’s an example:

var dynamicData= { 
	customerData: {
    firstName: 'John',
    lastName: 'Doe'
  },
  paymentDetails: {
    totalAmount: 11.55
	}
};
mycomponent.payabliExec('pay', dynamicData); //This action executes a payment, using the customerData and paymentDetails objects declared in the dynamicData variable

Customize component styling

Customize your component by providing a URL to a custom CSS file in the parameter customCssUrl in the component configuration.

CSS URL example
const payabliConfig0 = {
          type: "methodLightbox",
          rootContainer: "pay-component-1",
          buttonLabelInModal: 'Save Payment Method',
          defaultOpen: 'ach',
          hideComponent: true,
          customCssUrl: 'www.example.com/mycssfile.css',
          ...
}

Make the component background transparent

By default, the embedded components have a white background. To make the component’s background transparent, add the following CSS to the stylesheet that’s linked with the customCssUrl parameter:

/* ... the rest of your custom css ... */

/* transparent while loading */
#main-loading-layer {
    background-color: transparent !important;
}

/* transparent after loading */
body {
    background-color: transparent !important;
}

Component containers

Each component creates a container for the iframe with a specific ID:

  • EmbeddedMethod: payabliComponentsIframeContainerMethodEmbedded
  • PayMethod: payabliComponentsIframeContainerMethod
  • VirtualTerminal: payabliComponentsIframeContainerEterminal

Component elements

You can also make reference and create custom styles for specific elements inside of the component using these IDs:

IDElement
cardNumberCard number input
cardNumberContainerCard number container
cardExpirationDateCard expiration date input
cardExpirationDateContainerCard expiration date container
cardCvvCard CVV input
cardCvvContainerCard CVV container
cardZipcodeCard zip code input
cardZipcodeContainerCard zip code container
cardHolderNameCardholder name input
cardHolderNameContainerCardholder name container
achAccountTypeBank account type selector
achAccountTypeContainerBank account type container
achAccountHolderNameBank account holder input
achAccountHolderNameContainerBank account holder container
achRoutingBank routing input
achRoutingContainerBank routing container
achAccountBank account input
achAccountContainerBank account container

This example targets the card number, expiration date, CVV, zip code, and cardholder name fields. It adds a solid, 1 pixel black border to the fields.

#cardNumber, #cardExpirationDate, #cardCvv, #cardZipcode, #cardHolderName{
  border: solid 1px #000000;
}

Style individual fields

Components are flexible widgets. You can array the input fields inside of the container and change labels and placeholders. The component doesn’t have a button triggering any action so you need to create one via code.

The internal design of the component is a grid with 3 rows and 12 columns. This feature allows developers to specify size and placement of each input in the grid without any CSS manipulation.

Row 0
Row 1Size=2Size=3Size=5Size=1Size=1
Row 2Size=8Size=4Size=1

You can style inputs in the component configuration using these parameters:

Field/ParameterDescription
labelstring. Label for input field.
placeholderstring. Placeholder for input field.
floating

boolean. Enable/disable floating label within input field. Default is true

valuestring. Value for input field.
sizeinteger. Size of input field in columns (1-12).
row

integer. Row to place the input within component grid (0-2), 0 being the top row.

order

integer. Order of input field within the row (0-99+), 0 being the left position.

confirm

boolean. For achRouting and achAccount inputs only. When true, duplicates the ACH account number and routing number fields and requires that the fields match. This helps make sure the user enters valid account and routing numbers

country

array[string]. For cardZipcode input only. Accepted values are us and ca. Controls which zip code formats are accepted. If ca is included, then Canadian payments are enabled.

Here are examples of different input configurations:

Example without customizations

This is the look of the EmbeddedMethod component without customizations:

Card

See this example in CodePen

ACH

See this example in CodePen

Example with customizations

This is an example of the EmbeddedMethod component with a custom CSS file and using input field descriptors.

See this example in CodePen:

Notice how the functionCallBackReady is triggered when the input fields are validated in the component showing or hiding the Submit button.

Handling responses and errors

Responses are returned in functionCallBackSuccess and functionCallBackError.

This is a general response handling example. Check the response object reference for the embedded component you’re using for other userful data you can access.

Response Handling Example
        functionCallBackSuccess: function (response) {

          // This callback covers both 2XX and 4XX responses
          console.log(response);
          switch (response.responseText) {
            case "Success":

              // Tokenization was successful
              alert(`Success: ${response.responseData.resultText}`);
              break;
            case "Declined":

              /* Transaction or tokenization failed due to processor decline or validation errors
              Recommend reinitialization of the component so that the user can try again
              with different card data */
              alert(`Declined: ${response.responseData.resultText}`);
              paycomponent0.payabliExec("reinit");
              break;
            default:

              /* Other response text. These are normally errors with Payabli internal validations
              before processor engagement. We recommend reinitializing the component.
              If the problem persists, contact Payabli to help debug */
              alert(`Error: ${response.responseText}`);
              paycomponent0.payabliExec("reinit");
              break;
          }
        },

        functionCallBackError: function (errors) {

          // This callback covers 5XX response or parsing errors
          console.log(errors);

          /* We recommend reinitializing the component.
          If the problem persists, contact Payabli to help debug */
          paycomponent0.payabliExec("reinit");
        }

Learn more about response codes and errors in the reference doc.

Playground

The Embedded Component Playground lets you experiment with some component types with a live preview in your browser. Learn more about the Playground in the changelog.