Search in sources :

Example 91 with FRDomesticConsent

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));
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)

Example 92 with FRDomesticConsent

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()));
}
Also used : Meta(uk.org.openbanking.datamodel.account.Meta) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)

Example 93 with FRDomesticConsent

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();
}
Also used : ParameterizedTypeReference(org.springframework.core.ParameterizedTypeReference) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) UriComponentsBuilder(org.springframework.web.util.UriComponentsBuilder) List(java.util.List) URI(java.net.URI)

Example 94 with FRDomesticConsent

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;
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)

Example 95 with FRDomesticConsent

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);
}
Also used : FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)105 Test (org.junit.Test)62 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)50 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)49 FRDomesticPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission)37 Collections (java.util.Collections)15 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)14 FRWriteDomesticConverter.toOBWriteDomestic2 (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticConverter.toOBWriteDomestic2)13 DomesticPaymentService (com.forgerock.openbanking.common.services.store.payment.DomesticPaymentService)13 ResponseEntity (org.springframework.http.ResponseEntity)12 ConsentStatusCode (com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode)11 RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)9 FRWriteDomestic (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomestic)9 FRWriteDomesticConsent (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticConsent)9 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)9 Principal (java.security.Principal)9 FRAccount (com.forgerock.openbanking.common.model.openbanking.persistence.account.FRAccount)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)7 DateTime (org.joda.time.DateTime)7 HttpHeaders (org.springframework.http.HttpHeaders)7