Feel free to fork it
VueJS component wrapper for Khalti SDK
https://codesandbox.io/s/k574mxpl17
npm install khalti-web --save
npm install vue-khalti --save
<script src="dist/vue-khalti-min.js"></script>
<script src="path/to/vue.js"></script>
<script>
Vue.use(VueKhalti)
</script>
<script>
import VueKhalti from 'vue-khalti'
export default {
components: { VueKhalti }
}
</script>
<template>
<div>
<vue-khalti />
</div>
</template>
data () {
return {
khaltiConfig: {
"publicKey": "YOUR_PUBLIC_KEY",
"productIdentity": "YOUR_PRODUCT_ID",
"productName": "YOUR_PRODUCT_NAME",
"productUrl": "YOUR_PRODUCT_URL",
"amount": 1000,
"eventHandler": {
onSuccess (payload) {
console.log(payload);
},
onError (error) {
console.log(error);
},
onClose () {
console.log('widget is closing');
}
}
}
}
}
<vue-khalti v-bind="khaltiConfig" />
<vue-khalti ref="khaltiCheckout">
<img
src="https://d7vw40z4bofef.cloudfront.net/static/www/images/khaltilogo.png"
@click="onKhaltiClick" />
</vue-khalti>
methods: {
onKhaltiClick () {
const khaltiCheckout = this.$refs.khaltiCheckout
khaltiCheckout.onClick()
}
}