Validate coupon code for subscriptions fixes #8398 (#8440)

* (fix) If coupon is not valid, display an error

* (test) Add valid and invalid coupon tests for applyCoupon

* Add test descriptions
This commit is contained in:
Cai Lu
2017-01-23 11:01:30 -08:00
committed by Keith Holliday
parent 79c3efaf9c
commit 79b51a40ce
2 changed files with 62 additions and 5 deletions

View File

@@ -269,7 +269,11 @@ habitrpg.controller('SettingsCtrl',
$scope.applyCoupon = function(coupon){
$http.post(ApiUrl.get() + '/api/v3/coupons/validate/'+coupon)
.success(function(){
.success(function(res, code){
if (!res.data.valid) {
Notification.error(env.t('invalidCoupon'), true);
return;
}
Notification.text("Coupon applied!");
var subs = Content.subscriptionBlocks;
subs["basic_6mo"].discount = true;