Skip to content

Instantly share code, notes, and snippets.

@vixtory09678
Created September 15, 2020 16:20
Show Gist options
  • Save vixtory09678/10e9810ab31264b387b3d4153a077c37 to your computer and use it in GitHub Desktop.
Save vixtory09678/10e9810ab31264b387b3d4153a077c37 to your computer and use it in GitHub Desktop.
<template>
<div id="app">
<form id="checkoutForm">
<input type="submit" @click="pay" id="checkout-button" value="pay" />
</form>
</div>
</template>
<script>
import axios from 'axios'
export default {
name: 'App',
mounted () {
OmiseCard.configure({
publicKey: 'pkey_test_5l7ms2pcwcyxr5t1avv'
})
},
methods : {
pay () {
OmiseCard.open({
submitFormTarget: '#checkoutForm',
amount: 10000,
currency: 'THB',
buttonLabel: 'Pay',
onCreateTokenSuccess: (nonce) => {
console.log(nonce)
axios.post
this.$axios.post('https://api.omise.co/charges', {
amount: '10000',
currency: 'thb',
card: nonce
}, {
headers: {
},
auth: {
username: 'skey_test_5l7ms2pd5o799n76fot'
}
})
.then(res => {
console.log(res.data)
})
.catch(err => {
console.log(err.message)
})
},
onFormClosed: () => {
console.log('close')
},
})
OmiseCard.attach()
}
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment