Skip to content

Commit

Permalink
Merge pull request #109 from Kondeo/monthly
Browse files Browse the repository at this point in the history
Monthly Subscription with MemberClicks Discount
  • Loading branch information
julianpoy committed May 27, 2016
2 parents 34cafde + a874fd4 commit c1e1658
Show file tree
Hide file tree
Showing 19 changed files with 593 additions and 137 deletions.
Binary file added E-Compendium-Release-0.1.7.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = function (grunt) {
production: {
constants: {
CONST: {
"apiBase": "https://ccra1.kondeo.com:3000/",
"apiBase": "https://ccracodes.com:3000/",
"stripePK": "pk_live_zgdVMyeOlyq0g7vQuRliqEDE",
"version": "<%= pkg.version %>"
}
Expand All @@ -63,7 +63,7 @@ module.exports = function (grunt) {
default: {
constants: {
CONST: {
"apiBase": "https://ccra1.kondeo.com:3000/",
"apiBase": "https://ccracodes.com:3000/",
"stripePK": "pk_live_zgdVMyeOlyq0g7vQuRliqEDE",
"version": "<%= pkg.version %>"
}
Expand Down
58 changes: 33 additions & 25 deletions app/scripts/controllers/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,36 @@ angular.module('starter')
loadingSpinner.stopLoading();
$scope.setConfig(data)
}, function(error){
//Our custom Error Handler
var handlers = [
{
status: 426,
title: "APPLICATION UNSUPPORTED",
text: "Your application version is no longer supported. There will likely be bugs and crashes. Please update to the newest version in the App Store.",
callback: function(response) {
$scope.setConfig(response.data)
}
},
{
status: 449,
title: "Please Update",
text: "You are running an old version of this app. Please update to the newest version in the App Store, or you may start experiencing bugs.",
callback: function(response) {
$scope.setConfig(response.data)
}
}
]

//Send to the notification handler
Notifications.error(error, handlers);
//Check if alert for versioning has already been sprung
if(sessionStorage.getItem("versionAlerted")){
loadingSpinner.stopLoading();
$scope.setConfig(error.data)
} else {
//Alert the user to their version and mark as alerted
sessionStorage.setItem("versionAlerted", true);
//Our custom Error Handler
var handlers = [
{
status: 426,
title: "APPLICATION UNSUPPORTED",
text: "Your application version is no longer supported. There will likely be bugs and crashes. Please update to the newest version in the App Store.",
callback: function(response) {
$scope.setConfig(response.data)
}
},
{
status: 449,
title: "Please Update",
text: "You are running an old version of this app. Please update to the newest version in the App Store, or you may start experiencing bugs.",
callback: function(response) {
$scope.setConfig(response.data)
}
}
]

//Send to the notification handler
Notifications.error(error, handlers);
}
});

$scope.settings = {};
Expand Down Expand Up @@ -148,9 +156,9 @@ angular.module('starter')

//Alert the user their subscription is Ending
//inform user there subscription is ending
Notifications.show("Subscription Ending Soon!", "Please notice that your subscription shall be ending: " +
moment(subDate.subscription).format("dddd, MMMM Do YYYY") +
". Please visit the menu, and select (Manage Subscription) to extend your subscription.");
// Notifications.show("Subscription Ending Soon!", "Please notice that your subscription shall be ending: " +
// moment(subDate.subscription).format("dddd, MMMM Do YYYY") +
// ". Please visit the menu, and select (Manage Subscription) to extend your subscription.");

//Set the alerted to true
//Save their subscription Date
Expand Down
138 changes: 113 additions & 25 deletions app/scripts/controllers/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ angular.module('starter')
//If our card is validated
$scope.cardValidated = false;

$scope.isMember = false;

//Check if we are logged in,
//If we are then fill the subscription information
$scope.initPage = function() {

loadingSpinner.stopLoading();

if(localStorage.getItem("admin")) {

//inform them of their admin powers
Expand All @@ -45,10 +49,13 @@ angular.module('starter')
};

User.get(payload, function(data) {
$scope.autoPay = data.subscriptionId;

//Stop loading
loadingSpinner.stopLoading();

$scope.isMember = data.memberPrice;

//Auto fill their email for them
$scope.registerData.email = data.email;

Expand All @@ -69,8 +76,7 @@ angular.module('starter')
}

//Lastly, get the price
$scope.price;
$scope.priceText = "Getting Prices...";
$scope.prices;

var payload = {

Expand All @@ -80,28 +86,13 @@ angular.module('starter')
loadingSpinner.startLoading();

Price.get(payload, function(response) {

//Stop loading
loadingSpinner.stopLoading();

//Check if we should get the price of a new user
//or extension
if($scope.loggedIn()) {

//Set the price
$scope.price = response.RENEW;

//Set the text
$scope.priceText = "Extend Subscription for 1 Year - $" + ($scope.price / 100);
}
else {

//Set the price
$scope.price = response.NEW;
//Set the price
$scope.prices = response;

//Set the text
$scope.priceText = "Create Subscription - $" + ($scope.price / 100);
}
//Set the text
$scope.updatePrices();
},
//errors
function(response) {
Expand All @@ -111,7 +102,31 @@ angular.module('starter')
})

}
$scope.initPage();

if(!$scope.loggedIn()){
loadingSpinner.startLoading();
$timeout(function(){
loadingSpinner.stopLoading();
$scope.initPage();
}, 250);
} else {
$scope.initPage();
}


$scope.updatePrices = function(){
if(!$scope.registerData.ccraMember) {
//Set the text
$scope.priceText = "Subscribe - $" + ($scope.prices.STANDARD / 100) + " AutoBilled Monthly";
} else {
//Set the text
$scope.priceText = "Subscribe at Member Price - $" + ($scope.prices.MEMBER / 100) + " AutoBilled Monthly";
}
}

$scope.setMember = function(){
$scope.isMember = $scope.registerData.ccraMember;
}

//Functions for the Form

Expand Down Expand Up @@ -344,6 +359,25 @@ angular.module('starter')
$ionicHistory.goBack();
}

$scope.unsubscribe = function() {
//Start loading
loadingSpinner.startLoading();

User.cancel({
token: localStorage.getItem("session_token")
}, function(){
//Stop loading
loadingSpinner.stopLoading();

//User is no longer subscribed to autopay, so change interface
$scope.autoPay = false;
}, function(){
//Stop loading
loadingSpinner.stopLoading();
Notifications.show("Error!", "Something went wrong. Please reload the app.");
});
}

//Create the user
$scope.registerUser = function() {

Expand Down Expand Up @@ -400,6 +434,11 @@ angular.module('starter')
password: $scope.registerData.password
}

if($scope.registerData.ccraMember){
payload.memberUsername = $scope.registerData.memberUsername;
payload.memberPassword = $scope.registerData.memberPassword;
}

//Submitting Now!
User.register(payload, function(data) {

Expand All @@ -419,14 +458,16 @@ angular.module('starter')
sessionStorage.setItem("weekAlerted", false);
sessionStorage.setItem("monthAlerted", false);

$scope.autoPay = true;

//Move them back to the index, no history
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('app.index');

//Alert them of success!
Notifications.show("Success!", "You have successfully registered! Your account is valid for a year (valid unitl: " + moment(data.subscription).format("MMM Do, YYYY") + "), and can be extended. Enjoy!");
Notifications.show("Success!", "You have successfully registered! Your card will be automatically billed each month to extend your subscription. Enjoy!");

},
//Errors
Expand All @@ -453,6 +494,26 @@ angular.module('starter')
//Display alert, and show card errors
$scope.cardError = true;
}
},
{
status: 424,
title: "Membership Inactive",
text: "The membership for the information you provided is no longer active. Please renew your CCRA membership, or subscribe without membership.",
callback: function() {

//Display alert, and show card errors
$scope.memberError = true;
}
},
{
status: 417,
title: "Membership Username/Password Incorrect",
text: "Please check your membership information.",
callback: function() {

//Display alert, and show card errors
$scope.memberError = true;
}
}
]

Expand Down Expand Up @@ -511,8 +572,13 @@ angular.module('starter')
password: $scope.registerData.password
}

if($scope.registerData.ccraMember){
payload.memberUsername = $scope.registerData.memberUsername;
payload.memberPassword = $scope.registerData.memberPassword;
}

//Submitting Now!
User.renew(payload, function(data) {
User.resub(payload, function(data) {

//Stop loading
loadingSpinner.stopLoading();
Expand All @@ -529,14 +595,16 @@ angular.module('starter')
sessionStorage.setItem("weekAlerted", false);
sessionStorage.setItem("monthAlerted", false);

$scope.autoPay = true;

//Move them back to the index, no history
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go('app.index');

//Alert them of success!
Notifications.show("Success!", "You have successfully registered! Your account is valid for a year (valid unitl: " + moment(data.subscription).format("MMM Do, YYYY") + "), and can be extended. Enjoy!");
Notifications.show("Success!", "You have successfully registered! Your card will be automatically billed each month to extend your subscription. Enjoy!");

},
//Errors
Expand Down Expand Up @@ -564,6 +632,26 @@ angular.module('starter')
//Display alert, and show card errors
$scope.cardError = true;
}
},
{
status: 424,
title: "Membership Inactive",
text: "The membership for the information you provided is no longer active. Please renew your CCRA membership, or subscribe without membership.",
callback: function() {

//Display alert, and show card errors
$scope.memberError = true;
}
},
{
status: 417,
title: "Membership Username/Password Incorrect",
text: "Please check your membership information.",
callback: function() {

//Display alert, and show card errors
$scope.memberError = true;
}
}
];

Expand Down
12 changes: 9 additions & 3 deletions app/scripts/services/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,16 @@ angular.module('starter')
isArray: false
},

renew: {
resub: {
method: 'POST',
params: { Id: 'renew' },
isArray: false
isArray: false,
url: CONST.apiBase + 'users/sub/add'
},

cancel: {
method: 'POST',
isArray: false,
url: CONST.apiBase + 'users/sub/cancel'
},

get: {
Expand Down
14 changes: 14 additions & 0 deletions app/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,17 @@ $dark: #444 !default;
text-align: center;
}
}

.center {
text-align: center;
}
.hint {
font-size: 12px !important;
}
.ccraMembership{
margin-left: 40px;
}
.button-subscribe{
word-wrap: break-word;
white-space: normal;
}
Loading

0 comments on commit c1e1658

Please sign in to comment.