- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 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 "";
}