Payment Button
This guide provides instructions on how to integrate the Pay Hero payment button widget into your web application.
Overview
The Pay Hero Payment Button Widget allows merchants and developers to easily integrate a payment button into their websites or applications. The widget provides a seamless way for customers to make payments through Pay Hero without leaving the merchant's site.
Features
Easy Integration: Just include the JavaScript SDK and configure a few parameters.
Customizable Button: Set button text, color, and dimensions.
Event Handling: Listen for successful or failed payments using JavaScript event listeners.
Redirection Support: Define success and failure URLs for post-payment actions.
Callback URL Support: Receive a payment payload for backend processing.
Installation
Include the Pay Hero Button SDK in your HTML file:
Usage
To use the widget, insert the following code into your HTML page:
Parameters
paymentUrl
Yes
Your Pay Hero Lipwa payment link.
width
No
Width of the button (default: 100%).
height
No
Height of the button (default: 100%).
containerId
Yes
The HTML element ID where the button will be injected.
channelID
Yes
Your unique payment channel ID.
amount
Yes
The amount to be paid.
phone
No
Customer's phone number (optional).
name
No
Customer's name (optional).
reference
No
A unique reference for tracking payments.
buttonName
Yes
The text displayed on the payment button.
buttonColor
Yes
The color of the payment button.
successUrl
No
URL to redirect the user upon a successful payment.
failedUrl
No
URL to redirect the user if the payment fails.
callbackUrl
No
Webhook URL where Pay Hero sends the payment details upon success.
Handling Payment Events
To listen for payment success or failure, use the following JavaScript event listener:
Use Cases
E-commerce Websites: Enable customers to make instant payments for products or services.
Service Providers: Freelancers or businesses can embed the button for easy payment collection.
Event Ticketing: Sell event tickets online with a seamless checkout experience.
Donations: Non-profits can collect donations with a single click.
Subscription Payments: Collect recurring or one-time subscription fees from users.
Conclusion
The Pay Hero Payment Button Widget simplifies payment processing, making it easier for businesses and individuals to collect payments securely. With a few lines of code, you can integrate a fully functional payment button into your website.
Success Callback URL Payload
This is the payload that will be sent to the provided callback URL via POST.
DEMO
Support
Credits: Wahome Mutahi
Last updated
Was this helpful?