UNPKG

unserver-unify

Version:

41 lines (40 loc) 1.34 kB
'use strict'; angular.module('bamboo.setting').controller('PricingCtrl', function(ApiService, CommonService,$location,$window, loginService) { var self = this; this.pricingRecords = {}; self.currency = (loginService.school.currency && loginService.school.currency.sign) ? loginService.school.currency.sign : '$'; function getAllPlans() { var info = { limit: 4, action: 'getEnabledUserPlans', sort: { predicate: "price", reverse: false } }; ApiService.post("/transaction", info).then(function(result) { console.log(result); if (result.data.success) { self.planRecords = result.data.data.items; } else { CommonService.showError("Failed: " + result.data.message); } }); } getAllPlans(); this.buyPlan = function(id) { var info = { action: 'paypalBuyUserPlan', id: id, url: $location.absUrl(), }; ApiService.post("/payment", info).then(function(result) { if (result.data.success && result.data.data.redirectUrl) { CommonService.showInfo('Redirect to Payment Page , Please wait ...'); $window.location.href = result.data.data.redirectUrl; } else { CommonService.showError("Failed: " + result.data.message); } }); } });