use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testGetInternationalPaymentSubmissionMissingConsentReturnNotFound.
@Test
public void testGetInternationalPaymentSubmissionMissingConsentReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = JMockData.mock(FRFileConsent.class);
consent.setId(IntentType.PAYMENT_FILE_CONSENT.generateIntentId());
FRFilePaymentSubmission submission = savePaymentSubmission(consent);
// When
HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class RCSFilePaymentDetailsApi method consentDetails.
@Override
public ResponseEntity consentDetails(String remoteConsentRequest, List<AccountWithBalance> accounts, String username, String consentId, String clientId) throws OBErrorException {
log.debug("Received a consent request with consent_request='{}'", remoteConsentRequest);
log.debug("=> The payment id '{}'", consentId);
log.debug("Populate the model with the payment and consent data");
FRFileConsent consent = paymentService.getPayment(consentId);
checkValidPisp(consent, clientId);
// A null debtor account will let PSU select account when authorising
if (consent.getInitiation().getDebtorAccount() != null) {
Optional<AccountWithBalance> matchingUserAccount = accountService.findAccountByIdentification(consent.getInitiation().getDebtorAccount().getIdentification(), accounts);
if (!matchingUserAccount.isPresent()) {
log.error("The PISP '{}' created the payment consent '{}' but the debtor account: {} on the consent " + " is not one of the user's accounts: {}.", consent.getPispId(), consent.getId(), consent.getInitiation().getDebtorAccount(), accounts);
return rcsErrorService.invalidConsentError(remoteConsentRequest, OBRIErrorType.RCS_CONSENT_REQUEST_DEBTOR_ACCOUNT_NOT_FOUND, consent.getPispId(), consent.getId(), accounts);
} else {
accounts = Collections.singletonList(matchingUserAccount.get());
}
}
associatePaymentToUser(consent, username);
Optional<Tpp> isTpp = tppStoreService.findById(consent.getPispId());
if (!isTpp.isPresent()) {
log.error("The TPP '{}' (Client ID {}) that created this consent id '{}' doesn't exist anymore.", consent.getPispId(), clientId, consentId);
return rcsErrorService.error(OBRIErrorType.RCS_CONSENT_REQUEST_NOT_FOUND_TPP, clientId, consentId);
}
Tpp tpp = isTpp.get();
FRWriteFileDataInitiation initiation = consent.getWriteFileConsent().getData().getInitiation();
return ResponseEntity.ok(FilePaymentConsentDetails.builder().accounts(accounts).username(username).merchantName(consent.getPispName()).clientId(clientId).fileReference(initiation.getFileReference()).numberOfTransactions(initiation.getNumberOfTransactions()).totalAmount(new OBActiveOrHistoricCurrencyAndAmount().amount(initiation.getControlSum().toPlainString()).currency(consent.getPayments().get(0).getInstructedAmount().getCurrency())).requestedExecutionDateTime(initiation.getRequestedExecutionDateTime()).paymentReference(Optional.ofNullable(initiation.getRemittanceInformation()).map(FRRemittanceInformation::getReference).orElse("")).build());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testMissingConsentOnPaymentInitiationShouldReturnNotFound.
@Test
public void testMissingConsentOnPaymentInitiationShouldReturnNotFound() throws Exception {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = JMockData.mock(FRFileConsent.class);
consent.setId(IntentType.PAYMENT_FILE_CONSENT.generateIntentId());
consent.getInitiation().setControlSum(new BigDecimal("1001.1"));
consent.getInitiation().setFileType("UK.OBIE.PaymentInitiation.3.0");
consent.getInitiation().setFileReference("Test");
consent.getInitiation().setNumberOfTransactions("100");
consent.getInitiation().setFileHash("sdjhgfksfkshfjksh");
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
OBWriteFile2 submissionRequest = new OBWriteFile2().data(new OBWriteFile2Data().consentId(consent.getId()).initiation(toOBWriteFile2DataInitiation(consent.getInitiation())));
// When
HttpResponse<String> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, "x-idempotency-key").header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(submissionRequest).asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testGetInternationalPaymentSubmission.
@Test
public void testGetInternationalPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = saveConsent();
FRFilePaymentSubmission submission = savePaymentSubmission(consent);
// When
HttpResponse<OBWriteFileConsentResponse2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").asObject(OBWriteFileConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
assertThat(response.getBody().getData().getInitiation()).isEqualTo(toOBFile2(submission.getFilePayment().getData().getInitiation()));
assertThat(response.getBody().getData().getCreationDateTime()).isEqualTo(consent.getCreated());
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiControllerIT method testGetReportFileSuccess.
@Test
public void testGetReportFileSuccess() throws Exception {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRFileConsent consent = saveConsent();
when(paymentReportFileService.createPaymentReport(eq(consent))).thenReturn("{\"Data\": {\"DomesticPayments\": []} }");
// When
HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/file-payments/" + consent.getId() + "/report-file").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, "x-idempotency-key").header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").header("Accept", "application/json; charset=utf-8").asString();
log.debug("Response: {}", response.getBody());
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody()).isEqualTo("{\"Data\": {\"DomesticPayments\": []} }");
}
Aggregations