Embedded components framework integrations
Learn how to use Payabli’s embedded components with front-end frameworks like React and Vue
You can use Payabli’s embedded components in a React or Vue application following the same configuration patterns as in a vanilla JavaScript application.
React
Visit the React Integration Example to see Payabli’s embedded components in a React application.
Step 1: Create the hook
Create a hook that allows you to use the embedded component and execute its methods.
The hook needs to inject the Payabli library script and initialize the embedded component with the provided configuration.
Make a new file for the usePayabli
hook and add the following code:
Step 2: Create the component
Create a new PayabliCheckout
component that passes in the configuration object for the embedded component to the usePayabli
hook.
The PayabliCheckout
component uses the payabliExec
function to execute the embedded component’s method.
Create a new file in the same directory and add the following code:
There are multiple types of embedded components with different use cases. See the Embedded Components Overview to decide which component type is best for you.
EmbeddedMethod UI
PayMethod UI
Types
The hook receives the following arguments:
The configuration object for the embedded component.
The method to execute in payabliExec
. See the field for more information.
An optional object that contains objects to pass to the method
. See the paymentMethod
, paymentDetails
, or customerData
objects for more information.
A boolean value that determines whether to use the production or sandbox environment.
The hook returns an array with the following elements:
The configuration object for the embedded component.
A function to update the configuration object for the embedded component. This allows you to dynamically change the options after initialization.
A function to execute the embedded component’s method. This will call the method specified in the method
argument passed to the hook.
A function to reinitialize the embedded component.
Vue
Visit the Vue integration example to see Payabli’s embedded components in a Vue application.
Step 1: Create the composable
Create a composable that allows you to use the embedded component and execute its methods.
The composable needs to inject the Payabli library script and initialize the embedded component with the provided configuration.
Make a new file for the usePayabli
composable and add the following code:
Step 2: Create the component
Create a new PayabliCheckout
component that passes in the configuration object for the embedded component to the usePayabli
composable.
The PayabliCheckout
component uses the payabliExec
function to execute the embedded component’s method.
Create a new file in the same directory and add the following code:
EmbeddedMethod UI
Types
The composable receives the following arguments:
The configuration object for the embedded component.
The method to execute in payabliExec
. See the field for more information.
An optional object that contains objects to pass to the method
. See the paymentMethod
, paymentDetails
, or customerData
objects for more information.
A boolean value that determines whether to use the production or sandbox environment.
The composable returns an array with the following elements:
The configuration object for the embedded component.
A function to execute the embedded component’s method. This will call the method specified in the method
argument passed to the hook.
A function to reinitialize the embedded component.