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 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 || '';
|
||||
|
||||
@@ -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});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user