Search in sources :

Example 36 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticScheduledPaymentsApiController method createDomesticScheduledPayments.

@Override
public ResponseEntity<OBWriteDomesticScheduledResponse4> createDomesticScheduledPayments(OBWriteDomesticScheduled2 obWriteDomesticScheduled2, String authorization, String xIdempotencyKey, String xJwsSignature, String 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 37 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalPaymentsApiController method createInternationalPayments.

public ResponseEntity<OBWriteInternationalResponse4> createInternationalPayments(OBWriteInternational3 obWriteInternational3, 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: '{}'", obWriteInternational3);
    FRWriteInternational frWriteInternational = toFRWriteInternational(obWriteInternational3);
    log.trace("Converted to: '{}'", frWriteInternational);
    String paymentId = obWriteInternational3.getData().getConsentId();
    FRInternationalConsent paymentConsent = internationalConsentRepository.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);
    FRInternationalPaymentSubmission frPaymentSubmission = FRInternationalPaymentSubmission.builder().id(paymentId).internationalPayment(frWriteInternational).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRWriteInternational(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational) FRWriteInternationalConverter.toFRWriteInternational(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConverter.toFRWriteInternational) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRInternationalPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalPaymentSubmission) Date(java.util.Date)

Example 38 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalScheduledPaymentsApiController method createInternationalScheduledPayments.

public ResponseEntity<OBWriteInternationalScheduledResponse4> createInternationalScheduledPayments(OBWriteInternationalScheduled3 obWriteInternationalScheduled3, 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: '{}'", obWriteInternationalScheduled3);
    FRWriteInternationalScheduled frWriteInternationalScheduled = toFRWriteInternationalScheduled(obWriteInternationalScheduled3);
    log.trace("Converted to: '{}'", frWriteInternationalScheduled);
    String paymentId = obWriteInternationalScheduled3.getData().getConsentId();
    FRInternationalScheduledConsent paymentConsent = internationalScheduledConsentRepository.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);
    FRInternationalScheduledPaymentSubmission frPaymentSubmission = FRInternationalScheduledPaymentSubmission.builder().id(paymentId).internationalScheduledPayment(frWriteInternationalScheduled).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : FRWriteInternationalScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduled) FRWriteInternationalScheduledConverter.toFRWriteInternationalScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConverter.toFRWriteInternationalScheduled) FRInternationalScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledPaymentSubmission) IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) Date(java.util.Date)

Aggregations

IdempotentRepositoryAdapter (com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter)38 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)37 Date (java.util.Date)37 FRWriteInternationalStandingOrder (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrder)6 FRDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent)6 FRDomesticStandingOrderPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderPaymentSubmission)6 FRInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent)6 FRInternationalStandingOrderPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderPaymentSubmission)6 FRWriteInternationalStandingOrderConverter.toFRWriteInternationalStandingOrder (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalStandingOrderConverter.toFRWriteInternationalStandingOrder)6 FRWriteDomestic (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomestic)5 FRWriteDomesticScheduled (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled)5 FRWriteDomesticStandingOrder (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrder)5 FRWriteInternational (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational)5 FRWriteInternationalScheduled (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduled)5 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)5 FRDomesticPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission)5 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)5 FRDomesticScheduledPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission)5 FRInternationalConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent)5 FRInternationalPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalPaymentSubmission)5