use of uk.org.openbanking.datamodel.payment.OBWriteInternationalStandingOrderResponse6 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalStandingOrdersApiController method createInternationalStandingOrders.
@Override
public ResponseEntity<OBWriteInternationalStandingOrderResponse6> createInternationalStandingOrders(OBWriteInternationalStandingOrder4 obWriteInternationalStandingOrder4, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
String consentId = obWriteInternationalStandingOrder4.getData().getConsentId();
FRInternationalStandingOrderConsent 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(toFRWriteInternationalStandingOrderDataInitiation(obWriteInternationalStandingOrder4.getData().getInitiation()), toFRRisk(obWriteInternationalStandingOrder4.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);
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
log.info("Updating payment");
paymentsService.updatePayment(payment);
FRWriteInternationalStandingOrderDataInitiation initiation = payment.getInitiation();
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.getInstructedAmount()).nextPaymentAmount(initiation.getInstructedAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(initiation.getFirstPaymentDateTime(), initiation.getFrequency())).finalPaymentDateTime(initiation.getFinalPaymentDateTime()).finalPaymentAmount(initiation.getInstructedAmount()).standingOrderId(payment.getId()).build();
String pispId = tppStoreService.findPispIdByTppId(tppId);
standingOrderService.createStandingOrder(standingOrder, pispId);
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-payment-id", consentId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalStandingOrderResponse6.class, obWriteInternationalStandingOrder4);
});
}
use of uk.org.openbanking.datamodel.payment.OBWriteInternationalStandingOrderResponse6 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalStandingOrdersApiController method responseEntity.
private OBWriteInternationalStandingOrderResponse6 responseEntity(FRInternationalStandingOrderPaymentSubmission frPaymentSubmission, FRInternationalStandingOrderConsent frInternationalStandingOrderConsent) {
FRReadRefundAccount readRefundAccount = frInternationalStandingOrderConsent.getInternationalStandingOrderConsent().getData().getReadRefundAccount();
FRWriteInternationalStandingOrderDataInitiation initiation = frPaymentSubmission.getInternationalStandingOrder().getData().getInitiation();
Optional<FRInternationalResponseDataRefund> refund = frInternationalResponseDataRefund(readRefundAccount, initiation);
return new OBWriteInternationalStandingOrderResponse6().data(new OBWriteInternationalStandingOrderResponse6Data().internationalStandingOrderId(frPaymentSubmission.getId()).initiation(toOBWriteInternationalStandingOrder4DataInitiation(initiation)).creationDateTime(frInternationalStandingOrderConsent.getCreated()).statusUpdateDateTime(frInternationalStandingOrderConsent.getStatusUpdate()).status(toOBWriteInternationalStandingOrderResponse6DataStatus(frInternationalStandingOrderConsent.getStatus())).consentId(frInternationalStandingOrderConsent.getId()).refund(refund.map(FRResponseDataRefundConverter::toOBWriteInternationalResponse4DataRefund).orElse(null))).links(resourceLinkService.toSelfLink(frPaymentSubmission, discovery -> getVersion(discovery).getGetInternationalStandingOrder())).meta(new Meta());
}
Aggregations