Search in sources :

Example 1 with OBWriteDomesticStandingOrder3

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

the class DomesticStandingOrdersApiController method createDomesticStandingOrders.

public ResponseEntity<OBWriteDomesticStandingOrderResponse4> createDomesticStandingOrders(OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = obWriteDomesticStandingOrder3.getData().getConsentId();
    FRDomesticStandingOrderConsent 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(toFRWriteDomesticStandingOrderDataInitiation(obWriteDomesticStandingOrder3.getData().getInitiation()), toFRRisk(obWriteDomesticStandingOrder3.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);
        FRWriteDomesticStandingOrderDataInitiation paymentInitiation = payment.getDomesticStandingOrderConsent().getData().getInitiation();
        DateTime firstPaymentDateTime = paymentInitiation.getFirstPaymentDateTime();
        FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(paymentInitiation.getCreditorAccount()).frequency(paymentInitiation.getFrequency()).reference(paymentInitiation.getReference()).firstPaymentDateTime(paymentInitiation.getFirstPaymentDateTime()).firstPaymentAmount(paymentInitiation.getFirstPaymentAmount()).nextPaymentAmount(paymentInitiation.getRecurringPaymentAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(paymentInitiation.getFirstPaymentDateTime(), paymentInitiation.getFrequency())).finalPaymentDateTime(paymentInitiation.getFinalPaymentDateTime()).finalPaymentAmount(paymentInitiation.getFinalPaymentAmount()).standingOrderId(payment.getId()).build();
        String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
        standingOrderService.createStandingOrder(standingOrder, pispId);
        log.info("Updating standing order '{}'", payment.getId());
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderResponse4.class, obWriteDomesticStandingOrder3);
    });
}
Also used : RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) FrequencyService(com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService) Controller(org.springframework.stereotype.Controller) OBWriteDomesticStandingOrderResponse4(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrderResponse4) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) ApiVersionUtils.getOBVersion(com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) DomesticStandingOrderService(com.forgerock.openbanking.common.services.store.payment.DomesticStandingOrderService) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) OBWriteDomesticStandingOrder3(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrder3) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) StandingOrderService(com.forgerock.openbanking.common.services.store.account.standingorder.StandingOrderService) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) 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) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) DateTime(org.joda.time.DateTime)

Example 2 with OBWriteDomesticStandingOrder3

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

the class DomesticStandingOrdersApiController method createDomesticStandingOrders.

@Override
public ResponseEntity<OBWriteDomesticStandingOrderResponse5> createDomesticStandingOrders(OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = obWriteDomesticStandingOrder3.getData().getConsentId();
    FRDomesticStandingOrderConsent 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(toFRWriteDomesticStandingOrderDataInitiation(obWriteDomesticStandingOrder3.getData().getInitiation()), toFRRisk(obWriteDomesticStandingOrder3.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);
        FRWriteDomesticStandingOrderDataInitiation initiation = payment.getInitiation();
        DateTime firstPaymentDateTime = initiation.getFirstPaymentDateTime();
        FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(initiation.getCreditorAccount()).frequency(initiation.getFrequency()).reference(initiation.getReference()).firstPaymentDateTime(initiation.getFirstPaymentDateTime()).firstPaymentAmount(initiation.getFirstPaymentAmount()).nextPaymentAmount(initiation.getRecurringPaymentAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(initiation.getFirstPaymentDateTime(), initiation.getFrequency())).finalPaymentDateTime(initiation.getFinalPaymentDateTime()).finalPaymentAmount(initiation.getFinalPaymentAmount()).standingOrderId(payment.getId()).build();
        String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
        standingOrderService.createStandingOrder(standingOrder, pispId);
        log.info("Updating standing order '{}'", payment.getId());
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderResponse5.class, obWriteDomesticStandingOrder3);
    });
}
Also used : RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) FrequencyService(com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService) Controller(org.springframework.stereotype.Controller) OBWriteDomesticStandingOrderResponse5(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrderResponse5) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) ApiVersionUtils.getOBVersion(com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) DomesticStandingOrderService(com.forgerock.openbanking.common.services.store.payment.DomesticStandingOrderService) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) OBWriteDomesticStandingOrder3(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrder3) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) StandingOrderService(com.forgerock.openbanking.common.services.store.account.standingorder.StandingOrderService) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) 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) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) DateTime(org.joda.time.DateTime)

Example 3 with OBWriteDomesticStandingOrder3

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

the class DomesticStandingOrdersApiController method createDomesticStandingOrders.

public ResponseEntity<OBWriteDomesticStandingOrderResponse6> createDomesticStandingOrders(OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    String consentId = obWriteDomesticStandingOrder3.getData().getConsentId();
    FRDomesticStandingOrderConsent 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(toFRWriteDomesticStandingOrderDataInitiation(obWriteDomesticStandingOrder3.getData().getInitiation()), toFRRisk(obWriteDomesticStandingOrder3.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);
        FRWriteDomesticStandingOrderDataInitiation initiation = payment.getInitiation();
        DateTime firstPaymentDateTime = initiation.getFirstPaymentDateTime();
        FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(initiation.getCreditorAccount()).frequency(initiation.getFrequency()).reference(initiation.getReference()).firstPaymentDateTime(initiation.getFirstPaymentDateTime()).firstPaymentAmount(initiation.getFirstPaymentAmount()).nextPaymentAmount(initiation.getRecurringPaymentAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(initiation.getFirstPaymentDateTime(), initiation.getFrequency())).finalPaymentDateTime(initiation.getFinalPaymentDateTime()).finalPaymentAmount(initiation.getFinalPaymentAmount()).standingOrderId(payment.getId()).build();
        String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
        standingOrderService.createStandingOrder(standingOrder, pispId);
        log.info("Updating standing order '{}'", payment.getId());
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderResponse6.class, obWriteDomesticStandingOrder3);
    });
}
Also used : RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) FrequencyService(com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService) Controller(org.springframework.stereotype.Controller) OBWriteDomesticStandingOrderResponse6(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrderResponse6) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) ApiVersionUtils.getOBVersion(com.forgerock.openbanking.common.utils.ApiVersionUtils.getOBVersion) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) DomesticStandingOrderService(com.forgerock.openbanking.common.services.store.payment.DomesticStandingOrderService) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) OBWriteDomesticStandingOrder3(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrder3) HttpStatus(org.springframework.http.HttpStatus) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) StandingOrderService(com.forgerock.openbanking.common.services.store.account.standingorder.StandingOrderService) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) 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) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) DateTime(org.joda.time.DateTime)

Example 4 with OBWriteDomesticStandingOrder3

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

the class DomesticStandingOrdersApiController method createDomesticStandingOrders.

@Override
public ResponseEntity<OBWriteDomesticStandingOrderResponse3> createDomesticStandingOrders(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, @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 {
    String consentId = obWriteDomesticStandingOrder3.getData().getConsentId();
    FRDomesticStandingOrderConsent payment = paymentsService.getPayment(consentId);
    return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).payment(payment).principal(principal).filters(f -> {
        f.verifyPaymentIdWithAccessToken();
        f.verifyIdempotencyKeyLength(xIdempotencyKey);
        f.verifyPaymentStatus();
        f.verifyRiskAndInitiation(toFRWriteDomesticStandingOrderDataInitiation(obWriteDomesticStandingOrder3.getData().getInitiation()), toFRRisk(obWriteDomesticStandingOrder3.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);
        FRWriteDomesticStandingOrderDataInitiation initiation = payment.getInitiation();
        DateTime firstPaymentDateTime = initiation.getFirstPaymentDateTime();
        FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(initiation.getCreditorAccount()).frequency(initiation.getFrequency()).reference(initiation.getReference()).firstPaymentDateTime(initiation.getFirstPaymentDateTime()).firstPaymentAmount(initiation.getFirstPaymentAmount()).nextPaymentAmount(initiation.getRecurringPaymentAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(initiation.getFirstPaymentDateTime(), initiation.getFrequency())).finalPaymentDateTime(initiation.getFinalPaymentDateTime()).finalPaymentAmount(initiation.getFinalPaymentAmount()).standingOrderId(payment.getId()).build();
        String pispId = tppStoreService.findPispIdByTppId(tppId);
        standingOrderService.createStandingOrder(standingOrder, pispId);
        log.info("Updating standing order '{}'", payment.getId());
        payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
        paymentsService.updatePayment(payment);
        HttpHeaders additionalHttpHeaders = new HttpHeaders();
        additionalHttpHeaders.add("x-ob-payment-id", consentId);
        return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderResponse3.class, obWriteDomesticStandingOrder3);
    });
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RsStoreGateway(com.forgerock.openbanking.common.services.store.RsStoreGateway) ApiParam(io.swagger.annotations.ApiParam) Autowired(org.springframework.beans.factory.annotation.Autowired) FrequencyService(com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService) Controller(org.springframework.stereotype.Controller) DateTimeFormat(org.springframework.format.annotation.DateTimeFormat) OBWriteDomesticStandingOrderResponse3(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrderResponse3) RequestBody(org.springframework.web.bind.annotation.RequestBody) Valid(javax.validation.Valid) HttpServletRequest(javax.servlet.http.HttpServletRequest) ConsentStatusCode(com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode) HTTP_DATE_FORMAT(com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) RSEndpointWrapperService(com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService) DomesticStandingOrderService(com.forgerock.openbanking.common.services.store.payment.DomesticStandingOrderService) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) DateTime(org.joda.time.DateTime) OBWriteDomesticStandingOrder3(uk.org.openbanking.datamodel.payment.OBWriteDomesticStandingOrder3) Slf4j(lombok.extern.slf4j.Slf4j) Principal(java.security.Principal) StandingOrderService(com.forgerock.openbanking.common.services.store.account.standingorder.StandingOrderService) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) ResponseEntity(org.springframework.http.ResponseEntity) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) FRPaymentRiskConverter.toFRRisk(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk) Collections(java.util.Collections) TppStoreService(com.forgerock.openbanking.common.services.store.tpp.TppStoreService) HttpHeaders(org.springframework.http.HttpHeaders) FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation) FRWriteDomesticStandingOrderDataInitiation(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) FRStandingOrderData(com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData) DateTime(org.joda.time.DateTime)

Aggregations

RSEndpointWrapperService (com.forgerock.openbanking.aspsp.rs.wrappper.RSEndpointWrapperService)4 FRStandingOrderData (com.forgerock.openbanking.common.model.openbanking.domain.account.FRStandingOrderData)4 FRWriteDomesticStandingOrderDataInitiation (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrderDataInitiation)4 ConsentStatusCode (com.forgerock.openbanking.common.model.openbanking.persistence.payment.ConsentStatusCode)4 FRDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent)4 FRPaymentRiskConverter.toFRRisk (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRPaymentRiskConverter.toFRRisk)4 FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConsentConverter.toFRWriteDomesticStandingOrderDataInitiation)4 FrequencyService (com.forgerock.openbanking.common.services.openbanking.frequency.FrequencyService)4 RsStoreGateway (com.forgerock.openbanking.common.services.store.RsStoreGateway)4 StandingOrderService (com.forgerock.openbanking.common.services.store.account.standingorder.StandingOrderService)4 DomesticStandingOrderService (com.forgerock.openbanking.common.services.store.payment.DomesticStandingOrderService)4 TppStoreService (com.forgerock.openbanking.common.services.store.tpp.TppStoreService)4 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)4 Principal (java.security.Principal)4 Collections (java.util.Collections)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 Slf4j (lombok.extern.slf4j.Slf4j)4 DateTime (org.joda.time.DateTime)4 HttpHeaders (org.springframework.http.HttpHeaders)4 ResponseEntity (org.springframework.http.ResponseEntity)4