Package com.music.model.persistent

Examples of com.music.model.persistent.Purchase


        //paymentContext = new PaymillContext(secret);
    }

    @Transactional
    public void checkout(Cart cart, Long userId, String email, String purchaseToken) {
        Purchase purchase = new Purchase();
        purchase.setPurchaseTime(new DateTime());
        purchase.setPaymentType(PaymentType.CREDITCARD);
        if (userId != null) {
            purchase.setUser(dao.getById(User.class, userId));
            purchase.setEmail(purchase.getUser().getEmail());
        } else {
            purchase.setEmail(email);
        }
        if (!cart.getPieceIds().isEmpty()) {
            purchase.setPieces(new HashSet<>(dao.getByIds(Piece.class, cart.getPieceIds())));
        }
        if (!cart.getPiecePackIds().isEmpty()) {
            purchase.setPacks(new HashSet<>(dao.getByIds(PiecePack.class, cart.getPiecePackIds())));
        }

        dao.persist(purchase);

//        Payment payment = paymentContext.getPaymentService().createWithToken(purchaseToken);
View Full Code Here


                + cart.getPiecePackIds().size() * 100 * 5);
    }

    @Transactional
    public void paymentComplete(String paymentProviderId) {
        Purchase purchase = dao.getByPropertyValue(Purchase.class, "paymentProviderId", paymentProviderId);
        // if no purchase found, or purchase already complete, ignore
        if (purchase == null || purchase.isComplete()) {
            return;
        }
        purchase.setComplete(true);
        dao.persist(purchase);
        sendPurchaseEmail(purchase);
    }
View Full Code Here

        emailService.send(emailDetails);
    }

    @Transactional(readOnly=true)
    public void download(long id, OutputStream out) throws IOException {
        Purchase purchase = dao.getById(Purchase.class, id);
        if (!purchase.isComplete()) {
            return;
        }

        pieceService.downloadPieces(out, purchase.getPieces());
    }
View Full Code Here

        }
    }

    @Transactional
    public long bitcoinCheckout(ArrayList<Long> ids, Long userId, String email) {
        Purchase purchase = new Purchase();
        purchase.setPaymentType(PaymentType.BITCOIN);
        purchase.setPurchaseTime(new DateTime());
        if (userId != null) {
            purchase.setUser(dao.getById(User.class, userId));
            purchase.setEmail(purchase.getUser().getEmail());
        } else {
            purchase.setEmail(email);
        }
        purchase.setPieces(new HashSet<>(dao.getByIds(Piece.class, ids)));

        return dao.persist(purchase).getId();
    }
View Full Code Here

        return dao.persist(purchase).getId();
    }

    @Transactional
    public void bitcoinPaymentComplete(String paymentId, Long purchaseId) {
        Purchase purchase = dao.getById(Purchase.class, purchaseId);
        // if no purchase found, or purchase already complete, ignore
        if (purchase == null || purchase.isComplete()) {
            return;
        }
        purchase.setPaymentProviderId(paymentId);
        purchase.setComplete(true);
        dao.persist(purchase);

        sendPurchaseEmail(purchase);
    }
View Full Code Here

TOP

Related Classes of com.music.model.persistent.Purchase

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.