use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class SinglePaymentService method getAllPaymentsInProcess.
public Collection<FRPaymentSetup> getAllPaymentsInProcess() {
LOGGER.debug("Read all the payments");
ParameterizedTypeReference<List<FRPaymentSetup>> ptr = new ParameterizedTypeReference<List<FRPaymentSetup>>() {
};
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/api/payments/search/findByStatus");
builder.queryParam("status", ConsentStatusCode.ACCEPTEDSETTLEMENTINPROCESS);
URI uri = builder.build().encode().toUri();
ResponseEntity<List<FRPaymentSetup>> entity = restTemplate.exchange(uri, HttpMethod.GET, null, ptr);
return entity.getBody();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldRejectPaymentWhenAnyException.
@Test
public void shouldRejectPaymentWhenAnyException() throws CurrencyConverterException {
// Given
FRPaymentSetup payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
doThrow(new RuntimeException()).when(moneyService).moveMoney(any(), any(), any(), any(), any());
// When
autoAcceptPaymentTask.autoAcceptPayment();
// Then
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.REJECTED)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldRejectPaymentWhenCurrencyConversionException.
@Test
public void shouldRejectPaymentWhenCurrencyConversionException() throws CurrencyConverterException {
// Given
FRPaymentSetup payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
doThrow(CurrencyConverterException.class).when(moneyService).moveMoney(any(), any(), any(), any(), any());
// When
autoAcceptPaymentTask.autoAcceptPayment();
// Then
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.REJECTED)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class MoneyServiceTest method shouldDebitAccount.
@Test
public void shouldDebitAccount() throws CurrencyConverterException {
// Given
given(balanceStoreService.getBalance(DEBIT_ACCOUNT, OBBalanceType1Code.INTERIMAVAILABLE)).willReturn(Optional.of(defaultBalance(DEBIT_ACCOUNT, "20")));
// When
moneyService.moveMoney(defaultAccount(DEBIT_ACCOUNT), defaultAmount(), FRCreditDebitIndicator.DEBIT, new FRPaymentSetup(), mock(CreateTransaction.class));
// Then
verify(balanceStoreService).updateBalance(defaultBalance(DEBIT_ACCOUNT, "17.00"));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentSetup method registerPendingPayment.
private FRPaymentSetup registerPendingPayment(String tppId, OBPaymentSetup1 paymentSetupPOSTRequest, String paymentID) {
FRPaymentSetup payment = new FRPaymentSetup();
payment.setStatus(ConsentStatusCode.PENDING);
payment.setPisp(tppStoreService.findByClientId(tppId).get());
// return paymentsService.createPayment(payment);
return null;
}
Aggregations