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

This section shows how to use the EmbeddedMethod UI component in your project. Use the interactive demo to see how the component works, then follow the configuration walkthrough to set it up in your project.

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-10-27T17:06:37.243Z/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. Including <meta charset="UTF-8"> in the <head> element prevents problems with special characters such as ‘á’ or ‘ñ’.

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 and Tab Structure

Add a container element where the embedded component will render. The id attribute becomes the rootContainer in your configuration. Create tabs to switch between card, ACH, and RDC payment methods.

-19
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 class="payment-container">
10 <div class="tabs">
11 <button class="tab active" data-method="card">Payment Card</button>
12 <button class="tab" data-method="ach">Bank Debit</button>
13 <button class="tab" data-method="rdc">Check Capture</button>
14 </div>
15 <div class="form-content">
16 <div id="pay-component-1"></div>
17 <button id="submit-btn" class="hidden">Process Payment</button>
18 </div>
19 </div>
20
21 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
22</body>
23</html>

/// Add Basic Styling

Add CSS styles for the tabs to handle active and focus states.

-53
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .tabs {
8 display: flex;
9 border-bottom: 1px solid #e5e5e5;
10 margin-bottom: 20px;
11 }
12
13 .tab {
14 flex: 1;
15 padding: 16px 24px;
16 text-align: center;
17 cursor: pointer;
18 background: white;
19 border: none;
20 border-bottom: 2px solid transparent;
21 transition: all 0.2s ease;
22 }
23
24 .tab:hover {
25 color: #333;
26 background: #f8f9fa;
27 }
28
29 .tab.active {
30 color: #007bff;
31 border-bottom-color: #007bff;
32 }
33
34 .hidden {
35 display: none;
36 }
37
38 #submit-btn {
39 background: #4f46e5;
40 color: white;
41 padding: 12px 24px;
42 border: none;
43 border-radius: 6px;
44 cursor: pointer;
45 margin-top: 16px;
46 }
47
48 #submit-btn:disabled {
49 background: #9ca3af;
50 cursor: not-allowed;
51 }
52 </style>
53</head>
54<body>
55 <h1>Payment Form</h1>
56 <div class="payment-container">
57 <div class="tabs">
58 <button class="tab active" data-method="card">Payment Card</button>
59 <button class="tab" data-method="ach">Bank Debit</button>
60 <button class="tab" data-method="rdc">Check Capture</button>
61 </div>
62 <div class="form-content">
63 <div id="pay-component-1"></div>
64 <button id="submit-btn" class="hidden">Process Payment</button>
65 </div>
66 </div>
67
68 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
69</body>
70</html>

/// Configure Card Payment Method

Create the configuration object for card payments. The token must be a public API token.

-159
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .tabs {
8 display: flex;
9 border-bottom: 1px solid #e5e5e5;
10 margin-bottom: 20px;
11 }
12
13 .tab {
14 flex: 1;
15 padding: 16px 24px;
16 text-align: center;
17 cursor: pointer;
18 background: white;
19 border: none;
20 border-bottom: 2px solid transparent;
21 transition: all 0.2s ease;
22 }
23
24 .tab:hover {
25 color: #333;
26 background: #f8f9fa;
27 }
28
29 .tab.active {
30 color: #007bff;
31 border-bottom-color: #007bff;
32 }
33
34 .hidden {
35 display: none;
36 }
37
38 #submit-btn {
39 background: #4f46e5;
40 color: white;
41 padding: 12px 24px;
42 border: none;
43 border-radius: 6px;
44 cursor: pointer;
45 margin-top: 16px;
46 }
47
48 #submit-btn:disabled {
49 background: #9ca3af;
50 cursor: not-allowed;
51 }
52 </style>
53</head>
54<body>
55 <h1>Payment Form</h1>
56 <div class="payment-container">
57 <div class="tabs">
58 <button class="tab active" data-method="card">Payment Card</button>
59 <button class="tab" data-method="ach">Bank Debit</button>
60 <button class="tab" data-method="rdc">Check Capture</button>
61 </div>
62 <div class="form-content">
63 <div id="pay-component-1"></div>
64 <button id="submit-btn" class="hidden">Process Payment</button>
65 </div>
66 </div>
67
68 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
69 <script>
70 let payComponent;
71
72 const cardConfig = {
73 type: "methodEmbedded",
74 rootContainer: "pay-component-1",
75 token: "your-public-api-token",
76 entryPoint: "your-entry-point",
77 defaultOpen: "card",
78 temporaryToken: false,
79 card: {
80 enabled: true,
81 amex: true,
82 discover: true,
83 visa: true,
84 mastercard: true,
85 jcb: true,
86 diners: true,
87 inputs: {
88 cardHolderName: {
89 label: "NAME ON CARD",
90 size: 12,
91 row: 0,
92 order: 0
93 },
94 cardNumber: {
95 label: "CARD NUMBER",
96 size: 6,
97 row: 1,
98 order: 0
99 },
100 cardExpirationDate: {
101 label: "EXPIRATION",
102 size: 6,
103 row: 1,
104 order: 1
105 },
106 cardCvv: {
107 label: "CVV",
108 size: 6,
109 row: 2,
110 order: 0
111 },
112 cardZipcode: {
113 label: "ZIP CODE",
114 size: 6,
115 row: 2,
116 order: 1
117 }
118 }
119 },
120 functionCallBackSuccess: function (response) {
121 // This callback covers both 2XX and 4XX responses
122 console.log(response);
123 switch (response.responseText) {
124 case "Success":
125 // Tokenization was successful
126 alert(`Success: ${response.responseData.resultText}`);
127 break;
128 case "Declined":
129 // Tokenization failed due to processor decline or validation errors
130 // Recommend reinitialization of the component so that the user can try again
131 // with different card data
132 alert(`Declined: ${response.responseData.resultText}`);
133 payComponent.payabliExec("reinit");
134 break;
135 default:
136 // Other response text. These are normally errors with Payabli internal validations
137 // before processor engagement
138 // We recommend reinitializing the component.
139 // If the problem persists, contact Payabli to help debug
140 alert(`Error: ${response.responseText}`);
141 payComponent.payabliExec("reinit");
142 break;
143 }
144 },
145 functionCallBackError: function(errors) {
146 console.log("Payment error:", errors);
147 alert("Payment processing error occurred");
148 payComponent.payabliExec("reinit");
149 },
150 functionCallBackReady: function(data) {
151 const btn = document.getElementById("submit-btn");
152 if (data[1] === true) {
153 btn.classList.remove("hidden");
154 } else {
155 btn.classList.add("hidden");
156 }
157 }
158 };
159 </script>
160</body>
161</html>

/// Configure ACH Payment Method

Create the configuration object for ACH payments. The token must be a public API token.

-243
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .tabs {
8 display: flex;
9 border-bottom: 1px solid #e5e5e5;
10 margin-bottom: 20px;
11 }
12
13 .tab {
14 flex: 1;
15 padding: 16px 24px;
16 text-align: center;
17 cursor: pointer;
18 background: white;
19 border: none;
20 border-bottom: 2px solid transparent;
21 transition: all 0.2s ease;
22 }
23
24 .tab:hover {
25 color: #333;
26 background: #f8f9fa;
27 }
28
29 .tab.active {
30 color: #007bff;
31 border-bottom-color: #007bff;
32 }
33
34 .hidden {
35 display: none;
36 }
37
38 #submit-btn {
39 background: #4f46e5;
40 color: white;
41 padding: 12px 24px;
42 border: none;
43 border-radius: 6px;
44 cursor: pointer;
45 margin-top: 16px;
46 }
47
48 #submit-btn:disabled {
49 background: #9ca3af;
50 cursor: not-allowed;
51 }
52 </style>
53</head>
54<body>
55 <h1>Payment Form</h1>
56 <div class="payment-container">
57 <div class="tabs">
58 <button class="tab active" data-method="card">Payment Card</button>
59 <button class="tab" data-method="ach">Bank Debit</button>
60 <button class="tab" data-method="rdc">Check Capture</button>
61 </div>
62 <div class="form-content">
63 <div id="pay-component-1"></div>
64 <button id="submit-btn" class="hidden">Process Payment</button>
65 </div>
66 </div>
67
68 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
69 <script>
70 let payComponent;
71
72 const cardConfig = {
73 type: "methodEmbedded",
74 rootContainer: "pay-component-1",
75 token: "your-public-api-token",
76 entryPoint: "your-entry-point",
77 defaultOpen: "card",
78 temporaryToken: false,
79 card: {
80 enabled: true,
81 amex: true,
82 discover: true,
83 visa: true,
84 mastercard: true,
85 jcb: true,
86 diners: true,
87 inputs: {
88 cardHolderName: {
89 label: "NAME ON CARD",
90 size: 12,
91 row: 0,
92 order: 0
93 },
94 cardNumber: {
95 label: "CARD NUMBER",
96 size: 6,
97 row: 1,
98 order: 0
99 },
100 cardExpirationDate: {
101 label: "EXPIRATION",
102 size: 6,
103 row: 1,
104 order: 1
105 },
106 cardCvv: {
107 label: "CVV",
108 size: 6,
109 row: 2,
110 order: 0
111 },
112 cardZipcode: {
113 label: "ZIP CODE",
114 size: 6,
115 row: 2,
116 order: 1
117 }
118 }
119 },
120 functionCallBackSuccess: function (response) {
121 // This callback covers both 2XX and 4XX responses
122 console.log(response);
123 switch (response.responseText) {
124 case "Success":
125 // Tokenization was successful
126 alert(`Success: ${response.responseData.resultText}`);
127 break;
128 case "Declined":
129 // Tokenization failed due to processor decline or validation errors
130 // Recommend reinitialization of the component so that the user can try again
131 // with different card data
132 alert(`Declined: ${response.responseData.resultText}`);
133 payComponent.payabliExec("reinit");
134 break;
135 default:
136 // Other response text. These are normally errors with Payabli internal validations
137 // before processor engagement
138 // We recommend reinitializing the component.
139 // If the problem persists, contact Payabli to help debug
140 alert(`Error: ${response.responseText}`);
141 payComponent.payabliExec("reinit");
142 break;
143 }
144 },
145 functionCallBackError: function(errors) {
146 console.log("Payment error:", errors);
147 alert("Payment processing error occurred");
148 payComponent.payabliExec("reinit");
149 },
150 functionCallBackReady: function(data) {
151 const btn = document.getElementById("submit-btn");
152 if (data[1] === true) {
153 btn.classList.remove("hidden");
154 } else {
155 btn.classList.add("hidden");
156 }
157 }
158 };
159
160 const achConfig = {
161 type: "methodEmbedded",
162 rootContainer: "pay-component-1",
163 token: "your-public-api-token",
164 entryPoint: "your-entry-point",
165 defaultOpen: "ach",
166 temporaryToken: false,
167 ach: {
168 enabled: true,
169 checking: true,
170 savings: true,
171 inputs: {
172 achAccountHolderName: {
173 label: "ACCOUNT HOLDER NAME",
174 placeholder: "Account Holder Name",
175 floating: false,
176 size: 6,
177 row: 0,
178 order: 0
179 },
180 achRouting: {
181 label: "ROUTING NUMBER",
182 placeholder: "123456789",
183 floating: false,
184 size: 6,
185 row: 1,
186 order: 0
187 },
188 achAccount: {
189 label: "ACCOUNT NUMBER",
190 placeholder: "Account Number",
191 floating: false,
192 size: 6,
193 row: 1,
194 order: 1
195 },
196 achAccountType: {
197 label: "ACCOUNT TYPE",
198 floating: false,
199 size: 6,
200 row: 0,
201 order: 1
202 }
203 }
204 },
205 functionCallBackSuccess: function (response) {
206 // This callback covers both 2XX and 4XX responses
207 console.log(response);
208 switch (response.responseText) {
209 case "Success":
210 // Tokenization was successful
211 alert(`Success: ${response.responseData.resultText}`);
212 break;
213 case "Declined":
214 // Tokenization failed due to processor decline or validation errors
215 // Recommend reinitialization of the component so that the user can try again
216 // with different card data
217 alert(`Declined: ${response.responseData.resultText}`);
218 payComponent.payabliExec("reinit");
219 break;
220 default:
221 // Other response text. These are normally errors with Payabli internal validations
222 // before processor engagement
223 // We recommend reinitializing the component.
224 // If the problem persists, contact Payabli to help debug
225 alert(`Error: ${response.responseText}`);
226 payComponent.payabliExec("reinit");
227 break;
228 }
229 },
230 functionCallBackError: function(errors) {
231 console.log("Payment error:", errors);
232 alert("Payment processing error occurred");
233 payComponent.payabliExec("reinit");
234 },
235 functionCallBackReady: function(data) {
236 const btn = document.getElementById("submit-btn");
237 if (data[1] === true) {
238 btn.classList.remove("hidden");
239 } else {
240 btn.classList.add("hidden");
241 }
242 }
243 };
244 </script>
245</body>
246</html>

/// Configure RDC Payment Method

Create the configuration object for RDC (Remote Deposit Capture) payments. The token must be a public API token.

-278
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .tabs {
8 display: flex;
9 border-bottom: 1px solid #e5e5e5;
10 margin-bottom: 20px;
11 }
12
13 .tab {
14 flex: 1;
15 padding: 16px 24px;
16 text-align: center;
17 cursor: pointer;
18 background: white;
19 border: none;
20 border-bottom: 2px solid transparent;
21 transition: all 0.2s ease;
22 }
23
24 .tab:hover {
25 color: #333;
26 background: #f8f9fa;
27 }
28
29 .tab.active {
30 color: #007bff;
31 border-bottom-color: #007bff;
32 }
33
34 .hidden {
35 display: none;
36 }
37
38 #submit-btn {
39 background: #4f46e5;
40 color: white;
41 padding: 12px 24px;
42 border: none;
43 border-radius: 6px;
44 cursor: pointer;
45 margin-top: 16px;
46 }
47
48 #submit-btn:disabled {
49 background: #9ca3af;
50 cursor: not-allowed;
51 }
52 </style>
53</head>
54<body>
55 <h1>Payment Form</h1>
56 <div class="payment-container">
57 <div class="tabs">
58 <button class="tab active" data-method="card">Payment Card</button>
59 <button class="tab" data-method="ach">Bank Debit</button>
60 <button class="tab" data-method="rdc">Check Capture</button>
61 </div>
62 <div class="form-content">
63 <div id="pay-component-1"></div>
64 <button id="submit-btn" class="hidden">Process Payment</button>
65 </div>
66 </div>
67
68 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
69 <script>
70 let payComponent;
71
72 const cardConfig = {
73 type: "methodEmbedded",
74 rootContainer: "pay-component-1",
75 token: "your-public-api-token",
76 entryPoint: "your-entry-point",
77 defaultOpen: "card",
78 temporaryToken: false,
79 card: {
80 enabled: true,
81 amex: true,
82 discover: true,
83 visa: true,
84 mastercard: true,
85 jcb: true,
86 diners: true,
87 inputs: {
88 cardHolderName: {
89 label: "NAME ON CARD",
90 size: 12,
91 row: 0,
92 order: 0
93 },
94 cardNumber: {
95 label: "CARD NUMBER",
96 size: 6,
97 row: 1,
98 order: 0
99 },
100 cardExpirationDate: {
101 label: "EXPIRATION",
102 size: 6,
103 row: 1,
104 order: 1
105 },
106 cardCvv: {
107 label: "CVV",
108 size: 6,
109 row: 2,
110 order: 0
111 },
112 cardZipcode: {
113 label: "ZIP CODE",
114 size: 6,
115 row: 2,
116 order: 1
117 }
118 }
119 },
120 functionCallBackSuccess: function (response) {
121 console.log(response);
122 switch (response.responseText) {
123 case "Success":
124 alert(`Success: ${response.responseData.resultText}`);
125 break;
126 case "Declined":
127 alert(`Declined: ${response.responseData.resultText}`);
128 payComponent.payabliExec("reinit");
129 break;
130 default:
131 alert(`Error: ${response.responseText}`);
132 payComponent.payabliExec("reinit");
133 break;
134 }
135 },
136 functionCallBackError: function(errors) {
137 console.log("Payment error:", errors);
138 alert("Payment processing error occurred");
139 payComponent.payabliExec("reinit");
140 },
141 functionCallBackReady: function(data) {
142 const btn = document.getElementById("submit-btn");
143 if (data[1] === true) {
144 btn.classList.remove("hidden");
145 } else {
146 btn.classList.add("hidden");
147 }
148 }
149 };
150
151 const achConfig = {
152 type: "methodEmbedded",
153 rootContainer: "pay-component-1",
154 token: "your-public-api-token",
155 entryPoint: "your-entry-point",
156 defaultOpen: "ach",
157 temporaryToken: false,
158 ach: {
159 enabled: true,
160 checking: true,
161 savings: true,
162 inputs: {
163 achAccountHolderName: {
164 label: "ACCOUNT HOLDER NAME",
165 placeholder: "Account Holder Name",
166 floating: false,
167 size: 6,
168 row: 0,
169 order: 0
170 },
171 achRouting: {
172 label: "ROUTING NUMBER",
173 placeholder: "123456789",
174 floating: false,
175 size: 6,
176 row: 1,
177 order: 0
178 },
179 achAccount: {
180 label: "ACCOUNT NUMBER",
181 placeholder: "Account Number",
182 floating: false,
183 size: 6,
184 row: 1,
185 order: 1
186 },
187 achAccountType: {
188 label: "ACCOUNT TYPE",
189 floating: false,
190 size: 6,
191 row: 0,
192 order: 1
193 }
194 }
195 },
196 functionCallBackSuccess: function (response) {
197 console.log(response);
198 switch (response.responseText) {
199 case "Success":
200 alert(`Success: ${response.responseData.resultText}`);
201 break;
202 case "Declined":
203 alert(`Declined: ${response.responseData.resultText}`);
204 payComponent.payabliExec("reinit");
205 break;
206 default:
207 alert(`Error: ${response.responseText}`);
208 payComponent.payabliExec("reinit");
209 break;
210 }
211 },
212 functionCallBackError: function(errors) {
213 console.log("Payment error:", errors);
214 alert("Payment processing error occurred");
215 payComponent.payabliExec("reinit");
216 },
217 functionCallBackReady: function(data) {
218 const btn = document.getElementById("submit-btn");
219 if (data[1] === true) {
220 btn.classList.remove("hidden");
221 } else {
222 btn.classList.add("hidden");
223 }
224 }
225 };
226
227 const rdcConfig = {
228 type: "methodEmbedded",
229 rootContainer: "pay-component-1",
230 token: "your-public-api-token",
231 entryPoint: "your-entry-point",
232 defaultOpen: "rdc",
233 temporaryToken: false,
234 card: { enabled: true },
235 rdc: {
236 enabled: true,
237 amount: 100,
238 inputs: {
239 rdcAccountHolderName: {
240 label: "ACCOUNT HOLDER NAME",
241 placeholder: "Account Holder Name",
242 floating: false,
243 size: 12,
244 row: 0,
245 order: 0
246 }
247 }
248 },
249 functionCallBackSuccess: function (response) {
250 console.log(response);
251 switch (response.responseText) {
252 case "Success":
253 alert(`Success: ${response.responseData.resultText}`);
254 break;
255 case "Declined":
256 alert(`Declined: ${response.responseData.resultText}`);
257 payComponent.payabliExec("reinit");
258 break;
259 default:
260 alert(`Error: ${response.responseText}`);
261 payComponent.payabliExec("reinit");
262 break;
263 }
264 },
265 functionCallBackError: function(errors) {
266 console.log("Payment error:", errors);
267 alert("Payment processing error occurred");
268 payComponent.payabliExec("reinit");
269 },
270 functionCallBackReady: function(data) {
271 const btn = document.getElementById("submit-btn");
272 if (data[1] === true) {
273 btn.classList.remove("hidden");
274 } else {
275 btn.classList.add("hidden");
276 }
277 }
278 };
279 </script>
280</body>
281</html>

/// Add Tab Switching Logic

Add JavaScript code for the tabs. The code handles reinitializing the component when users change payment methods.

-298
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .tabs {
8 display: flex;
9 border-bottom: 1px solid #e5e5e5;
10 margin-bottom: 20px;
11 }
12
13 .tab {
14 flex: 1;
15 padding: 16px 24px;
16 text-align: center;
17 cursor: pointer;
18 background: white;
19 border: none;
20 border-bottom: 2px solid transparent;
21 transition: all 0.2s ease;
22 }
23
24 .tab:hover {
25 color: #333;
26 background: #f8f9fa;
27 }
28
29 .tab.active {
30 color: #007bff;
31 border-bottom-color: #007bff;
32 }
33
34 .hidden {
35 display: none;
36 }
37
38 #submit-btn {
39 background: #4f46e5;
40 color: white;
41 padding: 12px 24px;
42 border: none;
43 border-radius: 6px;
44 cursor: pointer;
45 margin-top: 16px;
46 }
47
48 #submit-btn:disabled {
49 background: #9ca3af;
50 cursor: not-allowed;
51 }
52 </style>
53</head>
54<body>
55 <h1>Payment Form</h1>
56 <div class="payment-container">
57 <div class="tabs">
58 <button class="tab active" data-method="card">Payment Card</button>
59 <button class="tab" data-method="ach">Bank Debit</button>
60 <button class="tab" data-method="rdc">Check Capture</button>
61 </div>
62 <div class="form-content">
63 <div id="pay-component-1"></div>
64 <button id="submit-btn" class="hidden">Process Payment</button>
65 </div>
66 </div>
67
68 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
69 <script>
70 let payComponent;
71
72 const cardConfig = {
73 type: "methodEmbedded",
74 rootContainer: "pay-component-1",
75 token: "your-public-api-token",
76 entryPoint: "your-entry-point",
77 defaultOpen: "card",
78 temporaryToken: false,
79 card: {
80 enabled: true,
81 amex: true,
82 discover: true,
83 visa: true,
84 mastercard: true,
85 jcb: true,
86 diners: true,
87 inputs: {
88 cardHolderName: {
89 label: "NAME ON CARD",
90 size: 12,
91 row: 0,
92 order: 0
93 },
94 cardNumber: {
95 label: "CARD NUMBER",
96 size: 6,
97 row: 1,
98 order: 0
99 },
100 cardExpirationDate: {
101 label: "EXPIRATION",
102 size: 6,
103 row: 1,
104 order: 1
105 },
106 cardCvv: {
107 label: "CVV",
108 size: 6,
109 row: 2,
110 order: 0
111 },
112 cardZipcode: {
113 label: "ZIP CODE",
114 size: 6,
115 row: 2,
116 order: 1
117 }
118 }
119 },
120 functionCallBackSuccess: function (response) {
121 console.log(response);
122 switch (response.responseText) {
123 case "Success":
124 alert(`Success: ${response.responseData.resultText}`);
125 break;
126 case "Declined":
127 alert(`Declined: ${response.responseData.resultText}`);
128 payComponent.payabliExec("reinit");
129 break;
130 default:
131 alert(`Error: ${response.responseText}`);
132 payComponent.payabliExec("reinit");
133 break;
134 }
135 },
136 functionCallBackError: function(errors) {
137 console.log("Payment error:", errors);
138 alert("Payment processing error occurred");
139 payComponent.payabliExec("reinit");
140 },
141 functionCallBackReady: function(data) {
142 const btn = document.getElementById("submit-btn");
143 if (data[1] === true) {
144 btn.classList.remove("hidden");
145 } else {
146 btn.classList.add("hidden");
147 }
148 }
149 };
150
151 const achConfig = {
152 type: "methodEmbedded",
153 rootContainer: "pay-component-1",
154 token: "your-public-api-token",
155 entryPoint: "your-entry-point",
156 defaultOpen: "ach",
157 temporaryToken: false,
158 ach: {
159 enabled: true,
160 checking: true,
161 savings: true,
162 inputs: {
163 achAccountHolderName: {
164 label: "ACCOUNT HOLDER NAME",
165 placeholder: "Account Holder Name",
166 floating: false,
167 size: 6,
168 row: 0,
169 order: 0
170 },
171 achRouting: {
172 label: "ROUTING NUMBER",
173 placeholder: "123456789",
174 floating: false,
175 size: 6,
176 row: 1,
177 order: 0
178 },
179 achAccount: {
180 label: "ACCOUNT NUMBER",
181 placeholder: "Account Number",
182 floating: false,
183 size: 6,
184 row: 1,
185 order: 1
186 },
187 achAccountType: {
188 label: "ACCOUNT TYPE",
189 floating: false,
190 size: 6,
191 row: 0,
192 order: 1
193 }
194 }
195 },
196 functionCallBackSuccess: function (response) {
197 console.log(response);
198 switch (response.responseText) {
199 case "Success":
200 alert(`Success: ${response.responseData.resultText}`);
201 break;
202 case "Declined":
203 alert(`Declined: ${response.responseData.resultText}`);
204 payComponent.payabliExec("reinit");
205 break;
206 default:
207 alert(`Error: ${response.responseText}`);
208 payComponent.payabliExec("reinit");
209 break;
210 }
211 },
212 functionCallBackError: function(errors) {
213 console.log("Payment error:", errors);
214 alert("Payment processing error occurred");
215 payComponent.payabliExec("reinit");
216 },
217 functionCallBackReady: function(data) {
218 const btn = document.getElementById("submit-btn");
219 if (data[1] === true) {
220 btn.classList.remove("hidden");
221 } else {
222 btn.classList.add("hidden");
223 }
224 }
225 };
226
227 const rdcConfig = {
228 type: "methodEmbedded",
229 rootContainer: "pay-component-1",
230 token: "your-public-api-token",
231 entryPoint: "your-entry-point",
232 defaultOpen: "rdc",
233 temporaryToken: false,
234 card: { enabled: true },
235 rdc: {
236 enabled: true,
237 amount: 100,
238 inputs: {
239 rdcAccountHolderName: {
240 label: "ACCOUNT HOLDER NAME",
241 placeholder: "Account Holder Name",
242 floating: false,
243 size: 12,
244 row: 0,
245 order: 0
246 }
247 }
248 },
249 functionCallBackSuccess: function (response) {
250 console.log(response);
251 switch (response.responseText) {
252 case "Success":
253 alert(`Success: ${response.responseData.resultText}`);
254 break;
255 case "Declined":
256 alert(`Declined: ${response.responseData.resultText}`);
257 payComponent.payabliExec("reinit");
258 break;
259 default:
260 alert(`Error: ${response.responseText}`);
261 payComponent.payabliExec("reinit");
262 break;
263 }
264 },
265 functionCallBackError: function(errors) {
266 console.log("Payment error:", errors);
267 alert("Payment processing error occurred");
268 payComponent.payabliExec("reinit");
269 },
270 functionCallBackReady: function(data) {
271 const btn = document.getElementById("submit-btn");
272 if (data[1] === true) {
273 btn.classList.remove("hidden");
274 } else {
275 btn.classList.add("hidden");
276 }
277 }
278 };
279
280 // Tab switching
281 document.querySelectorAll('.tab').forEach(tab => {
282 tab.addEventListener('click', function() {
283 const method = this.dataset.method;
284
285 // Update active tab
286 document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
287 this.classList.add('active');
288
289 // Create new component with appropriate config
290 if (method === 'card') {
291 payComponent = new PayabliComponent(cardConfig);
292 } else if (method === 'ach') {
293 payComponent = new PayabliComponent(achConfig);
294 } else if (method === 'rdc') {
295 payComponent = new PayabliComponent(rdcConfig);
296 }
297 });
298 });
299 </script>
300</body>
301</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.

-322
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="UTF-8">
5 <title>Payabli Integration</title>
6 <style>
7 .tabs {
8 display: flex;
9 border-bottom: 1px solid #e5e5e5;
10 margin-bottom: 20px;
11 }
12
13 .tab {
14 flex: 1;
15 padding: 16px 24px;
16 text-align: center;
17 cursor: pointer;
18 background: white;
19 border: none;
20 border-bottom: 2px solid transparent;
21 transition: all 0.2s ease;
22 }
23
24 .tab:hover {
25 color: #333;
26 background: #f8f9fa;
27 }
28
29 .tab.active {
30 color: #007bff;
31 border-bottom-color: #007bff;
32 }
33
34 .hidden {
35 display: none;
36 }
37
38 #submit-btn {
39 background: #4f46e5;
40 color: white;
41 padding: 12px 24px;
42 border: none;
43 border-radius: 6px;
44 cursor: pointer;
45 margin-top: 16px;
46 }
47
48 #submit-btn:disabled {
49 background: #9ca3af;
50 cursor: not-allowed;
51 }
52 </style>
53</head>
54<body>
55 <h1>Payment Form</h1>
56 <p>Enter your payment information below:</p>
57 <div class="payment-container">
58 <div class="tabs">
59 <button class="tab active" data-method="card">Payment Card</button>
60 <button class="tab" data-method="ach">Bank Debit</button>
61 <button class="tab" data-method="rdc">Check Capture</button>
62 </div>
63 <div class="form-content">
64 <div id="pay-component-1"></div>
65 <button id="submit-btn" class="hidden">Process Payment</button>
66 </div>
67 </div>
68
69 <script src="https://embedded-component-sandbox.payabli.com/component.js" data-test></script>
70 <script>
71 let payComponent;
72
73 const cardConfig = {
74 type: "methodEmbedded",
75 rootContainer: "pay-component-1",
76 token: "your-public-api-token",
77 entryPoint: "your-entry-point",
78 defaultOpen: "card",
79 temporaryToken: false,
80 card: {
81 enabled: true,
82 amex: true,
83 discover: true,
84 visa: true,
85 mastercard: true,
86 jcb: true,
87 diners: true,
88 inputs: {
89 cardHolderName: {
90 label: "NAME ON CARD",
91 size: 12,
92 row: 0,
93 order: 0
94 },
95 cardNumber: {
96 label: "CARD NUMBER",
97 size: 6,
98 row: 1,
99 order: 0
100 },
101 cardExpirationDate: {
102 label: "EXPIRATION",
103 size: 6,
104 row: 1,
105 order: 1
106 },
107 cardCvv: {
108 label: "CVV",
109 size: 6,
110 row: 2,
111 order: 0
112 },
113 cardZipcode: {
114 label: "ZIP CODE",
115 size: 6,
116 row: 2,
117 order: 1
118 }
119 }
120 },
121 functionCallBackSuccess: function (response) {
122 console.log(response);
123 switch (response.responseText) {
124 case "Success":
125 alert(`Success: ${response.responseData.resultText}`);
126 break;
127 case "Declined":
128 alert(`Declined: ${response.responseData.resultText}`);
129 payComponent.payabliExec("reinit");
130 break;
131 default:
132 alert(`Error: ${response.responseText}`);
133 payComponent.payabliExec("reinit");
134 break;
135 }
136 },
137 functionCallBackError: function(errors) {
138 console.log("Payment error:", errors);
139 alert("Payment processing error occurred");
140 payComponent.payabliExec("reinit");
141 },
142 functionCallBackReady: function(data) {
143 const btn = document.getElementById("submit-btn");
144 if (data[1] === true) {
145 btn.classList.remove("hidden");
146 } else {
147 btn.classList.add("hidden");
148 }
149 }
150 };
151
152 const achConfig = {
153 type: "methodEmbedded",
154 rootContainer: "pay-component-1",
155 token: "your-public-api-token",
156 entryPoint: "your-entry-point",
157 defaultOpen: "ach",
158 temporaryToken: false,
159 ach: {
160 enabled: true,
161 checking: true,
162 savings: true,
163 inputs: {
164 achAccountHolderName: {
165 label: "ACCOUNT HOLDER NAME",
166 placeholder: "Account Holder Name",
167 floating: false,
168 size: 6,
169 row: 0,
170 order: 0
171 },
172 achRouting: {
173 label: "ROUTING NUMBER",
174 placeholder: "123456789",
175 floating: false,
176 size: 6,
177 row: 1,
178 order: 0
179 },
180 achAccount: {
181 label: "ACCOUNT NUMBER",
182 placeholder: "Account Number",
183 floating: false,
184 size: 6,
185 row: 1,
186 order: 1
187 },
188 achAccountType: {
189 label: "ACCOUNT TYPE",
190 floating: false,
191 size: 6,
192 row: 0,
193 order: 1
194 }
195 }
196 },
197 functionCallBackSuccess: function (response) {
198 console.log(response);
199 switch (response.responseText) {
200 case "Success":
201 alert(`Success: ${response.responseData.resultText}`);
202 break;
203 case "Declined":
204 alert(`Declined: ${response.responseData.resultText}`);
205 payComponent.payabliExec("reinit");
206 break;
207 default:
208 alert(`Error: ${response.responseText}`);
209 payComponent.payabliExec("reinit");
210 break;
211 }
212 },
213 functionCallBackError: function(errors) {
214 console.log("Payment error:", errors);
215 alert("Payment processing error occurred");
216 payComponent.payabliExec("reinit");
217 },
218 functionCallBackReady: function(data) {
219 const btn = document.getElementById("submit-btn");
220 if (data[1] === true) {
221 btn.classList.remove("hidden");
222 } else {
223 btn.classList.add("hidden");
224 }
225 }
226 };
227
228 const rdcConfig = {
229 type: "methodEmbedded",
230 rootContainer: "pay-component-1",
231 token: "your-public-api-token",
232 entryPoint: "your-entry-point",
233 defaultOpen: "rdc",
234 temporaryToken: false,
235 card: { enabled: true },
236 rdc: {
237 enabled: true,
238 amount: 100,
239 inputs: {
240 rdcAccountHolderName: {
241 label: "ACCOUNT HOLDER NAME",
242 placeholder: "Account Holder Name",
243 floating: false,
244 size: 12,
245 row: 0,
246 order: 0
247 }
248 }
249 },
250 functionCallBackSuccess: function (response) {
251 console.log(response);
252 switch (response.responseText) {
253 case "Success":
254 alert(`Success: ${response.responseData.resultText}`);
255 break;
256 case "Declined":
257 alert(`Declined: ${response.responseData.resultText}`);
258 payComponent.payabliExec("reinit");
259 break;
260 default:
261 alert(`Error: ${response.responseText}`);
262 payComponent.payabliExec("reinit");
263 break;
264 }
265 },
266 functionCallBackError: function(errors) {
267 console.log("Payment error:", errors);
268 alert("Payment processing error occurred");
269 payComponent.payabliExec("reinit");
270 },
271 functionCallBackReady: function(data) {
272 const btn = document.getElementById("submit-btn");
273 if (data[1] === true) {
274 btn.classList.remove("hidden");
275 } else {
276 btn.classList.add("hidden");
277 }
278 }
279 };
280
281 // Tab switching
282 document.querySelectorAll('.tab').forEach(tab => {
283 tab.addEventListener('click', function() {
284 const method = this.dataset.method;
285
286 // Update active tab
287 document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
288 this.classList.add('active');
289
290 // Create new component with appropriate config
291 if (method === 'card') {
292 payComponent = new PayabliComponent(cardConfig);
293 } else if (method === 'ach') {
294 payComponent = new PayabliComponent(achConfig);
295 } else if (method === 'rdc') {
296 payComponent = new PayabliComponent(rdcConfig);
297 }
298 });
299 });
300
301 // Initialize the Payabli component
302 payComponent = new PayabliComponent(cardConfig);
303
304 // Handle payment execution
305 document.getElementById("submit-btn").addEventListener("click", function() {
306 payComponent.payabliExec('pay', {
307 paymentDetails: {
308 totalAmount: 100.00,
309 serviceFee: 0,
310 categories: [{
311 label: "payment",
312 amount: 100.00,
313 qty: 1
314 }]
315 },
316 customerData: {
317 firstName: "John",
318 lastName: "Doe",
319 billingEmail: "john.doe@example.com"
320 }
321 });
322 });
323 </script>
324</body>
325</html>

Configuration reference

These are the configuration parameters available for the EmbeddedMethod component. If you need to pass more than data than what’s supported, consider using the temporary token flow. See Temporary Token Flow for more information.

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.

rdc
objectRequired

rdcService object used to configure accepted RDC types.

enabled
boolean

Enable/disable RDC option.

amount
number

Amount to collect via RDC.

inputs
object

RDC input field descriptors.

rdcAccountHolderName
object

Descriptor object for input field.

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.

Response

The embedded component returns a response object to the callback functions defined in the configuration. The response object contains the result of the transaction (success, declined, or error) and details about the transaction.

Response examples

Click the tab to see an example response returned by the embedded component for each result.

1{
2 responseText: "Success",
3 responseData: {
4 authCode: "123456",
5 referenceId: "40-692c62895d1541d28c0bf77b275a26e4",
6 resultCode: 1,
7 resultText: "Approved",
8 avsResponseText: "",
9 cvvResponseText: "",
10 customerId: 706,
11 methodReferenceId: null
12 }
13}

Response reference

The response object passed to a callback function has the following structure:

responseText
string

“Success” or “Declined”

responseData
object

Container for response details.

responseData.AuthCode
string

Authorization code for payments. This field has a value of null for saved 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.AvsResponseText
string

Result of address validation for card transactions. This field is an empty string when processing ACH transactions. This field doesn’t exist when saving payment methods.

responseData.CvvResponseText
string

Result of CVV validation for card transactions. This field is an empty string when processing ACH transactions. This field doesn’t exist when saving payment methods.

responseData.CustomerId
integer

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

responseData.methodReferenceId
string

Identifier for stored payment method for saved payment methods. This field has a value of null for payment transactions. The methodReferenceId is used as the storedMethodId in other operations. See Handling responses and errors for more.

functionCallBackError response

The functionCallBackError function is called when the component can’t validate the payment information before submitting it to Payabli’s API. The response object passed to functionCallBackError contains an array with codes, keys, and descriptions 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

Usage Flows

These flowcharts 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

See related resources to help you get the most out of Payabli.