Payment Widget overview
The Payment Widget allows is a pre-built JavaScript UI that allows you to embed payments directly into your custom website without extensive development work.
Benefits of the Payment Widget
-
It allows you to begin accepting payments faster.
-
It’s simple and easy to integrate into your current website.
-
You can customise the widget to the style that best suits your needs.
-
It takes care of the entire transaction process, including the collection of payment information and the security of sensitive data. This reduces your compliance requirements and lets you focus on your business.
How does the Payment Widget work?
-
Truevo offers a pre-built Payment Widget form that you embed on your website. Buyers then provide their payment information directly on your checkout page within the embedded widget.
-
Once the customer submits their payment, Truevo automatically processes the payment on your behalf.
How to integrate a Payment Widget
When your customer loads a checkout page, add the following code to the page:
Document
Let’s explain what’s taking place in the above sample code.
Start by including a div element in the place where you want the payment form to be displayed.
Include a script tag that loads the Truevo Hosted Payments Widget SDK (merchant.minified.js).
Configure the payment widget within another script tag directly on the page.
Do the following within that script:
- Create a configuration object using the various attributes of the payment you wish to capture, such as type of the transaction, widget configuration settings (including your preferred widget style configuration), transaction details, merchant details, customer details, and generated digital signature.
Note that the signature property is a digital signature that allows us to validate the authenticity and integrity of the request sent to us. Read how to create a digital signature here.
-
-
Initialize the widget using the TruevoCheckout.initialize function while passing the configuration object into it as a parameter.
-
Create a Truevo checkout session by calling TruevoCheckout.mount while passing a selector that identifies the div element that renders the payment widget form.
-
Add various event listener functions that are called whenever the specified payment event takes place.
-
Sample response
{
rrn: '',
transactionId: '',
transactionStatus: '',
responseCode: '',
merchantReference: ''
}
Custom styles
The Payment Widget offers the ability to apply custom styles. For more information and example implementation please review our Payment Widget styling capabilities.