1. Java / Говнокод #18099

    +141

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    34. 34
    @ResponseBody
    public String paymentFeedback(@RequestBody MultiValueMap<String, String> requestParameters, @RequestBody String requestBody) {
        boolean isValidRequest = myService.hasRequestValidSHASign(requestParameters);
        if (isValidRequest) {
            String voucherNumber = findParameter(requestParameters, ORDERID_PARAMETER);
            if (!StringUtils.isEmpty(voucherNumber)) {
                Order order = orderService.getOrderByVoucherNumber(voucherNumber);
                if (order != null) {
                    String status = findParameter(requestParameters, STATUS_PARAMETER);
                    if (ACCEPT_STATUS_VALUES.contains(status)) {
                        updateOrderWithPaymentStatus(order, Status.PAID, requestParameters);
                        orderService.sendEmail(order);
                        orderService.sell(order);
                    } else if (CANCELLED_STATUS_VALUE.equals(status)) {
                        updateOrderWithPaymentStatus(order, Status.CANCELLED, requestParameters);
                    } else if (DECLINE_STATUS_VALUES.contains(status)) {
                        updateOrderWithPaymentStatus(order, Status.DECLINED, requestParameters);
                    } else if (EXCEPTION_STATUS_VALUES.contains(status)) {
                        updateOrderWithPaymentStatus(order, Status.EXCEPTION, requestParameters);
                    } else {
                        logger.warn("Order ID={} got strange status: {}. Ignoring that feedback...", voucherNumber, status);
                    }
                } else {
                    throw new IllegalArgumentException("Can't find voucher with orderID from feedback: " + voucherNumber);
                }
            } else {
                throw new IllegalArgumentException("Received feedback with missing orderID: " + requestBody);
            }
        } else {
            throw new IllegalArgumentException("Received feedback with invalid SHA sign: " + requestBody);
        }
        
        return "";
    }

    Запостил: pingw33n, 30 Апреля 2015

    Комментарии (1) RSS

    • Почему на другие статусы "contains" и только на cancelled - "equals"?
      Кто-то недополучил люлей?
      Ответить

    Добавить комментарий