Package org.jayasoft.woj.portal.model

Examples of org.jayasoft.woj.portal.model.Order


        String orderId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_ORDER_ID);
        String buyerId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.BUYER_ID);
        if (orderId != null) {
            LOGGER.debug("Editing mode for orderId = "+orderId);
            // Editing mode
            Order order = Portal.getInstance().getPricingService().getOrder(orderId);
            f.set(Params.REGISTER.PRODUCT.VALIDATE.PARAMS.LICENSE_TYPE, Params.REGISTER.PRODUCT.LICENSES.COMMERCIAL_LICENSE);
            f.set("selectedProduct", order.getPrice().getProduct().getCode());
            f.set("selectedUser", new Integer(order.getSubscribedUsers()));
            f.set("selectedYear", new Integer(order.getSubscribedYears()));
        } else {
            // Creating mode
            // TODO set default license to commercial one
            if (buyerId != null) {
                LOGGER.debug("Creating mode buyerId = "+buyerId);
View Full Code Here


                            ServiceFactory.getUserService().update(modifiedUser);
                        }
                       
                        // Handle Order
                        String orderId = (String)request.getSession().getAttribute(Params.REGISTER.SESSION.CURRENT_ORDER_ID);
                        Order baseOrder = null;
                        if (orderId == null) {
                            // Creating mode
                            LOGGER.debug("Creating new order for user"+modifiedUser);
                            baseOrder = Portal.getInstance().getPricingService().newOrder(modifiedUser, r.getPurchaser(), product, users.intValue(), years.intValue());
                            request.getSession().setAttribute(Params.REGISTER.SESSION.CURRENT_ORDER_ID, String.valueOf(baseOrder.getId()));        
                        } else {
                            // Modifying mode
                            baseOrder = Portal.getInstance().getPricingService().getOrder(orderId);
                            LOGGER.debug("Updating order "+baseOrder);
                            baseOrder = Portal.getInstance().getPricingService().updateOrder(baseOrder, modifiedUser, r.getPurchaser(), product, users.intValue(), years.intValue());
View Full Code Here

    }
   
    public static void main(String[] args) {
        LoggingManager.initSimpleLoggingManagement();
        InvoiceBuilder builder = ItextPDFInvoiceBuilder.instance();
        Order o = new Order();
        o.setTotalCost(50.0d);
        Invoice i = new Invoice();
        PaymentInfo pi = new PaymentInfo();
        License l = new License();
        Price p = new Price();
        p.setPriceByYear(50);
        l.setPrice(p);
        pi.setLicenses(Collections.singleton(l));
        o.setPayments(Collections.singleton(pi));
        o.setInvoice(i);
        Purchaser pur = getPurchaser();
        if (builder.buildInvoicePDF(o, pur, "inv-" + System.currentTimeMillis()) != null) {
            LOGGER.debug("pdf done");
        } else {
            LOGGER.debug("creation of pdf failed");
View Full Code Here

    return _df.format(num);
  }
 
  public Order newOrder(UserImpl buyer, Purchaser p, String productCode, int users, int years) {
        LOGGER.info(MessageFormat.format("registring order buyer[{0}]\\n purchaser:{1}\\nprod:{2} users:{3} years:{4}", new Object[]{buyer.getLogin(), p, productCode, new Integer(users), new Integer(years)}));
    Order order = (Order)DaoFactory.getOrderDao().newHandledObject();
      privateUpdate(buyer, p, productCode, users, years, order);
       
    try {
            DaoFactory.getPurchaserDao().save(p);
      DaoFactory.getOrderDao().save(order);
View Full Code Here

      String bankResponseCode = resp.getValue("response_code");
      LOGGER.debug("bankResponseCode ="+bankResponseCode);
      String transactionId = resp.getValue("transaction_id");
      LOGGER.debug("transactionId ="+transactionId);
     
      Order pendingOrder = Portal.getInstance().getPricingService().getOrder(Long.valueOf(orderId));
      LOGGER.debug("pendingOrder ="+pendingOrder);
      //payment authorized
      if(pendingOrder != null) {
                LOGGER.info("order:" + pendingOrder.getId() + "found for this payment");
        PaymentInfo paymentInfo = Portal.getInstance().getPricingService().getPayment(pendingOrder);
        LOGGER.debug("paymentInfo ="+paymentInfo);
        //verify that payment is not yet registered
        if(paymentInfo == null) {
          //send email confirmation
          if(!pendingOrder.getBuyer().isMailVerified()) {
            ServiceFactory.getRegistrationService().sendEmailVerification(pendingOrder.getBuyer());
          }
                    //store payment info
                    LOGGER.info("creating payment info...");
                    paymentInfo = Portal.getInstance().getPricingService().newPaymentInfo(pendingOrder, transactionId, authorisationId, bankResponseCode);
          if(PricingService.RESPONSE_OK.equals(bankResponseCode)) {
                        //create license
                        pendingOrder.setStatus(Order.ORDER_PAYED);
                        LOGGER.info("order " + pendingOrder.getId() + " payed...");
                        DaoFactory.getOrderDao().save(pendingOrder);
                       
            LOGGER.info("creating licence...");
            List lic = ServiceFactory.getLicenseService().addLicense(pendingOrder);
                        UserImpl buyer = pendingOrder.getBuyer();
                       
                       
                        // We modify user for fidelity
                        Product p = pendingOrder.getPrice().getProduct();
                        int years = pendingOrder.getSubscribedYears();
                        FidelityService fs = ServiceFactory.getFidelityService();
                        fs.buy(buyer, p, years, pendingOrder.getSubscribedUsers());
                       
                        LOGGER.info("creating invoice...");
                        Invoice invoice = ServiceFactory.getCommercialService().createInvoice(pendingOrder, pendingOrder.getPurchaser());
            ServiceFactory.getRegistrationService().sendLicenseBuyConfirmationMail(pendingOrder.getBuyer(), pendingOrder, lic, invoice);
                        LOGGER.info("payment created");
            return paymentInfo;
          } else  {
                        // TODO g�rer annulation ou refus de paiement
                        pendingOrder.setStatus(Order.ORDER_PAYMENT_REFUSED);
                        LOGGER.info("order " + pendingOrder.getId() + " payment refused, code : " + bankResponseCode);
                        DaoFactory.getOrderDao().save(pendingOrder);
            LOGGER.warn("Payment refused by bank return code:"+bankResponseCode);
                        PaymentRefusedException e = new PaymentRefusedException(bankResponseCode);
                        e.appendError(RessourceBundleApplicationMessage.error("registration.payment-form.error." + bankResponseCode, null));
            throw e;
          }
        } else {
            LOGGER.info("payment already done for order " + pendingOrder.getId());
                }
        return paymentInfo;
      } else  {
        throw ServiceException.create("Internal error", "No order found withid="+orderId+" defined in transaction id="+transactionId, null);
      }
View Full Code Here

    /* (non-Javadoc)
     * @see org.jayasoft.woj.portal.data.dao.hibernate.DefaultHibernateWOJDao#newHandledObject()
     */
    public WOJObject newHandledObject() {
    return new Order();
  }
View Full Code Here

        getHelper().doRemove(o);
    }

    public void fetch(WOJObject o) throws DaoException {
        if (o instanceof Order) {
            final Order order = (Order)o;
            HibernateTemplate t = new HibernateTemplate(getSessionFactory());
            t.execute(
                    new HibernateCallback() {
                        public Object doInHibernate(Session s) throws HibernateException, SQLException {
                            s.lock(order, LockMode.NONE);
                            if(order.getSuccessPayment() != null) {
                              order.getSuccessPayment().getTransactionId();
                            }
                            return null;
                        }
                    }
            );
View Full Code Here

TOP

Related Classes of org.jayasoft.woj.portal.model.Order

Copyright © 2018 www.massapicom. 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.