Added coupon purchasing back to stripe (#9794)

This commit is contained in:
Keith Holliday
2018-01-15 12:12:19 -07:00
committed by GitHub
parent a73b03452a
commit dd95acf436
2 changed files with 7 additions and 11 deletions

View File

@@ -113,9 +113,10 @@ import { mapState } from 'client/libs/store';
import subscriptionBlocks from '../../../common/script/content/subscriptionBlocks'; import subscriptionBlocks from '../../../common/script/content/subscriptionBlocks';
import planGemLimits from '../../../common/script/libs/planGemLimits'; import planGemLimits from '../../../common/script/libs/planGemLimits';
import paymentsMixin from '../../mixins/payments'; import paymentsMixin from '../../mixins/payments';
import notificationsMixin from '../../mixins/notifications';
export default { export default {
mixins: [paymentsMixin], mixins: [paymentsMixin, notificationsMixin],
data () { data () {
return { return {
loading: false, loading: false,
@@ -247,17 +248,12 @@ export default {
}); });
}, },
async applyCoupon (coupon) { 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) { if (!response.data.data.valid) return;
// Notification.error(env.t('invalidCoupon'), true);
return;
}
// Notification.text("Coupon applied!"); this.text('Coupon applied!');
let subs = subscriptionBlocks; this.subscription.key = 'google_6mo';
subs.basic_6mo.discount = true;
subs.google_6mo.discount = false;
}, },
getCancelSubInfo () { getCancelSubInfo () {
let payMethod = this.user.purchased.plan.paymentMethod || ''; let payMethod = this.user.purchased.plan.paymentMethod || '';

View File

@@ -32,7 +32,7 @@ api.checkout = {
let gift = req.query.gift ? JSON.parse(req.query.gift) : undefined; let gift = req.query.gift ? JSON.parse(req.query.gift) : undefined;
let sub = req.query.sub ? shared.content.subscriptionBlocks[req.query.sub] : false; let sub = req.query.sub ? shared.content.subscriptionBlocks[req.query.sub] : false;
let groupId = req.query.groupId; let groupId = req.query.groupId;
let coupon; let coupon = req.query.coupon;
await stripePayments.checkout({token, user, gift, sub, groupId, coupon}); await stripePayments.checkout({token, user, gift, sub, groupId, coupon});