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);
});
}
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);
});
}
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);
});
}
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);
});
}
Aggregations