use of com.forgerock.openbanking.common.model.openbanking.persistence.account.Account in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDueScheduledPaymentTask method moveDebitPayment.
private String moveDebitPayment(FRScheduledPayment payment) throws CurrencyConverterException {
Account accountFrom = accountStoreService.getAccount(payment.getAccountId());
log.info("We are going to pay from this account: {}", accountFrom);
moneyService.moveMoney(accountFrom, payment.getScheduledPayment().getInstructedAmount(), FRCreditDebitIndicator.DEBIT, payment, this::createTransaction);
String identificationFrom = payment.getScheduledPayment().getCreditorAccount().getIdentification();
log.debug("Find if the 'to' account '{}' is own by this ASPSP", identificationFrom);
return identificationFrom;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.Account in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDueStandingOrderTask method moveDebitPayment.
private void moveDebitPayment(FRStandingOrder payment, FRAmount amount) throws CurrencyConverterException {
Account accountTo = accountStoreService.getAccount(payment.getAccountId());
log.info("We are going to pay from this account: {}", accountTo);
moneyService.moveMoney(accountTo, amount, FRCreditDebitIndicator.DEBIT, payment, this::createTransaction);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.Account in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptInternationalPaymentTask method moveDebitPayment.
private String moveDebitPayment(FRInternationalConsent payment) throws CurrencyConverterException {
Account accountFrom = accountStoreService.getAccount(payment.getAccountId());
log.info("We are going to pay from this account: {}", accountFrom);
moneyService.moveMoney(accountFrom, payment.getInitiation().getInstructedAmount(), FRCreditDebitIndicator.DEBIT, payment, this::createTransaction);
String identificationFrom = payment.getInitiation().getCreditorAccount().getIdentification();
log.debug("Find if the 'to' account '{}' is own by this ASPSP", identificationFrom);
return identificationFrom;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.Account in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptInternationalPaymentTask method autoAcceptPayment.
@Scheduled(fixedRate = 60 * 1000)
@SchedulerLock(name = "internationalPayment")
public void autoAcceptPayment() {
log.info("Auto-accept payment task waking up. The time is now {}.", format.print(DateTime.now()));
Collection<FRInternationalConsent> allPaymentsInProcess = internationalPaymentService.getAllPaymentsInProcess();
for (FRInternationalConsent payment : allPaymentsInProcess) {
log.info("Processing payment {}", payment);
try {
String identificationTo = moveDebitPayment(payment);
Optional<Account> isAccountToFromOurs = accountStoreService.findAccountByIdentification(identificationTo);
if (isAccountToFromOurs.isPresent()) {
moveCreditPayment(payment, identificationTo, isAccountToFromOurs.get());
} else {
log.info("Account '{}' not ours", identificationTo);
}
log.info("Update payment status to completed");
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
log.info("Payment {}", payment);
} catch (CurrencyConverterException e) {
log.info("Can't convert amount in the right currency", e);
log.info("Update payment status to rejected");
payment.setStatus(ConsentStatusCode.REJECTED);
log.info("Payment {}", payment);
} catch (Exception e) {
log.error("Couldn't auto-pay payment.", e);
log.info("Update payment status to rejected");
payment.setStatus(ConsentStatusCode.REJECTED);
log.info("Payment {}", payment);
} finally {
internationalPaymentService.updatePayment(payment);
paymentNotificationService.paymentStatusChanged(payment);
}
}
log.info("All payments in process are now accepted. See you in 1 minute! The time is now {}.", format.print(DateTime.now()));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.Account in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticPaymentTask method autoAcceptPayment.
@Scheduled(fixedRate = 60 * 1000)
@SchedulerLock(name = "domesticPayment")
public void autoAcceptPayment() {
log.info("Auto-accept payment task waking up. The time is now {}.", format.print(DateTime.now()));
Collection<FRDomesticConsent> allPaymentsInProcess = domesticPaymentsService.getAllPaymentsInProcess();
for (FRDomesticConsent payment : allPaymentsInProcess) {
log.info("Processing payment {}", payment);
try {
String identificationTo = moveDebitPayment(payment);
Optional<Account> isAccountToFromOurs = accountStoreService.findAccountByIdentification(identificationTo);
if (isAccountToFromOurs.isPresent()) {
moveCreditPayment(payment, identificationTo, isAccountToFromOurs.get());
} else {
log.info("Account '{}' not ours", identificationTo);
}
log.info("Update payment status to completed");
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
log.info("Payment {}", payment);
} catch (CurrencyConverterException e) {
log.info("Can't convert amount in the right currency", e);
log.info("Update payment status to rejected");
payment.setStatus(ConsentStatusCode.REJECTED);
log.info("Payment {}", payment);
} catch (Exception e) {
log.error("Couldn't auto-pay payment.", e);
log.info("Update payment status to rejected");
payment.setStatus(ConsentStatusCode.REJECTED);
log.info("Payment {}", payment);
} finally {
domesticPaymentsService.updatePayment(payment);
paymentNotificationService.paymentStatusChanged(payment);
}
}
log.info("All payments in process are now accepted. See you in 1 minute! The time is now {}.", format.print(DateTime.now()));
}
Aggregations