From dd95acf4367ad6c79cbfb40661cedb84ad88df37 Mon Sep 17 00:00:00 2001 From: Keith Holliday Date: Mon, 15 Jan 2018 12:12:19 -0700 Subject: [PATCH] Added coupon purchasing back to stripe (#9794) --- .../client/components/settings/subscription.vue | 16 ++++++---------- .../controllers/top-level/payments/stripe.js | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/website/client/components/settings/subscription.vue b/website/client/components/settings/subscription.vue index 07ad6e1b97..e086f99f59 100644 --- a/website/client/components/settings/subscription.vue +++ b/website/client/components/settings/subscription.vue @@ -113,9 +113,10 @@ import { mapState } from 'client/libs/store'; import subscriptionBlocks from '../../../common/script/content/subscriptionBlocks'; import planGemLimits from '../../../common/script/libs/planGemLimits'; import paymentsMixin from '../../mixins/payments'; +import notificationsMixin from '../../mixins/notifications'; export default { - mixins: [paymentsMixin], + mixins: [paymentsMixin, notificationsMixin], data () { return { loading: false, @@ -247,17 +248,12 @@ export default { }); }, async applyCoupon (coupon) { - let response = await axios.get(`/api/v3/coupons/validate/${coupon}`); + const response = await axios.post(`/api/v3/coupons/validate/${coupon}`); - if (!response.data.valid) { - // Notification.error(env.t('invalidCoupon'), true); - return; - } + if (!response.data.data.valid) return; - // Notification.text("Coupon applied!"); - let subs = subscriptionBlocks; - subs.basic_6mo.discount = true; - subs.google_6mo.discount = false; + this.text('Coupon applied!'); + this.subscription.key = 'google_6mo'; }, getCancelSubInfo () { let payMethod = this.user.purchased.plan.paymentMethod || ''; diff --git a/website/server/controllers/top-level/payments/stripe.js b/website/server/controllers/top-level/payments/stripe.js index b684b20c91..5794e87314 100644 --- a/website/server/controllers/top-level/payments/stripe.js +++ b/website/server/controllers/top-level/payments/stripe.js @@ -32,7 +32,7 @@ api.checkout = { let gift = req.query.gift ? JSON.parse(req.query.gift) : undefined; let sub = req.query.sub ? shared.content.subscriptionBlocks[req.query.sub] : false; let groupId = req.query.groupId; - let coupon; + let coupon = req.query.coupon; await stripePayments.checkout({token, user, gift, sub, groupId, coupon});