use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiController method getDomesticPaymentConsentsConsentId.
@Override
public ResponseEntity getDomesticPaymentConsentsConsentId(String consentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRDomesticConsent> isDomesticConsent = domesticConsentRepository.findById(consentId);
if (!isDomesticConsent.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Domestic consent '" + consentId + "' can't be found");
}
FRDomesticConsent domesticConsent = isDomesticConsent.get();
return ResponseEntity.ok(responseEntity(domesticConsent));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiController method getDomesticPaymentConsentsConsentIdFundsConfirmation.
@Override
public ResponseEntity getDomesticPaymentConsentsConsentIdFundsConfirmation(String consentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, String httpUrl, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRDomesticConsent> isDomesticConsent = domesticConsentRepository.findById(consentId);
if (!isDomesticConsent.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Domestic consent '" + consentId + "' can't be found");
}
FRDomesticConsent domesticConsent = isDomesticConsent.get();
// Check if funds are available on the account selected in consent
boolean areFundsAvailable = fundsAvailabilityService.isFundsAvailable(domesticConsent.getAccountId(), domesticConsent.getInitiation().getInstructedAmount().getAmount());
return ResponseEntity.status(HttpStatus.OK).body(new OBWriteFundsConfirmationResponse1().data(new OBWriteFundsConfirmationResponse1Data().fundsAvailableResult(new OBWriteFundsConfirmationResponse1DataFundsAvailableResult().fundsAvailable(areFundsAvailable).fundsAvailableDateTime(DateTime.now()))).links(PaginationUtil.generateLinksOnePager(httpUrl)).meta(new Meta()));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentService method getAllPaymentsInProcess.
public Collection<FRDomesticConsent> getAllPaymentsInProcess() {
log.debug("Read all the payments");
ParameterizedTypeReference<List<FRDomesticConsent>> ptr = new ParameterizedTypeReference<List<FRDomesticConsent>>() {
};
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(rsStoreRoot + BASE_RESOURCE_PATH + "search/findByStatus");
builder.queryParam("status", ConsentStatusCode.ACCEPTEDSETTLEMENTINPROCESS);
URI uri = builder.build().encode().toUri();
ResponseEntity<List<FRDomesticConsent>> entity = restTemplate.exchange(uri, HttpMethod.GET, null, ptr);
return entity.getBody();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method saveFRConsent.
private FRDomesticConsent saveFRConsent(FRReadRefundAccount frReadRefundAccount, ConsentStatusCode consentStatusCode) {
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.getDomesticConsent().getData().setReadRefundAccount(frReadRefundAccount);
consent.setId(IntentType.PAYMENT_DOMESTIC_CONSENT.generateIntentId());
consent.setIdempotencyKey(UUID.randomUUID().toString());
consent.setStatus(consentStatusCode);
setupTestFRConsentInitiation(consent.getInitiation());
consent.getRisk().setMerchantCategoryCode(aValidFRRisk().getMerchantCategoryCode());
consent.getRisk().setDeliveryAddress(aValidFRRisk().getDeliveryAddress());
consent.setObVersion(OBVersion.v3_1_6);
repository.save(consent);
return consent;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testCreateDomesticPaymentConsent.
@Test
public void testCreateDomesticPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
// When
HttpResponse<OBWriteDomesticConsentResponse5> response = Unirest.post(RS_STORE_URL + port + CONTEXT_PATH).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(aValidOBWriteDomesticConsent4()).asObject(OBWriteDomesticConsentResponse5.class);
// Then
log.error("The response: {}", response);
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticConsentResponse5 consentResponse = response.getBody();
FRDomesticConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
assertThat(consent.getPispName()).isEqualTo(MOCK_PISP_NAME);
assertThat(consent.getPispId()).isEqualTo(MOCK_PISP_ID);
assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(toOBWriteDomestic2DataInitiation(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
assertThat(consent.getStatus().toOBExternalConsentStatus1Code().toString()).isEqualTo(consentResponse.getData().getStatus().getValue());
assertThat(consent.getRisk()).isEqualTo(toFRRisk(consentResponse.getRisk()));
assertThat(consent.getObVersion()).isEqualTo(OBVersion.v3_1_6);
}
Aggregations