Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BD-381: Implemented changes to the OpenAPI specification; fixed versi… #15

Merged
merged 2 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Run integration tests
run: mvn -B -ntp -Dgroups=integration test
env:
BLINKPAY_CLIENT_ID: ${{ secrets.CLIENT_ID }}
BLINKPAY_CLIENT_ID: ${{ vars.CLIENT_ID }}
BLINKPAY_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
BLINKPAY_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}

Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,3 @@ jobs:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_PASSPHRASE }}
SDK_VERSION_NUMBER: ${{ vars.SDK_VERSION_NUMBER }}
BUILD_NUMBER: ${{ github.run_number }}
11 changes: 3 additions & 8 deletions core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<maven.compiler.target>8</maven.compiler.target>

<revision>1.0-SNAPSHOT</revision>
<snakeyaml.version>1.33</snakeyaml.version>
<system.stubs.jupiter.version>2.0.1</system.stubs.jupiter.version>
<snakeyaml.version>2.0</snakeyaml.version>
<system.stubs.jupiter.version>2.0.2</system.stubs.jupiter.version>
</properties>

<dependencies>
Expand All @@ -43,13 +43,8 @@
<profiles>
<profile>
<id>versioning</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<revision>${env.SDK_VERSION_NUMBER}.${env.BUILD_NUMBER}</revision>
<revision>1.1.0</revision>
</properties>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@
*/
public enum BlinkDebitConstant {

REQUEST_ID("X-Request-Id"),
REQUEST_ID("request-id"),

INTERACTION_ID("x-interaction-id"),
CORRELATION_ID("x-correlation-id"),

IDEMPOTENCY_KEY("idempotency-key"),

BEARER("Bearer "),

AUTHORIZATION("Authorization"),

TOKEN_PATH("/oauth2/token"),

METADATA_PATH("/payments/v1/meta"),
Expand Down
23 changes: 9 additions & 14 deletions java-spring6/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
<maven.compiler.target>17</maven.compiler.target>

<revision>1.0-SNAPSHOT</revision>
<spring.boot.version>3.0.2</spring.boot.version>
<spring.cloud.starter.circuitbreaker.reactor.resilience4j.version>3.0.0</spring.cloud.starter.circuitbreaker.reactor.resilience4j.version>
<spring.boot.version>3.0.6</spring.boot.version>
<spring.cloud.starter.circuitbreaker.reactor.resilience4j.version>3.0.1</spring.cloud.starter.circuitbreaker.reactor.resilience4j.version>
<resilience4j.version>2.0.2</resilience4j.version>
<swagger.version>2.2.8</swagger.version>
<java.jwt.version>4.2.2</java.jwt.version>
<slf4j.version>2.0.6</slf4j.version>
<logback.version>1.4.5</logback.version>
<swagger.version>2.2.10</swagger.version>
<java.jwt.version>4.4.0</java.jwt.version>
<slf4j.version>2.0.7</slf4j.version>
<logback.version>1.4.7</logback.version>

<spring.cloud.contract.wiremock.version>4.0.0</spring.cloud.contract.wiremock.version>
<reactor.test.version>3.5.2</reactor.test.version>
<spring.cloud.contract.wiremock.version>4.0.2</spring.cloud.contract.wiremock.version>
<reactor.test.version>3.5.6</reactor.test.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -171,13 +171,8 @@
<profiles>
<profile>
<id>versioning</id>
<activation>
<property>
<name>env.BUILD_NUMBER</name>
</property>
</activation>
<properties>
<revision>${env.SDK_VERSION_NUMBER}.${env.BUILD_NUMBER}</revision>
<revision>1.1.0</revision>
</properties>
</profile>
</profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
import java.util.regex.Pattern;

import static nz.co.blink.debit.dto.v1.Consent.StatusEnum.AUTHORISED;
import static nz.co.blink.debit.dto.v1.Payment.StatusEnum.ACCEPTED;
import static nz.co.blink.debit.dto.v1.Payment.StatusEnum.ACCEPTEDSETTLEMENTCOMPLETED;

/**
Expand Down Expand Up @@ -1532,7 +1531,7 @@ public Payment awaitSuccessfulPayment(UUID paymentId, final int maxWaitSeconds)
Payment.StatusEnum status = payment.getStatus();
log.debug("The last status polled was: {} \tfor Payment ID: {}", status, paymentId);

if (ACCEPTEDSETTLEMENTCOMPLETED == status || ACCEPTED == status) {
if (ACCEPTEDSETTLEMENTCOMPLETED == status) {
return paymentMono;
}

Expand Down Expand Up @@ -1598,7 +1597,6 @@ public Mono<Payment> awaitSuccessfulPaymentAsMono(UUID paymentId, final int maxW

switch (status) {
case ACCEPTEDSETTLEMENTCOMPLETED:
case ACCEPTED:
break;
case REJECTED:
BlinkPaymentRejectedException exception1 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import nz.co.blink.debit.exception.BlinkInvalidValueException;
import nz.co.blink.debit.exception.BlinkServiceException;
import nz.co.blink.debit.helpers.AccessTokenHandler;
import nz.co.blink.debit.helpers.RequestHandler;
import nz.co.blink.debit.helpers.ResponseHandler;
import nz.co.blink.debit.service.ValidationService;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -55,7 +56,7 @@
import java.util.UUID;

import static nz.co.blink.debit.enums.BlinkDebitConstant.ENDURING_CONSENTS_PATH;
import static nz.co.blink.debit.enums.BlinkDebitConstant.INTERACTION_ID;
import static nz.co.blink.debit.enums.BlinkDebitConstant.IDEMPOTENCY_KEY;
import static nz.co.blink.debit.enums.BlinkDebitConstant.REQUEST_ID;

/**
Expand Down Expand Up @@ -236,19 +237,18 @@ public Mono<Consent> getEnduringConsent(UUID consentId, final String requestId)
throw new BlinkInvalidValueException("Consent ID must not be null");
}

String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());

return getWebClientBuilder(correlationId)
return getWebClientBuilder(requestIdFinal)
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(null, clientRequest,
exchangeFunction))
.build()
.get()
.uri(uriBuilder -> uriBuilder
.path(ENDURING_CONSENTS_PATH.getValue() + "/{consentId}")
.build(consentId))
.accept(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> {
httpHeaders.add(REQUEST_ID.getValue(), correlationId);
httpHeaders.add(INTERACTION_ID.getValue(), correlationId);
})
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal))
.exchangeToMono(ResponseHandler.handleResponseMono(Consent.class));
}

Expand All @@ -275,36 +275,38 @@ public Mono<Void> revokeEnduringConsent(UUID consentId, final String requestId)
throw new BlinkInvalidValueException("Consent ID must not be null");
}

String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());

return getWebClientBuilder(correlationId)
return getWebClientBuilder(requestIdFinal)
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(null, clientRequest,
exchangeFunction))
.build()
.delete()
.uri(uriBuilder -> uriBuilder
.path(ENDURING_CONSENTS_PATH.getValue() + "/{consentId}")
.build(consentId))
.accept(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> {
httpHeaders.add(REQUEST_ID.getValue(), correlationId);
httpHeaders.add(INTERACTION_ID.getValue(), correlationId);
})
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal))
.exchangeToMono(ResponseHandler.handleResponseMono(Void.class))
.transformDeferred(RetryOperator.of(retry));
}

private Mono<CreateConsentResponse> createEnduringConsentMono(EnduringConsentRequest request, String requestId)
throws BlinkServiceException {
String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String idempotencyKey = UUID.randomUUID().toString();

return getWebClientBuilder(correlationId)
return getWebClientBuilder(requestIdFinal)
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(request, clientRequest,
exchangeFunction))
.build()
.post()
.uri(ENDURING_CONSENTS_PATH.getValue())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> {
httpHeaders.add(REQUEST_ID.getValue(), correlationId);
httpHeaders.add(INTERACTION_ID.getValue(), correlationId);
httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal);
httpHeaders.add(IDEMPOTENCY_KEY.getValue(), idempotencyKey);
})
.bodyValue(request)
.exchangeToMono(ResponseHandler.handleResponseMono(CreateConsentResponse.class))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import nz.co.blink.debit.enums.BlinkDebitConstant;
import nz.co.blink.debit.exception.BlinkServiceException;
import nz.co.blink.debit.helpers.AccessTokenHandler;
import nz.co.blink.debit.helpers.RequestHandler;
import nz.co.blink.debit.helpers.ResponseHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -89,14 +90,16 @@ public Flux<BankMetadata> getMeta() throws BlinkServiceException {
* @throws BlinkServiceException thrown when an exception occurs
*/
public Flux<BankMetadata> getMeta(final String requestId) throws BlinkServiceException {
String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());

return getWebClientBuilder(correlationId)
return getWebClientBuilder(requestIdFinal)
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(null, clientRequest,
exchangeFunction))
.build()
.get()
.uri(METADATA_PATH.getValue())
.accept(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), correlationId))
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal))
.exchangeToFlux(ResponseHandler.handleResponseFlux(BankMetadata.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import nz.co.blink.debit.enums.BlinkDebitConstant;
import nz.co.blink.debit.exception.BlinkInvalidValueException;
import nz.co.blink.debit.exception.BlinkServiceException;
import nz.co.blink.debit.helpers.RequestHandler;
import nz.co.blink.debit.helpers.ResponseHandler;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -108,15 +109,17 @@ public Mono<AccessTokenResponse> generateAccessToken(final String requestId) thr
.grantType("client_credentials")
.build();

String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());

return getWebClientBuilder()
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(request, clientRequest,
exchangeFunction))
.build()
.post()
.uri(TOKEN_PATH.getValue())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), correlationId))
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal))
.bodyValue(request)
.exchangeToMono(ResponseHandler.handleResponseMono(AccessTokenResponse.class))
.transformDeferred(RetryOperator.of(retry));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import nz.co.blink.debit.exception.BlinkInvalidValueException;
import nz.co.blink.debit.exception.BlinkServiceException;
import nz.co.blink.debit.helpers.AccessTokenHandler;
import nz.co.blink.debit.helpers.RequestHandler;
import nz.co.blink.debit.helpers.ResponseHandler;
import nz.co.blink.debit.service.ValidationService;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -48,7 +49,7 @@

import java.util.UUID;

import static nz.co.blink.debit.enums.BlinkDebitConstant.INTERACTION_ID;
import static nz.co.blink.debit.enums.BlinkDebitConstant.IDEMPOTENCY_KEY;
import static nz.co.blink.debit.enums.BlinkDebitConstant.PAYMENTS_PATH;
import static nz.co.blink.debit.enums.BlinkDebitConstant.REQUEST_ID;

Expand Down Expand Up @@ -215,35 +216,37 @@ public Mono<Payment> getPayment(UUID paymentId, final String requestId) throws B
throw new BlinkInvalidValueException("Payment ID must not be null");
}

String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());

return getWebClientBuilder(correlationId)
return getWebClientBuilder(requestIdFinal)
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(null, clientRequest,
exchangeFunction))
.build()
.get()
.uri(uriBuilder -> uriBuilder
.path(PAYMENTS_PATH.getValue() + "/{paymentId}")
.build(paymentId))
.accept(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> {
httpHeaders.add(REQUEST_ID.getValue(), correlationId);
httpHeaders.add(INTERACTION_ID.getValue(), correlationId);
})
.headers(httpHeaders -> httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal))
.exchangeToMono(ResponseHandler.handleResponseMono(Payment.class));
}

private Mono<PaymentResponse> createPaymentMono(PaymentRequest request, String requestId)
throws BlinkServiceException {
String correlationId = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String requestIdFinal = StringUtils.defaultIfBlank(requestId, UUID.randomUUID().toString());
String idempotencyKey = UUID.randomUUID().toString();

return getWebClientBuilder(correlationId)
return getWebClientBuilder(requestIdFinal)
.filter((clientRequest, exchangeFunction) -> RequestHandler.logRequest(request, clientRequest,
exchangeFunction))
.build()
.post()
.uri(PAYMENTS_PATH.getValue())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.headers(httpHeaders -> {
httpHeaders.add(REQUEST_ID.getValue(), correlationId);
httpHeaders.add(INTERACTION_ID.getValue(), correlationId);
httpHeaders.add(REQUEST_ID.getValue(), requestIdFinal);
httpHeaders.add(IDEMPOTENCY_KEY.getValue(), idempotencyKey);
})
.bodyValue(request)
.exchangeToMono(ResponseHandler.handleResponseMono(PaymentResponse.class))
Expand Down
Loading