use of uk.org.openbanking.datamodel.payment.OBWriteInternationalConsent2 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentConsentsApiControllerIT method testCreateInternationalPaymentConsent.
@Test
public void testCreateInternationalPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
PaymentTestHelper.setupMockTpp(tppRepository);
OBWriteInternationalConsent2 consentRequest = JMockData.mock(OBWriteInternationalConsent2.class);
consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
consentRequest.getData().getInitiation().getCreditor().getPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().getExchangeRateInformation().unitCurrency("GBP");
consentRequest.getData().getInitiation().currencyOfTransfer("USD");
consentRequest.getData().getInitiation().getCreditorAgent().getPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().supplementaryData(new OBSupplementaryData1());
consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().countrySubDivision("Wessex").addressLine(Collections.singletonList("3 Queens Square")).country("GP");
// When
HttpResponse<OBWriteInternationalConsentResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/international-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").header("x-ob-client-id", PaymentTestHelper.MOCK_CLIENT_ID).body(consentRequest).asObject(OBWriteInternationalConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteInternationalConsentResponse2 consentResponse = response.getBody();
FRInternationalConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
assertThat(consent.getPispName()).isEqualTo(PaymentTestHelper.MOCK_PISP_NAME);
assertThat(consent.getPispId()).isEqualTo(PaymentTestHelper.MOCK_PISP_ID);
assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(toOBInternational2(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
assertThat(consent.getStatus().toOBExternalConsentStatus1Code()).isEqualTo(consentResponse.getData().getStatus());
assertThat(consent.getObVersion()).isEqualTo(OBVersion.v3_1);
}
use of uk.org.openbanking.datamodel.payment.OBWriteInternationalConsent2 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentConsentsApiControllerIT method testCreateInternationalPaymentConsent_noExchangeRate.
@Test
public void testCreateInternationalPaymentConsent_noExchangeRate() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
PaymentTestHelper.setupMockTpp(tppRepository);
OBWriteInternationalConsent2 consentRequest = JMockData.mock(OBWriteInternationalConsent2.class);
consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
consentRequest.getData().getInitiation().getCreditor().getPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().currencyOfTransfer("USD");
consentRequest.getData().getInitiation().setExchangeRateInformation(null);
consentRequest.getData().getInitiation().getCreditorAgent().getPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().supplementaryData(new OBSupplementaryData1());
consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().countrySubDivision("Wessex").addressLine(Collections.singletonList("3 Queens Square")).country("GP");
// When
HttpResponse<OBWriteInternationalConsentResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/international-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").header("x-ob-client-id", PaymentTestHelper.MOCK_CLIENT_ID).body(consentRequest).asObject(OBWriteInternationalConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteInternationalConsentResponse2 consentResponse = response.getBody();
FRInternationalConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
assertThat(consent.getInitiation().getExchangeRateInformation()).isNull();
}
use of uk.org.openbanking.datamodel.payment.OBWriteInternationalConsent2 in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentConsentsApiController method createInternationalPaymentConsents.
@Override
public ResponseEntity<OBWriteInternationalConsentResponse2> createInternationalPaymentConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalConsent2 obWriteInternationalConsent2Param, @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 {
return rsEndpointWrapperService.paymentEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).filters(f -> {
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyJwsDetachedSignature(xJwsSignature, request);
f.validateRisk(obWriteInternationalConsent2Param.getRisk());
}).execute((String tppId) -> {
exchangeRateVerifier.verify(obWriteInternationalConsent2Param.getData().getInitiation().getExchangeRateInformation());
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-client-id", tppId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalConsentResponse2.class, obWriteInternationalConsent2Param);
});
}
Aggregations