use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRScheduledPayment in project openbanking-aspsp by OpenBankingToolkit.
the class ScheduledPaymentsApiController method getScheduledPayments.
@Override
public ResponseEntity<OBReadScheduledPayment1> getScheduledPayments(@ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP. " + "All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: " + "Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @ApiParam(value = "The OB account IDs") @RequestHeader(value = "x-ob-account-ids", required = true) List<String> accountIds, @ApiParam(value = "The OB permissions") @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @ApiParam(value = "The origin http url") @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
LOGGER.info("Reading schedule payment from account ids {}", accountIds);
Page<FRScheduledPayment> scheduledPayments = frScheduledPaymentRepository.byAccountIdInWithPermissions(accountIds, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_SCHEDULE_PAYMENTS));
int totalPages = scheduledPayments.getTotalPages();
return ResponseEntity.ok(new OBReadScheduledPayment1().data(new OBReadScheduledPayment1Data().scheduledPayment(scheduledPayments.getContent().stream().map(FRScheduledPayment::getScheduledPayment).map(FRScheduledPaymentConverter::toOBScheduledPayment1).map(dd -> accountDataInternalIdFilter.apply(dd)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRScheduledPayment in project openbanking-aspsp by OpenBankingToolkit.
the class ScheduledPaymentsApiController method getAccountScheduledPayments.
@Override
public ResponseEntity<OBReadScheduledPayment1> getAccountScheduledPayments(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP. " + "All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: " + "Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
LOGGER.info("Read scheduled payments for account {} with minimumPermissions {}", accountId, permissions);
Page<FRScheduledPayment> scheduledPayments = frScheduledPaymentRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_SCHEDULE_PAYMENTS));
int totalPages = scheduledPayments.getTotalPages();
return ResponseEntity.ok(new OBReadScheduledPayment1().data(new OBReadScheduledPayment1Data().scheduledPayment(scheduledPayments.getContent().stream().map(FRScheduledPayment::getScheduledPayment).map(FRScheduledPaymentConverter::toOBScheduledPayment1).map(dd -> accountDataInternalIdFilter.apply(dd)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRScheduledPayment in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticScheduledPaymentTaskTest method scheduledPayment_ignoreIfNotDue.
@Test
public void scheduledPayment_ignoreIfNotDue() throws CurrencyConverterException {
// Given
FRScheduledPayment payment = defaultPayment(DateTime.now().plusDays(1), ScheduledPaymentStatus.PENDING);
given(paymentsService.getPendingAndDueScheduledPayments()).willReturn(Collections.singletonList(payment));
// When
acceptDueScheduledPaymentTask.payDueScheduledPayments();
// Then
verifyZeroInteractions(moneyService);
assertThat(payment.getStatus()).isEqualTo(ScheduledPaymentStatus.PENDING);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRScheduledPayment in project openbanking-aspsp by OpenBankingToolkit.
the class AcceptDomesticScheduledPaymentTaskTest method scheduledPaymentDue_shouldDebitAccount.
@Test
public void scheduledPaymentDue_shouldDebitAccount() throws CurrencyConverterException {
// Given
FRScheduledPayment payment = defaultPayment(DateTime.now().minusDays(1), ScheduledPaymentStatus.PENDING);
given(paymentsService.getPendingAndDueScheduledPayments()).willReturn(Collections.singletonList(payment));
FRAccount account = defaultAccount(DEBIT_ACCOUNT);
given(account2StoreService.getAccount(DEBIT_ACCOUNT)).willReturn(account);
// When
acceptDueScheduledPaymentTask.payDueScheduledPayments();
// Then
verify(moneyService).moveMoney(eq(account), eq(payment.getScheduledPayment().getInstructedAmount()), eq(FRCreditDebitIndicator.DEBIT), eq(payment), any());
verify(paymentsService).updateSchedulePayment(argThat(p -> p.getStatus().equals(ScheduledPaymentStatus.COMPLETED)));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.account.FRScheduledPayment in project openbanking-aspsp by OpenBankingToolkit.
the class ScheduledPaymentsApiController method getAccountScheduledPayments.
@Override
public ResponseEntity<OBReadScheduledPayment2> getAccountScheduledPayments(@ApiParam(value = "A unique identifier used to identify the account resource.", required = true) @PathVariable("AccountId") String accountId, @ApiParam(value = "Page number.", required = false, defaultValue = "0") @RequestParam(value = "page", defaultValue = "0") int page, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "The time when the PSU last logged in with the TPP. " + "All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: " + "Sun, 10 Sep 2017 19:43:31 UTC") @RequestHeader(value = "x-fapi-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.") @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress, @ApiParam(value = "An RFC4122 UID used as a correlation id.") @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId, @ApiParam(value = "Indicates the user-agent that the PSU is using.") @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent, @RequestHeader(value = "x-ob-permissions", required = true) List<OBExternalPermissions1Code> permissions, @RequestHeader(value = "x-ob-url", required = true) String httpUrl) throws OBErrorResponseException {
log.info("Read scheduled payments for account {} with minimumPermissions {}", accountId, permissions);
Page<FRScheduledPayment> scheduledPayments = frScheduledPaymentRepository.byAccountIdWithPermissions(accountId, toFRExternalPermissionsCodeList(permissions), PageRequest.of(page, PAGE_LIMIT_SCHEDULE_PAYMENTS));
int totalPages = scheduledPayments.getTotalPages();
return ResponseEntity.ok(new OBReadScheduledPayment2().data(new OBReadScheduledPayment2Data().scheduledPayment(scheduledPayments.getContent().stream().map(FRScheduledPayment::getScheduledPayment).map(FRScheduledPaymentConverter::toOBScheduledPayment2).map(dd -> accountDataInternalIdFilter.apply(dd)).collect(Collectors.toList()))).links(PaginationUtil.generateLinks(httpUrl, page, totalPages)).meta(PaginationUtil.generateMetaData(totalPages)));
}
Aggregations