私は休憩アーキテクチャでスプリングブートを使用します。 私はエラー管理の初心者です。支払いにエラーがある場合はエラー管理
私のコードは
@Transactional
@Override
public void processPayment() throws CreditCardPaymentException{
List<Payment> payments = paymentRepository.findByDateLessThanEqualAndPaymentModeAndStatus(LocalDate.now(), PaymentModeEnum.CREDITCARD, StatusEnum.STANDBY);
processCreditCardPayment(payments);
}
private void processCreditCardPayment(List<Payment> payments) throws ProcessPaymentException{
PaymentGatewayConfig paymentGateway = new PaymentGatewayConfig();
String crypt_type = "7";
for (Payment payment : payments) {
chargeMemberCreditCard(payment, crypt_type, paymentGateway);
}
}
private ResolverReceipt chargeMemberCreditCard(Payment payment, String crypt_type, PaymentGatewayConfig paymentGateway) throws ProcessPaymentException {
try {
if (resreceipt != null) {
//information about customer we have sent are returned
ResolveData resdata = resreceipt.getResolveData();
//todo check auth code
if (Boolean.valueOf(resreceipt.getComplete()) && !Boolean.valueOf(resreceipt.getTimedOut())) {
//if (resreceipt != null && resreceipt.getResponseCode() != null && Integer.getInteger(resreceipt.getResponseCode()) < 50) {
payment.setStatus(StatusEnum.COMPLETE);
} else {
payment.setStatus(StatusEnum.FAIL);
}
}
} catch (Exception e) {
throw new ProcessPaymentException();
log.error("chargeMemberCreditCard - payment: " + payment.getPaymentId(), e);
}
}
このような構造を持って、私は次のいずれかに渡したいです。 最後に多くのエラーがある場合は、発生したエラーがあることを知りたいだけです。
もしこのコードがそれを行うなら、それが行く方法なのかどうかは分かりません。
のtry/catchで
Payments
またはExceptions
を失敗し蓄積しますか? –