Search in sources :

Example 1 with FRWriteDomesticScheduled

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

the class DomesticScheduledPaymentsApiController method createDomesticScheduledPayments.

public ResponseEntity<OBWriteDomesticScheduledResponse5> createDomesticScheduledPayments(OBWriteDomesticScheduled2 obWriteDomesticScheduled2, 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: '{}'", obWriteDomesticScheduled2);
    FRWriteDomesticScheduled frWriteDomesticScheduled = toFRWriteDomesticScheduled(obWriteDomesticScheduled2);
    log.trace("Converted to: '{}'", frWriteDomesticScheduled);
    String paymentId = obWriteDomesticScheduled2.getData().getConsentId();
    FRDomesticScheduledConsent paymentConsent = domesticScheduledConsentRepository.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);
    // Save Payment
    FRDomesticScheduledPaymentSubmission frPaymentSubmission = FRDomesticScheduledPaymentSubmission.builder().id(paymentId).domesticScheduledPayment(frWriteDomesticScheduled).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled) FRWriteDomesticScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission) Date(java.util.Date)

Example 2 with FRWriteDomesticScheduled

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

the class DomesticScheduledPaymentsApiController method createDomesticScheduledPayments.

public ResponseEntity<OBWriteDomesticScheduledResponse3> createDomesticScheduledPayments(OBWriteDomesticScheduled2 obWriteDomesticScheduled2, 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: '{}'", obWriteDomesticScheduled2);
    FRWriteDomesticScheduled frWriteDomesticScheduled = toFRWriteDomesticScheduled(obWriteDomesticScheduled2);
    log.trace("Converted to: '{}'", frWriteDomesticScheduled);
    String paymentId = obWriteDomesticScheduled2.getData().getConsentId();
    FRDomesticScheduledConsent paymentConsent = domesticScheduledConsentRepository.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);
    // Save Payment
    FRDomesticScheduledPaymentSubmission frPaymentSubmission = FRDomesticScheduledPaymentSubmission.builder().id(paymentId).domesticScheduledPayment(frWriteDomesticScheduled).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled) FRWriteDomesticScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission) Date(java.util.Date)

Example 3 with FRWriteDomesticScheduled

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

the class DomesticScheduledPaymentsApiController method createDomesticScheduledPayments.

@Override
public ResponseEntity createDomesticScheduledPayments(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticScheduled1 obWriteDomesticScheduled1, @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: '{}'", obWriteDomesticScheduled1);
    FRWriteDomesticScheduled frScheduledPayment = toFRWriteDomesticScheduled(obWriteDomesticScheduled1);
    log.trace("Converted to: '{}'", frScheduledPayment);
    String paymentId = frScheduledPayment.getData().getConsentId();
    FRDomesticScheduledConsent paymentConsent = domesticScheduledConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.NOT_FOUND, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    // Save Payment
    FRDomesticScheduledPaymentSubmission frPaymentSubmission = FRDomesticScheduledPaymentSubmission.builder().id(frScheduledPayment.getData().getConsentId()).domesticScheduledPayment(frScheduledPayment).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled) FRWriteDomesticScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission) Date(java.util.Date)

Example 4 with FRWriteDomesticScheduled

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

the class DomesticScheduledPaymentsApiControllerIT method savePaymentSubmission.

private FRDomesticScheduledPaymentSubmission savePaymentSubmission(FRDomesticScheduledConsent consent) {
    FRWriteDomesticScheduled submissionRequest = JMockData.mock(FRWriteDomesticScheduled.class);
    submissionRequest.getData().setInitiation(consent.getInitiation());
    FRDomesticScheduledPaymentSubmission submission = FRDomesticScheduledPaymentSubmission.builder().id(consent.getId()).domesticScheduledPayment(submissionRequest).build();
    submissionRepository.save(submission);
    return submission;
}
Also used : FRWriteDomesticScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled) FRDomesticScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission)

Example 5 with FRWriteDomesticScheduled

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

the class DomesticScheduledPaymentsApiControllerIT method savePaymentSubmission.

private FRDomesticScheduledPaymentSubmission savePaymentSubmission(FRDomesticScheduledConsent consent, String xIdempotencyKey) {
    FRWriteDomesticScheduled submissionRequest = FRWriteDomesticScheduled.builder().risk(consent.getRisk()).data(FRWriteDataDomesticScheduled.builder().consentId(consent.getId()).initiation(consent.getInitiation()).build()).build();
    FRDomesticScheduledPaymentSubmission submission = FRDomesticScheduledPaymentSubmission.builder().id(consent.getId()).domesticScheduledPayment(submissionRequest).idempotencyKey(xIdempotencyKey).build();
    submissionRepository.save(submission);
    return submission;
}
Also used : FRWriteDomesticScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled) FRDomesticScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission)

Aggregations

FRWriteDomesticScheduled (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled)10 FRDomesticScheduledPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission)10 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)7 IdempotentRepositoryAdapter (com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter)5 FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled)5 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)5 Date (java.util.Date)5 SpringSecForTest (com.forgerock.openbanking.integration.test.support.SpringSecForTest)2 Test (org.junit.Test)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2