//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);