|
@@ -1,5 +1,5 @@ |
|
|
<template> |
|
|
<template> |
|
|
<section class="select-credits"> |
|
|
|
|
|
|
|
|
<section v-if="!complete" class="select-credits"> |
|
|
<div class="credits-pane"><h2>10 Credits</h2> |
|
|
<div class="credits-pane"><h2>10 Credits</h2> |
|
|
<h3>$10.99</h3><div><span>Qty</span><input min="0" max="1000" v-model="packs.credits10" type="number"></div> |
|
|
<h3>$10.99</h3><div><span>Qty</span><input min="0" max="1000" v-model="packs.credits10" type="number"></div> |
|
|
</div> |
|
|
</div> |
|
@@ -19,7 +19,7 @@ |
|
|
<div id="credits-errors"></div> |
|
|
<div id="credits-errors"></div> |
|
|
</section> |
|
|
</section> |
|
|
|
|
|
|
|
|
<section id="payment-section"> |
|
|
|
|
|
|
|
|
<section v-if="!complete" id="payment-section"> |
|
|
<h4>Select a payment method</h4> |
|
|
<h4>Select a payment method</h4> |
|
|
|
|
|
|
|
|
<div class="sliding-menu"> |
|
|
<div class="sliding-menu"> |
|
@@ -39,16 +39,19 @@ |
|
|
<div id="payment-error"></div> |
|
|
<div id="payment-error"></div> |
|
|
</section> |
|
|
</section> |
|
|
|
|
|
|
|
|
<section class="credits-confirm"> |
|
|
|
|
|
|
|
|
<section v-if="!complete" class="credits-confirm"> |
|
|
<button @click="pay" :disabled="!ready" |
|
|
<button @click="pay" :disabled="!ready" |
|
|
class="brand-btn">Buy<loading v-if="loading"></loading></button> |
|
|
class="brand-btn">Buy<loading v-if="loading"></loading></button> |
|
|
</section> |
|
|
</section> |
|
|
|
|
|
|
|
|
|
|
|
<PurchaseCompleted v-if="complete"></PurchaseCompleted> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import Loading from '../icons/loading.vue' |
|
|
import Loading from '../icons/loading.vue' |
|
|
import PaymentCard from './payment-card.vue' |
|
|
import PaymentCard from './payment-card.vue' |
|
|
import SavedCards from './saved-cards.vue' |
|
|
import SavedCards from './saved-cards.vue' |
|
|
|
|
|
import PurchaseCompleted from './purchase-completed.vue' |
|
|
|
|
|
|
|
|
function total() { |
|
|
function total() { |
|
|
return this.packs.credits10*10.99 + this.packs.credits50*54.99 |
|
|
return this.packs.credits10*10.99 + this.packs.credits50*54.99 |
|
@@ -104,7 +107,8 @@ function pay() { |
|
|
document.getElementById('payment-error').textContent = |
|
|
document.getElementById('payment-error').textContent = |
|
|
result.error.message |
|
|
result.error.message |
|
|
} else if (result.paymentIntent.status === 'succeeded') { |
|
|
} else if (result.paymentIntent.status === 'succeeded') { |
|
|
this.$emit('purchaseComplete') |
|
|
|
|
|
|
|
|
setTimeout(() => {this.$emit('purchaseComplete')}, 4000) |
|
|
|
|
|
this.complete = true |
|
|
} else { |
|
|
} else { |
|
|
document.getElementById('payment-error').textContent = |
|
|
document.getElementById('payment-error').textContent = |
|
|
'An unknown error occured' |
|
|
'An unknown error occured' |
|
@@ -133,13 +137,13 @@ function ready() { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
components:{Loading, PaymentCard, SavedCards}, |
|
|
|
|
|
|
|
|
components:{Loading, PaymentCard, SavedCards, PurchaseCompleted}, |
|
|
data() { |
|
|
data() { |
|
|
return {packs: {credits10: 0, credits50: 0, |
|
|
return {packs: {credits10: 0, credits50: 0, |
|
|
credits100: 0, credits1000: 0}, loading: false, stripe: |
|
|
credits100: 0, credits1000: 0}, loading: false, stripe: |
|
|
window.Stripe(process.env.VUE_APP_STRIPE_KEY), card: |
|
|
window.Stripe(process.env.VUE_APP_STRIPE_KEY), card: |
|
|
null, billingName: null, selectSaved: true, cardValid: false, cards: |
|
|
null, billingName: null, selectSaved: true, cardValid: false, cards: |
|
|
null, picked: null |
|
|
|
|
|
|
|
|
null, picked: null, complete: false |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
computed: {total, ready}, |
|
|
computed: {total, ready}, |
|
|