Skip to content

Instantly share code, notes, and snippets.

@phawk
Last active December 29, 2020 08:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phawk/1fcea088772c7249617654c0a226463c to your computer and use it in GitHub Desktop.
Save phawk/1fcea088772c7249617654c0a226463c to your computer and use it in GitHub Desktop.
Payhere embed SDK example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Embed Test Site</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
.container {
margin: 4rem auto;
max-width: 32rem;
text-align: center;
}
</style>
</head>
<body>
<div class="container">
<button id="payhere-custom">Pay now</button>
</div>
<script src="https://payhere.co/embed/embed.js"></script>
<script>
document.getElementById("payhere-custom").addEventListener("click", () => {
console.log("launch payhere embed")
PayHere.launch({
embedURL: "https://sandbox.payhere.co/altlabs/cart",
amountInCents: 4000,
hideAmount: "yes",
onSuccess: function({ customerName, customerEmail }) {
console.log("onSuccess", customerName, customerEmail)
},
onFailure: function(error) {
console.log("onFailure", error)
},
onClose: function() {
console.log("onClose")
}
})
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment