EmbeddedMethod UI

Learn how to use the EmbeddedMethod UI embedded component to add the ability to securely store a payment profile or execute a sale
Applies to:Developers

Use the EmbeddedMethod component to capture a payment method or make a sale using any payment method. This is the most flexible and customizable component Payabli offers to developers.


This component is supported in the Playground. Use the Embedded Component Playground to edit and design embedded components in real time, and export the code to use in your own site or app.

Usage

See Library URLs for important information about embedded components library URLs.

Interactive demo

This demo shows the component in action with transaction processing and visual feedback. When the component processes a transaction, the demo displays the JSON response.

Embedded content from https://files.buildwithfern.com/payabli.docs.buildwithfern.com/2025-06-30T20:57:09.897Z/snippets/demos/embedded-method.html

EmbeddedMethod UI Demo

Loading content...

Configuration walkthrough

The interactive walkthrough displays code examples alongside step-by-step explanations.

Loading walkthrough content

Loading walkthrough...

Loading walkthrough...

/// Include the Payabli Script First, include the Payabli embedded component script in your HTML. This loads the core PayabliComponent class that powers all embedded components.

1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6</head>
7<body>
8 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
9</body>
10</html>

/// Create the Container Add a container element where the embedded component will render. The id attribute becomes the rootContainer in your configuration.

This div acts as the mounting point for the Payabli payment form.

-9
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6</head>
7<body>
8 <h1>Payment Form</h1>
9 <div id="pay-component-1"></div>
10
11 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
12</body>
13</html>

/// Configure the Component Create the configuration object that defines how your embedded component behaves. This includes authentication, payment methods, and callback functions.

The token must be a public API token. See the Configuration Reference for more information.

-62
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6</head>
7<body>
8 <h1>Payment Form</h1>
9 <div id="pay-component-1"></div>
10
11 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
12 <script>
13 const payabliConfig = {
14 type: "methodEmbedded",
15 rootContainer: "pay-component-1",
16 token: "your-public-api-token",
17 entryPoint: "your-entry-point",
18 defaultOpen: "card",
19 temporaryToken: false,
20 card: {
21 enabled: true,
22 amex: true,
23 discover: true,
24 visa: true,
25 mastercard: true,
26 jcb: true,
27 diners: true,
28 inputs: {
29 cardHolderName: {
30 label: "NAME ON CARD",
31 size: 12,
32 row: 0,
33 order: 0
34 },
35 cardNumber: {
36 label: "CARD NUMBER",
37 size: 6,
38 row: 1,
39 order: 0
40 },
41 cardExpirationDate: {
42 label: "EXPIRATION",
43 size: 6,
44 row: 1,
45 order: 1
46 },
47 cardCvv: {
48 label: "CVV",
49 size: 6,
50 row: 2,
51 order: 0
52 },
53 cardZipcode: {
54 label: "ZIP CODE",
55 size: 6,
56 row: 2,
57 order: 1
58 }
59 }
60 }
61 };
62 </script>
63</body>
64</html>

/// Add Callback Functions Implement success, error, and ready callback functions to handle component responses and form validation states.

These callbacks run after the user submits their payment information and the component receives a response from Payabli’s API.

-112
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .hidden { display: none; }
8 #submit-btn {
9 background: #4f46e5;
10 color: white;
11 padding: 12px 24px;
12 border: none;
13 border-radius: 6px;
14 cursor: pointer;
15 margin-top: 16px;
16 }
17 </style>
18</head>
19<body>
20 <h1>Payment Form</h1>
21 <div id="pay-component-1"></div>
22 <button id="submit-btn" class="hidden">Process Payment</button>
23
24 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
25 <script>
26 const payabliConfig = {
27 type: "methodEmbedded",
28 rootContainer: "pay-component-1",
29 token: "your-public-api-token",
30 entryPoint: "your-entry-point",
31 defaultOpen: "card",
32 temporaryToken: false,
33 card: {
34 enabled: true,
35 amex: true,
36 discover: true,
37 visa: true,
38 mastercard: true,
39 jcb: true,
40 diners: true,
41 inputs: {
42 cardHolderName: {
43 label: "NAME ON CARD",
44 size: 12,
45 row: 0,
46 order: 0
47 },
48 cardNumber: {
49 label: "CARD NUMBER",
50 size: 6,
51 row: 1,
52 order: 0
53 },
54 cardExpirationDate: {
55 label: "EXPIRATION",
56 size: 6,
57 row: 1,
58 order: 1
59 },
60 cardCvv: {
61 label: "CVV",
62 size: 6,
63 row: 2,
64 order: 0
65 },
66 cardZipcode: {
67 label: "ZIP CODE",
68 size: 6,
69 row: 2,
70 order: 1
71 }
72 }
73 },
74 functionCallBackSuccess: function (response) {
75 // This callback covers both 2XX and 4XX responses
76 console.log(response);
77 switch (response.responseText) {
78 case "Success":
79 // Tokenization was successful
80 alert(`Success: ${response.responseData.resultText}`);
81 break;
82 case "Declined":
83 // Tokenization failed due to processor decline or validation errors
84 // Recommend reinitialization of the component so that the user can try again
85 // with different card data
86 alert(`Declined: ${response.responseData.resultText}`);
87 paycomponent0.payabliExec("reinit");
88 break;
89 default:
90 // Other response text. These are normally errors with Payabli internal validations
91 // before processor engagement
92 // We recommend reinitializing the component.
93 // If the problem persists, contact Payabli to help debug
94 alert(`Error: ${response.responseText}`);
95 paycomponent0.payabliExec("reinit");
96 break;
97 }
98 },
99 functionCallBackError: function(errors) {
100 console.log("Payment error:", errors);
101 alert("Payment processing error occurred");
102 payComponent.payabliExec("reinit");
103 },
104 functionCallBackReady: function(data) {
105 const btn = document.getElementById("submit-btn");
106 if (data[1] === true) {
107 btn.classList.remove("hidden");
108 } else {
109 btn.classList.add("hidden");
110 }
111 }
112 };
113 </script>
114</body>
115</html>

/// Initialize and Execute Payment Use the payabliExec method to perform payment processing logic.

The final step creates a working payment form that can process real transactions or save payment methods securely.

-140
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .hidden { display: none; }
8 #submit-btn {
9 background: #4f46e5;
10 color: white;
11 padding: 12px 24px;
12 border: none;
13 border-radius: 6px;
14 cursor: pointer;
15 margin-top: 16px;
16 }
17 #pay-component-1 {
18 max-width: 500px;
19 margin: 20px 0;
20 }
21 </style>
22</head>
23<body>
24 <h1>Payment Form</h1>
25 <p>Enter your payment information below:</p>
26 <div id="pay-component-1"></div>
27 <button id="submit-btn" class="hidden">Process Payment</button>
28
29 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
30 <script>
31 const payabliConfig = {
32 type: "methodEmbedded",
33 rootContainer: "pay-component-1",
34 token: "your-public-api-token",
35 entryPoint: "your-entry-point",
36 defaultOpen: "card",
37 temporaryToken: false,
38 card: {
39 enabled: true,
40 amex: true,
41 discover: true,
42 visa: true,
43 mastercard: true,
44 jcb: true,
45 diners: true,
46 inputs: {
47 cardHolderName: {
48 label: "NAME ON CARD",
49 size: 12,
50 row: 0,
51 order: 0
52 },
53 cardNumber: {
54 label: "CARD NUMBER",
55 size: 6,
56 row: 1,
57 order: 0
58 },
59 cardExpirationDate: {
60 label: "EXPIRATION",
61 size: 6,
62 row: 1,
63 order: 1
64 },
65 cardCvv: {
66 label: "CVV",
67 size: 6,
68 row: 2,
69 order: 0
70 },
71 cardZipcode: {
72 label: "ZIP CODE",
73 size: 6,
74 row: 2,
75 order: 1
76 }
77 }
78 },
79 functionCallBackSuccess: function (response) {
80 // This callback covers both 2XX and 4XX responses
81 console.log(response);
82 switch (response.responseText) {
83 case "Success":
84 // Tokenization was successful
85 alert(`Success: ${response.responseData.resultText}`);
86 break;
87 case "Declined":
88 // Tokenization failed due to processor decline or validation errors
89 // Recommend reinitialization of the component so that the user can try again
90 // with different card data
91 alert(`Declined: ${response.responseData.resultText}`);
92 paycomponent0.payabliExec("reinit");
93 break;
94 default:
95 // Other response text. These are normally errors with Payabli internal validations
96 // before processor engagement
97 // We recommend reinitializing the component.
98 // If the problem persists, contact Payabli to help debug
99 alert(`Error: ${response.responseText}`);
100 paycomponent0.payabliExec("reinit");
101 break;
102 }
103 },
104 functionCallBackError: function(errors) {
105 console.log("Payment error:", errors);
106 alert("Payment processing error occurred");
107 payComponent.payabliExec("reinit");
108 },
109 functionCallBackReady: function(data) {
110 const btn = document.getElementById("submit-btn");
111 if (data[1] === true) {
112 btn.classList.remove("hidden");
113 } else {
114 btn.classList.add("hidden");
115 }
116 }
117 };
118
119 // Initialize the Payabli component
120 const payComponent = new PayabliComponent(payabliConfig);
121
122 // Handle payment execution
123 document.getElementById("submit-btn").addEventListener("click", function() {
124 payComponent.payabliExec('pay', {
125 paymentDetails: {
126 totalAmount: 100.00,
127 serviceFee: 0,
128 categories: [{
129 label: "payment",
130 amount: 100.00,
131 qty: 1
132 }]
133 },
134 customerData: {
135 firstName: "John",
136 lastName: "Doe",
137 billingEmail: "john.doe@example.com"
138 }
139 });
140 });
141 </script>
142</body>
143</html>

You need to include <meta charset="UTF-8"> in the <head> element of your HTML to prevent problems with special characters such as ‘á’ or ‘ñ’.

Configuration reference

These are the configuration parameters available for the EmbeddedMethod component.

The component accepts only the data below. If you need to pass more data than what’s supported, consider using the temporary token flow.

type
stringRequired

This value determines the type of embedded component to render.
Accepted values are: methodEmbedded, methodLightbox, vterminal, or expressCheckout.
For the EmbeddedMethod UI, this value is methodEmbedded. See the Embedded Components Overview for more information on other component types.

rootContainer
stringRequired

Container ID used for the component.

defaultOpen
string

Sets the default payment method that’s shown. Accepted values are: card or ach.

hideComponent
booleanDefaults to false

When true the component is hidden when it’s instanced.

token
stringRequired

API token for authentication. This should be a public API token, as described here.

forceCustomerCreation
booleanDefaults to true

When true, the component uses the customerData object to create a new customer record. When temporaryToken is true and forceCustomerCreation is false, the component doesn’t create a new customer record. See Temporary Token Flow for more information.

customCssUrl
string

Complete URL of a custom CSS stylesheet to use with the component.

clearFormAfterSubmit
booleanDefaults to true

When true, the entered values on the form are cleared when submitted.

temporaryToken
booleanDefaults to true

When true, the token created for the payment is temporary. Set this parameter to false to create a storedMethodId and save the payment profile.

showPopoverError
booleanDefaults to true

When false, the validation error appears below the field instead of above it in a popover.

entryPoint
string

When the API token belongs to an organization, the entrypoint name identifies the target paypoint (merchant).

card
objectRequired

cardService object used to configure accepted card types.

enabled
boolean

Enable/disable card option.

amex
boolean

Enable/disable acceptance of American Express cards.

discover
boolean

Enable/disable acceptance of Discover cards.

visa
boolean

Enable/disable acceptance of Visa cards.

mastercard
boolean

Enable/disable acceptance of MasterCard cards.

diners
boolean

Enable/disable acceptance of Diner’s Club cards.

jcb
boolean

Enable/disable acceptance of JCB cards.

inputs
object

Card input fields descriptors. This object applies only to the EmbeddedMethod UI component.

cardHolderName
object

Optional, but strongly recommended. Descriptor object for input field.

cardNumber
objectRequired

Descriptor object for input field.

cardExpirationDate
objectRequired

Descriptor object for input field.

cardCvv
objectRequired

Descriptor object for input field.

cardZipcode
object

Optional, but strongly recommended. Descriptor object for input field.

ach
objectRequired

achService object used to configure accepted ACH types.

enabled
boolean

Enable/disable ACH option.

checking
boolean

Enable/disable acceptance of Checking account.

savings
boolean

Enable/disable acceptance of Savings account.

achValidation
booleanDefaults to false

When set to true, the embedded component will validate ACH account and routing numbers in real time. This is an add-on feature. Contact the Payabli team for more information.

inputs
object

ACH input field descriptors. This only applies to the EmbeddedMethod UI component.

achAccountHolderName
objectRequired

Required. Descriptor object for input field.

achAccountType
objectRequired

Required. Descriptor object for input field.

achRouting
objectRequired

Required. Descriptor object for input field. Use the confirm input descriptor to add matching validation to this field. See Style Individual Fields for more.

achAccount
objectRequired

Required. Descriptor object for input field. Use the confirm input descriptor to add matching validation to this field. See Style Individual Fields for more.

paymentMethod
objectRequired

paymentMethod object with data related to the payment method. Required when saving a payment method or executing a payment. Can be passed to the component via payabliExec method.

customerData
objectRequired

Customer Object with data related to customer. Can be passed to the component as a parameter with the payabliExec method. Required when saving a payment method. Which fields are required depends on whether the paypoint has custom identifiers. If you aren’t using custom identifiers, then you must include at least one of these values: firstname and lastname, email, or customerId.

paymentDetails
objectRequired

paymentDetails object with data related to the payment. Required to save a payment method. Can be passed to the component via payabliExec method.

fallbackAuth
boolean | nullDefaults to false

When true, if tokenization fails, Payabli will attempt an authorization transaction to request a permanent token for the card. If the authorization is successful, the card will be tokenized and the authorization will be voided automatically.

fallbackAuthAmount
number | nullDefaults to 1.00

The amount for the fallbackAuth transaction. Defaults to one dollar.

functionCallBackSuccess
function

The callback function called when the component executes successfully.

functionCallBackError
function

The callback function called when the component receives an error. See functionCallBackError response in the next section for a complete reference.

functionCallBackReady
function

The callback function called when the component’s status changes. Used to poll the form’s completeness before showing the submit button.

functionCallBackError response

The response for the callback error will contain an array with codes, keys and texts of failed validations. You can check the values in the array to offer your customized error message.

CodeKeyDescription
802paymentMethodsCardNumberErrorError in Card number field
803paymentMethodsCardExpirationDateErrorError in Card Expiration field
804paymentMethodsCardCvvErrorError in CardCVV field
805paymentMethodsCardZipcodeErrorError in Card Zip code field
901paymentMethodsAchAccountHolderNameErrorError in ACH Holder field
902paymentMethodsAchAccountTypeErrorError in ACH Account type field
903paymentMethodsAchRoutingErrorError in ACH Routing field
904paymentMethodsAchAccountErrorError in ACH Account number field

Response

The Response object received via callback Success function has the following structure:

responseText
string

“Success” or “Declined”

responseData
object

Container for response details.

responseData.AuthCode
string

Authorization code for payments. ULL for saving payment methods.

responseData.ReferenceId
string

Identifier for the transaction (for payments) or the stored payment method (for save payment method).

responseData.ResultCode
integer

Result of operation. 1 is success, 2 is declined, and 3 is error.

responseData.ResultText
string

Message related the result. If the operation was successful, it returns “Added”/“Approved”. If there was an error, it returns error details.

responseData.CustomerId
integer

ID for the customer owner of payment or saved payment method.

Examples

These flowcharts visually illustrate the path to making a payment or storing a payment method using an embedded component.

Make a payment

To make a payment with an embedded component, your component configuration should contain payabliExec(pay, parameters). In the parameters argument, include customerData and paymentDetails objects. When the payment is executed, the request returns response data.

This flowchart explains the basic steps for the task. Hover over a step for more information.

Run payabliExec(pay, parameters) The action is set to pay here. Send the paymentDetail and customerData object in parameters.

Payment executed The transaction is executed and includes the data sent as parameters

Response

Save a payment method

To save a payment method with an embedded component, your component configuration should contain payabliExec(method, parameters). In the parameters argument, include customerData and paymentDetails objects. When the payment method is saved, the request returns response data.

This flowchart explains the basic steps for the task. Hover over a step for more information.

Run payabliExec(method, parameters) The action is set to method here. Send the paymentDetail and customerData object in parameters.

Payment method saved The payment method is saved and includes the data sent as parameters

Response

Save a payment method and make a payment

You can save a payment method and make a payment with the EmbeddedMethod UI component by writing a callback function to execute the payment after successfully saving the payment method.

To save a payment method and then execute a transaction with the saved payment method, your component configuration should contain payabliExec(method, parameters). In the parameters argument, include the customerData and paymentDetails objects. When the payment method is saved, use a callback function to execute the transaction.

Remember to never make payment transactions via client-side API requests. Your callback function should make the payment transaction using a server-side function.

This flowchart explains the basic steps for the task. Hover over a step for more information.

Run payabliExec(method, parameters) Here, the action is set to method. Send the paymentDetail and customerData object in parameters.

Payment method saved The payment method is saved and includes the data sent as parameters. An ID for the payment method is returned, which is then used to make transactions.

Callback function Use a callback function to send a transaction that uses the new payment method.

Response