Search in sources :

Example 1 with FRWriteFile

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile in project openbanking-aspsp by OpenBankingToolkit.

the class FilePaymentsApiController method createFilePayments.

public ResponseEntity<OBWriteFileResponse2> createFilePayments(OBWriteFile2 obWriteFile2, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteFile2);
    FRWriteFile frWriteFile = toFRWriteFile(obWriteFile2);
    log.trace("Converted to: '{}'", frWriteFile);
    String paymentId = obWriteFile2.getData().getConsentId();
    FRFileConsent paymentConsent = fileConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRFilePaymentSubmission frPaymentSubmission = FRFilePaymentSubmission.builder().id(paymentId).filePayment(frWriteFile).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(filePaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRWriteFileConverter.toFRWriteFile(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteFileConverter.toFRWriteFile) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) Date(java.util.Date)

Example 2 with FRWriteFile

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile in project openbanking-aspsp by OpenBankingToolkit.

the class FilePaymentsApiController method createFilePayments.

@Override
public ResponseEntity createFilePayments(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteFile2 obWriteFile2, @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 = "Every request will be processed only once per x-idempotency-key.  The Idempotency Key will be valid for 24 hours.", required = true) @RequestHeader(value = "x-idempotency-key", required = true) String xIdempotencyKey, @ApiParam(value = "A detached JWS signature of the body of the payload.", required = true) @RequestHeader(value = "x-jws-signature", required = true) String xJwsSignature, @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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteFile2);
    FRWriteFile frWriteFile = toFRWriteFile(obWriteFile2);
    log.trace("Converted to: '{}'", frWriteFile);
    String paymentId = obWriteFile2.getData().getConsentId();
    FRFileConsent paymentConsent = fileConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRFilePaymentSubmission frPaymentSubmission = FRFilePaymentSubmission.builder().id(paymentId).filePayment(frWriteFile).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(filePaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRWriteFileConverter.toFRWriteFile(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteFileConverter.toFRWriteFile) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) Date(java.util.Date)

Example 3 with FRWriteFile

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile in project openbanking-aspsp by OpenBankingToolkit.

the class FilePaymentsApiController method createFilePayments.

@Override
public ResponseEntity createFilePayments(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteFile1 obWriteFile1, @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 = "Every request will be processed only once per x-idempotency-key.  The Idempotency Key will be valid for 24 hours.", required = true) @RequestHeader(value = "x-idempotency-key", required = true) String xIdempotencyKey, @ApiParam(value = "A detached JWS signature of the body of the payload.", required = true) @RequestHeader(value = "x-jws-signature", required = true) String xJwsSignature, @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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteFile1);
    FRWriteFile frWriteFile = toFRWriteFile(obWriteFile1);
    log.trace("Converted to: '{}'", frWriteFile);
    String paymentId = frWriteFile.getData().getConsentId();
    FRFileConsent paymentConsent = fileConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRFilePaymentSubmission frPaymentSubmission = FRFilePaymentSubmission.builder().id(paymentId).filePayment(frWriteFile).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(filePaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRWriteFileConverter.toFRWriteFile(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteFileConverter.toFRWriteFile) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) Date(java.util.Date)

Example 4 with FRWriteFile

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile in project openbanking-aspsp by OpenBankingToolkit.

the class FilePaymentsApiControllerIT method savePaymentSubmission.

private FRFilePaymentSubmission savePaymentSubmission(FRFileConsent consent) {
    FRWriteFile submissionRequest = JMockData.mock(FRWriteFile.class);
    submissionRequest.getData().getInitiation().setRequestedExecutionDateTime(null);
    submissionRequest.getData().getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
    FRFilePaymentSubmission submission = FRFilePaymentSubmission.builder().id(consent.getId()).filePayment(submissionRequest).build();
    submissionRepository.save(submission);
    return submission;
}
Also used : FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission)

Example 5 with FRWriteFile

use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile in project openbanking-aspsp by OpenBankingToolkit.

the class FilePaymentsApiControllerIT method testGetMissingInternationalPaymentSubmissionReturnNotFound.

@Test
public void testGetMissingInternationalPaymentSubmissionReturnNotFound() throws UnirestException {
    // Given
    springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
    FRFileConsent consent = saveConsent();
    FRWriteFile submissionRequest = JMockData.mock(FRWriteFile.class);
    FRFilePaymentSubmission submission = FRFilePaymentSubmission.builder().id(consent.getId()).filePayment(submissionRequest).build();
    // When
    HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").asObject(String.class);
    // Then
    assertThat(response.getStatus()).isEqualTo(400);
}
Also used : FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) SpringSecForTest(com.forgerock.openbanking.integration.test.support.SpringSecForTest) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

FRWriteFile (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile)6 FRFilePaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission)6 FRFileConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent)5 IdempotentRepositoryAdapter (com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter)4 FRWriteFileConverter.toFRWriteFile (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteFileConverter.toFRWriteFile)4 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)4 Date (java.util.Date)4 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1