From f0ed427c6ce5a34e5f10f710b977969d06776ebf Mon Sep 17 00:00:00 2001 From: DispatchCommit Date: Sun, 24 May 2020 16:39:46 -0700 Subject: [PATCH] v1.19.0 - Add payment processing for chat alerts --- components/Chat/ChatInput.vue | 4 +- components/Chat/ChatMessages/index.vue | 3 +- components/Payment/ChatCoin.vue | 240 ++++++++++++++++++------- components/Payment/Checkout.vue | 34 +++- components/Payment/v-braintree.vue | 7 +- package.json | 2 +- store/index.js | 11 +- 7 files changed, 215 insertions(+), 86 deletions(-) diff --git a/components/Chat/ChatInput.vue b/components/Chat/ChatInput.vue index 481a8a69..8595cbba 100644 --- a/components/Chat/ChatInput.vue +++ b/components/Chat/ChatInput.vue @@ -46,10 +46,10 @@ {{ msg.message }} diff --git a/components/Payment/ChatCoin.vue b/components/Payment/ChatCoin.vue index 483f205c..bb7767ce 100644 --- a/components/Payment/ChatCoin.vue +++ b/components/Payment/ChatCoin.vue @@ -6,10 +6,10 @@ color="primary" class="d-flex align-center justify-space-between pl-2" > -
+

local_atm Coin Store -

+ - + - 500 Coin - $5 - + - + + + ${{ this.amount }} - Buy 100 Coins + - - - - - - - Buy Coins - - - - - - - + Blue Alert 09 + + + Grey Alert 07 + + + + + + + +

+ warning + Create {{ alertColor.toUpperCase() }} Chat Alert +

+ + close + +
+ +
+ + +
+
Hello Senator
+ + Create + Cancel +
+
+
+
+ @@ -107,12 +192,16 @@ data () { return { showPurchasePopup: false, + redeemAlertPopup: false, token: 'production_ndjvk9d7_4q2xfsbyxjmm8brs', server: 'https://api.bitwave.tv', - endpoint: 'v1/payments/checkout', + endpoint: 'api/payment/coins/checkout', amount: null, productId: null, + + alertColor: 'grey', + alertMessage: '', }; }, @@ -126,15 +215,42 @@ this.amount = amount; this.showPurchasePopup = true; }, + + openRedeemMenu ( color ) { + this.redeemAlertPopup = true; + this.alertColor = color; + }, + + async createAlert () { + try { + await this.$axios.post( + 'https://api.bitwave.tv/api/store/alerts/checkout', + { + username: this.user.username, + uid: this.user.uid, + color: this.alertColor, + message: this.alertMessage, + } + ); + this.redeemAlertPopup = false; + this.alertMessage = ''; + this.close(); + } catch ( error ) { + console.error( error.message ); + this.$toast.error( error.message, { duration: 2500, icon: 'error', position: 'top-center' } ); + } + }, }, computed: { ...mapGetters({ - getBalance: VStore.$getters.getBalance, + isAuth : VStore.$getters.isAuth, + user : VStore.$getters.getUser, + getCoins : VStore.$getters.getCoins, }), - balance () { - return this.getBalance > 1000 ? `${(this.getBalance / 1000).toFixed( 1 )}k` : this.getBalance; + coins () { + return this.getCoins > 1000 ? `${(this.getCoins / 1000).toFixed( 1 )}k` : this.getCoins; }, url () { @@ -143,7 +259,3 @@ }, }; - - diff --git a/components/Payment/Checkout.vue b/components/Payment/Checkout.vue index ec747344..4616ff8c 100644 --- a/components/Payment/Checkout.vue +++ b/components/Payment/Checkout.vue @@ -1,7 +1,12 @@