Skip to content

Instantly share code, notes, and snippets.

@nickfogle
Created July 21, 2021 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickfogle/fc2ffeb83b006356a662488d1e1041d6 to your computer and use it in GitHub Desktop.
Save nickfogle/fc2ffeb83b006356a662488d1e1041d6 to your computer and use it in GitHub Desktop.
Churnkey vue.js sample template
<template>
<div>
<h1>Click to launch Churnkey</h1>
<!-- show button if user can cancel and loading finished -->
<div>
<button id="ck-cancel" @click="cancelFlow()" v-if="user.canCancel && !isLoading">Cancel</el-button>
</div>
</template>
<script>
import loadChurnKey from '@/helpers/loadChurnKey';
import launchChurnKey from '@/helpers/launchChurnKey';
export default {
name: 'SamplePage',
computed: {
user() {
return this.$store.state.user;
},
canCancel() {
// hide cancel button if user doesn't have an active subscription
return this.user.subscription;
},
},
data() {
return {
isLoading: false,
};
},
methods: {
// click handler for launching churnkey embed
cancelFlow() {
launchChurnKey(this.user);
},
},
mounted() {
const vm = this;
loadChurnKey();
},
};
</script>
<style>
.button {
color: #000;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment