Last active
December 29, 2020 08:00
-
-
Save phawk/1fcea088772c7249617654c0a226463c to your computer and use it in GitHub Desktop.
Payhere embed SDK example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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