mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Added coupon purchasing back to stripe (#9794)
This commit is contained in:
@@ -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 || '';
|
||||||
|
|||||||
@@ -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});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user