Examples of BillingDataAccessService


Examples of org.wso2.carbon.billing.mgt.services.BillingDataAccessService

        subscription.setItem(item);
        String planName=tenantBean.getUsagePlan();
        subscription.setSubscriptionPlan(planName);
        int subscriptionId = 0;
        try {
            BillingDataAccessService dataAccessService = new BillingDataAccessService();
            subscriptionId = dataAccessService.addSubscription(subscription);
        } catch (Exception e) {
            log.error("Could not add new subscription for tenant: " +
                    tenantBean.getTenantDomain() + " " + e.getMessage(), e);
            return false;
        }
View Full Code Here

Examples of org.wso2.carbon.billing.mgt.services.BillingDataAccessService

    }

    public static Subscription getActiveUsagePlan(int tenantId) throws Exception {
        Subscription subscription;
        try{
            BillingDataAccessService billingDataAccessService = new BillingDataAccessService();
            subscription = billingDataAccessService.getActiveSubscriptionOfCustomer(tenantId);
        }catch (Exception e){
            String msg = "Error occurred while getting the usage plan for tenant: " + tenantId + " " + e.getMessage();
            log.error(msg);
            throw new Exception(msg, e);
        }
View Full Code Here

Examples of org.wso2.carbon.billing.mgt.services.BillingDataAccessService

    }

    public static void updateUsagePlan(TenantInfoBean infoBean) throws Exception{
        String usagePlan = infoBean.getUsagePlan();
        try{
            BillingDataAccessService billingDataAccessService = new BillingDataAccessService();
            Subscription currentSubscription = billingDataAccessService.getActiveSubscriptionOfCustomer(infoBean.getTenantId());
            if(currentSubscription != null && currentSubscription.getSubscriptionPlan() != null){
                if(!currentSubscription.getSubscriptionPlan().equals(usagePlan)){
                    boolean updated = billingDataAccessService.changeSubscription(infoBean.getTenantId(), usagePlan);
                    if(updated){
                        log.debug("Usage plan was changed successfully from " + currentSubscription.getSubscriptionPlan() +
                                " to " + usagePlan);
                    }else{
                        log.debug("Usage plan was not changed");
View Full Code Here

Examples of org.wso2.carbon.billing.mgt.services.BillingDataAccessService

    }

    public static void activateUsagePlan(int tenantId) throws Exception {
        try{
            BillingDataAccessService dataAccessService = new BillingDataAccessService();
            Subscription subscription = dataAccessService.getActiveSubscriptionOfCustomer(tenantId);
            if(subscription!=null){
                String msg = "Cant activate subscription for tenant: " + tenantId +
                            ". An active subscription already exists";
                log.info(msg);
            }else{
                Subscription[] inactiveSubscriptions = dataAccessService.getInactiveSubscriptionsOfCustomer(tenantId);
                if(inactiveSubscriptions.length>0){
                    //I am doing this assuming that there wont be more than one subscription for a tenant
                    //at the time of activation. Logically it cant be.
                    subscription = inactiveSubscriptions[0];
                    boolean activated = dataAccessService.activateSubscription(subscription.getId());
                    if(activated){
                        log.debug("Subscription was activated for tenant: " + tenantId);
                    }
                }
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.