use of uk.org.openbanking.datamodel.payment.OBWriteInternationalResponse5 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentsApiController method responseEntity.
private OBWriteInternationalResponse5 responseEntity(FRInternationalPaymentSubmission frPaymentSubmission, FRInternationalConsent frInternationalConsent) {
FRReadRefundAccount readRefundAccount = frInternationalConsent.getInternationalConsent().getData().getReadRefundAccount();
FRWriteInternationalDataInitiation initiation = frPaymentSubmission.getInternationalPayment().getData().getInitiation();
Optional<FRInternationalResponseDataRefund> refund = frInternationalResponseDataRefund(readRefundAccount, initiation);
return new OBWriteInternationalResponse5().data(new OBWriteInternationalResponse5Data().internationalPaymentId(frPaymentSubmission.getId()).initiation(toOBWriteInternational3DataInitiation(frPaymentSubmission.getInternationalPayment().getData().getInitiation())).creationDateTime(frInternationalConsent.getCreated()).statusUpdateDateTime(frInternationalConsent.getStatusUpdate()).status(toOBWriteInternationalResponse5DataStatus(frInternationalConsent.getStatus())).consentId(frInternationalConsent.getId()).debtor(toOBCashAccountDebtor4(frInternationalConsent.getInitiation().getDebtorAccount())).exchangeRateInformation(toOBWriteInternationalConsentResponse6DataExchangeRateInformation(frInternationalConsent.getCalculatedExchangeRate())).refund(refund.map(FRResponseDataRefundConverter::toOBWriteInternationalResponse5DataRefund).orElse(null))).links(resourceLinkService.toSelfLink(frPaymentSubmission, discovery -> getVersion(discovery).getGetInternationalPayment())).meta(new Meta());
}
use of uk.org.openbanking.datamodel.payment.OBWriteInternationalResponse5 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentsApiController method createInternationalPayments.
public ResponseEntity<OBWriteInternationalResponse5> createInternationalPayments(OBWriteInternational3 obWriteInternational3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
String consentId = obWriteInternational3.getData().getConsentId();
FRInternationalConsent 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(toFRWriteInternationalDataInitiation(obWriteInternational3.getData().getInitiation()), toFRRisk(obWriteInternational3.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.ACCEPTEDSETTLEMENTINPROCESS);
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(), OBWriteInternationalResponse5.class, obWriteInternational3);
});
}
Aggregations