Search in sources :

Example 1 with OBWriteInternationalScheduled3

use of uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduled3 in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalScheduledPaymentsApiController method createInternationalScheduledPayments.

@Override
public ResponseEntity<OBWriteInternationalScheduledResponse5> createInternationalScheduledPayments(OBWriteInternationalScheduled3 obWriteInternationalScheduled3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = obWriteInternationalScheduled3.getData().getConsentId();
    FRInternationalScheduledConsent payment = paymentsService.getPayment(consentId);
    return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).payment(payment).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
        f.verifyPaymentIdWithAccessToken();
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyPaymentStatus();
        f.verifyRiskAndInitiation(toFRWriteInternationalScheduledDataInitiation(obWriteInternationalScheduled3.getData().getInitiation()), toFRRisk(obWriteInternationalScheduled3.getRisk()));
        f.verifyJwsDetachedSignature(xJwsSignature, request);
    }).execute((String tppId) -> {
        // Modify the status of the payment
        log.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
        FRWriteInternationalScheduledDataInitiation initiation = payment.getInitiation();
        FRScheduledPaymentData scheduledPayment = FRScheduledPaymentData.builder().accountId(payment.getAccountId()).creditorAccount(initiation.getCreditorAccount()).instructedAmount(initiation.getInstructedAmount()).scheduledType(FRScheduledPaymentData.FRScheduleType.EXECUTION).scheduledPaymentDateTime(initiation.getRequestedExecutionDateTime()).scheduledPaymentId(payment.getId()).build();
        String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
        scheduledPaymentService.createSchedulePayment(scheduledPayment, pispId);
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        log.info("Updating payment");
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalScheduledResponse5.class, obWriteInternationalScheduled3);
    });
}
Also used : RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) FRScheduledPaymentData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData) FRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation) Controller(org.springframework.stereotype.Controller) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) ApiVersionUtils.getOBVersion(com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) HttpHeaders(org.springframework.http.HttpHeaders) InternationalScheduledPaymentService(com.forgerock.openbanking.common.services.store.payment.InternationalScheduledPaymentService) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) OBWriteInternationalScheduledResponse5(uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduledResponse5) ScheduledPaymentService(com.forgerock.openbanking.common.services.store.account.scheduledpayment.ScheduledPaymentService) ResponseEntity(org.springframework.http.ResponseEntity) FRPaymentRiskConverter.toFRRisk(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk) OBWritePaymentDetailsResponse1(uk.org.openbanking.datamodel.payment.OBWritePaymentDetailsResponse1) Collections(java.util.Collections) TppStoreService(com.forgerock.openbanking.common.services.store.tpp.TppStoreService) OBWriteInternationalScheduled3(uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduled3) FRScheduledPaymentData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)

Example 2 with OBWriteInternationalScheduled3

use of uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduled3 in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalScheduledPaymentsApiController method createInternationalScheduledPayments.

public ResponseEntity<OBWriteInternationalScheduledResponse6> createInternationalScheduledPayments(OBWriteInternationalScheduled3 obWriteInternationalScheduled3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = obWriteInternationalScheduled3.getData().getConsentId();
    FRInternationalScheduledConsent payment = paymentsService.getPayment(consentId);
    return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).payment(payment).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
        f.verifyPaymentIdWithAccessToken();
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyPaymentStatus();
        f.verifyRiskAndInitiation(toFRWriteInternationalScheduledDataInitiation(obWriteInternationalScheduled3.getData().getInitiation()), toFRRisk(obWriteInternationalScheduled3.getRisk()));
        f.verifyJwsDetachedSignature(xJwsSignature, request);
    }).execute((String tppId) -> {
        // Modify the status of the payment
        log.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
        FRWriteInternationalScheduledDataInitiation initiation = payment.getInitiation();
        FRScheduledPaymentData scheduledPayment = FRScheduledPaymentData.builder().accountId(payment.getAccountId()).creditorAccount(initiation.getCreditorAccount()).instructedAmount(initiation.getInstructedAmount()).scheduledType(FRScheduledPaymentData.FRScheduleType.EXECUTION).scheduledPaymentDateTime(initiation.getRequestedExecutionDateTime()).scheduledPaymentId(payment.getId()).build();
        String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
        scheduledPaymentService.createSchedulePayment(scheduledPayment, pispId);
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        log.info("Updating payment");
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalScheduledResponse6.class, obWriteInternationalScheduled3);
    });
}
Also used : RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) FRScheduledPaymentData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData) FRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation) Controller(org.springframework.stereotype.Controller) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) ApiVersionUtils.getOBVersion(com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) HttpHeaders(org.springframework.http.HttpHeaders) InternationalScheduledPaymentService(com.forgerock.openbanking.common.services.store.payment.InternationalScheduledPaymentService) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) OBWriteInternationalScheduledResponse6(uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduledResponse6) ScheduledPaymentService(com.forgerock.openbanking.common.services.store.account.scheduledpayment.ScheduledPaymentService) ResponseEntity(org.springframework.http.ResponseEntity) FRPaymentRiskConverter.toFRRisk(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk) OBWritePaymentDetailsResponse1(uk.org.openbanking.datamodel.payment.OBWritePaymentDetailsResponse1) Collections(java.util.Collections) TppStoreService(com.forgerock.openbanking.common.services.store.tpp.TppStoreService) OBWriteInternationalScheduled3(uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduled3) FRScheduledPaymentData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)

Example 3 with OBWriteInternationalScheduled3

use of uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduled3 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 {
    String consentId = obWriteInternationalScheduled3.getData().getConsentId();
    FRInternationalScheduledConsent payment = paymentsService.getPayment(consentId);
    return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).payment(payment).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
        f.verifyPaymentIdWithAccessToken();
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyPaymentStatus();
        f.verifyRiskAndInitiation(toFRWriteInternationalScheduledDataInitiation(obWriteInternationalScheduled3.getData().getInitiation()), toFRRisk(obWriteInternationalScheduled3.getRisk()));
        f.verifyJwsDetachedSignature(xJwsSignature, request);
    }).execute((String tppId) -> {
        // Modify the status of the payment
        log.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
        FRWriteInternationalScheduledDataInitiation initiation = payment.getInitiation();
        FRScheduledPaymentData scheduledPayment = FRScheduledPaymentData.builder().accountId(payment.getAccountId()).creditorAccount(initiation.getCreditorAccount()).instructedAmount(initiation.getInstructedAmount()).scheduledType(FRScheduledPaymentData.FRScheduleType.EXECUTION).scheduledPaymentDateTime(initiation.getRequestedExecutionDateTime()).scheduledPaymentId(payment.getId()).build();
        String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
        scheduledPaymentService.createSchedulePayment(scheduledPayment, pispId);
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        log.info("Updating payment");
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalScheduledResponse4.class, obWriteInternationalScheduled3);
    });
}
Also used : RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) FRScheduledPaymentData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData) FRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation) Controller(org.springframework.stereotype.Controller) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) ApiVersionUtils.getOBVersion(com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) HttpHeaders(org.springframework.http.HttpHeaders) InternationalScheduledPaymentService(com.forgerock.openbanking.common.services.store.payment.InternationalScheduledPaymentService) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) OBWriteInternationalScheduledResponse4(uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduledResponse4) Principal(java.security.Principal) ScheduledPaymentService(com.forgerock.openbanking.common.services.store.account.scheduledpayment.ScheduledPaymentService) ResponseEntity(org.springframework.http.ResponseEntity) FRPaymentRiskConverter.toFRRisk(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk) OBWritePaymentDetailsResponse1(uk.org.openbanking.datamodel.payment.OBWritePaymentDetailsResponse1) Collections(java.util.Collections) TppStoreService(com.forgerock.openbanking.common.services.store.tpp.TppStoreService) OBWriteInternationalScheduled3(uk.org.openbanking.datamodel.payment.OBWriteInternationalScheduled3) FRScheduledPaymentData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation) FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)

Aggregations

RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)3 FRScheduledPaymentData (com.forgerock.openbanking.common.model.openbanking.domain.account.FRScheduledPaymentData)3 FRWriteInternationalScheduledDataInitiation (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduledDataInitiation)3 ConsentStatusCode (com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode)3 FRInternationalScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent)3 FRPaymentRiskConverter.toFRRisk (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk)3 FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConsentConverter.toFRWriteInternationalScheduledDataInitiation)3 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)3 ScheduledPaymentService (com.forgerock.openbanking.common.services.store.account.scheduledpayment.ScheduledPaymentService)3 InternationalScheduledPaymentService (com.forgerock.openbanking.common.services.store.payment.InternationalScheduledPaymentService)3 TppStoreService (com.forgerock.openbanking.common.services.store.tpp.TppStoreService)3 ApiVersionUtils.getOBVersion (com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion)3 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)3 Principal (java.security.Principal)3 Collections (java.util.Collections)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 Slf4j (lombok.extern.slf4j.Slf4j)3 DateTime (org.joda.time.DateTime)3 HttpHeaders (org.springframework.http.HttpHeaders)3 HttpStatus (org.springframework.http.HttpStatus)3