@Override protected JSONStreamAware processRequest(HttpServletRequest req) throws NxtException { DigitalGoodsStore.Goods goods = ParameterParser.getGoods(req); if (goods.isDelisted()) { return UNKNOWN_GOODS; } int quantity = ParameterParser.getGoodsQuantity(req); if (quantity > goods.getQuantity()) { return INCORRECT_PURCHASE_QUANTITY; } long priceNQT = ParameterParser.getPriceNQT(req); if (priceNQT != goods.getPriceNQT()) { return INCORRECT_PURCHASE_PRICE; } String deliveryDeadlineString = Convert.emptyToNull(req.getParameter("deliveryDeadlineTimestamp")); if (deliveryDeadlineString == null) { return MISSING_DELIVERY_DEADLINE_TIMESTAMP; } int deliveryDeadline; try { deliveryDeadline = Integer.parseInt(deliveryDeadlineString); if (deliveryDeadline <= Nxt.getEpochTime()) { return INCORRECT_DELIVERY_DEADLINE_TIMESTAMP; } } catch (NumberFormatException e) { return INCORRECT_DELIVERY_DEADLINE_TIMESTAMP; } Account buyerAccount = ParameterParser.getSenderAccount(req); Account sellerAccount = Account.getAccount(goods.getSellerId()); Attachment attachment = new Attachment.DigitalGoodsPurchase(goods.getId(), quantity, priceNQT, deliveryDeadline); try { return createTransaction(req, buyerAccount, sellerAccount.getId(), 0, attachment); } catch (NxtException.InsufficientBalanceException e) { return JSONResponses.NOT_ENOUGH_FUNDS; } }