Wix Embed SDK
Installation
First, set up your payment links in Wix to like to Payhere, you can see how to do that using the following guide.
Once you have your buttons connected, you’ll want to add a Custom Code
marketing element.
- First you’ll want to select the 'Add element' button on the right hand menu in the Wix editor
- Then choose 'Embed code', and 'Marketing tools', and finally click the 'Custom Code' element.
- Next you’ll see a screen showing some areas of the page you can add custom code to. Inside the 'Head` section, click the 'Add code' button
- Paste the code snippet below into the first box.
- Give your embed code a name, this can be anything you want, but I’ve used 'Payhere auto embed' in this example.
- Click 'Apply'
- Publish the changes to your website
Now any Payhere links that you setup using the previous guide will open embedded within your website 🎉
<script src="https://app.payhere.co/embed/embed.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll("a").forEach(function (link) {
const text = link.innerText.trim()
if (link.href.startsWith("https://sandbox.payhere.co") || link.href.startsWith("https://app.payhere.co")) {
console.log("link", link.href)
link.addEventListener("click", function(event) {
event.preventDefault()
PayHere.launch({
embedURL: link.href
})
})
}
})
});
</script>