use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldCreditAccount.
@Test
public void shouldCreditAccount() throws CurrencyConverterException {
// Given
FRPaymentSetup payment = defaultPayment();
given(paymentsService.getAllPaymentsInProcess()).willReturn(Collections.singleton(payment));
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(defaultAccount(DEBIT_ACCOUNT));
FRAccount account = defaultAccount(CREDIT_ACCOUNT);
given(account2StoreService.findAccountByIdentification(CREDIT_ACCOUNT)).willReturn(Optional.of(account));
// When
autoAcceptPaymentTask.autoAcceptPayment();
// Then
FRAmount instructedAmount = payment.getInitiation().getInstructedAmount();
verify(moneyService).moveMoney(eq(account), eq(instructedAmount), eq(FRCreditDebitIndicator.CREDIT), eq(payment), any());
verify(paymentsService).updatePayment(argThat(p -> p.getStatus().equals(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptSinglePaymentTaskTest method shouldDebitAccount.
@Test
public void shouldDebitAccount() 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);
// 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.ACCEPTEDSETTLEMENTCOMPLETED)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class MoneyServiceTest method shouldCreditAccount.
@Test
public void shouldCreditAccount() throws CurrencyConverterException {
// Given
given(balanceStoreService.getBalance(CREDIT_ACCOUNT, OBBalanceType1Code.INTERIMAVAILABLE)).willReturn(Optional.of(defaultBalance(CREDIT_ACCOUNT, "1")));
// When
moneyService.moveMoney(defaultAccount(CREDIT_ACCOUNT), defaultAmount(), FRCreditDebitIndicator.CREDIT, new FRPaymentSetup(), mock(CreateTransaction.class));
// Then
verify(balanceStoreService).updateBalance(defaultBalance(CREDIT_ACCOUNT, "4.00"));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class MoneyServiceTest method shouldCreateTransaction.
@Test
public void shouldCreateTransaction() throws CurrencyConverterException {
// Given
FRBalance balance = defaultBalance(DEBIT_ACCOUNT, "20");
given(balanceStoreService.getBalance(DEBIT_ACCOUNT, OBBalanceType1Code.INTERIMAVAILABLE)).willReturn(Optional.of(balance));
CreateTransaction<FRPaymentSetup> createTransaction = mock(CreateTransaction.class);
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
FRPaymentSetup payment = new FRPaymentSetup();
FRTransaction transaction = JMockData.mock(FRTransaction.class);
FRAmount amount = defaultAmount();
given(createTransaction.createTransaction(account, payment, FRCreditDebitIndicator.DEBIT, balance, amount)).willReturn(transaction);
// When
moneyService.moveMoney(account, amount, FRCreditDebitIndicator.DEBIT, payment, createTransaction);
// Then
verify(transactionStoreService).create(transaction);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class SinglePaymentService method updatePayment.
/**
* update payment
*
* @param payment a payment
*/
public void updatePayment(FRPaymentSetup payment) {
LOGGER.debug("Update the payment in the store. FRPaymentConsent={}", payment);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + "/api/payments/");
URI uri = builder.build().encode().toUri();
HttpEntity<FRPaymentSetup> request = new HttpEntity<>(payment, new HttpHeaders());
restTemplate.exchange(uri, HttpMethod.PUT, request, Void.class);
}
Aggregations