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

feat: [CHK-2860] Update gdi check url to redirect to ecommerce-fe #498

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
4 changes: 4 additions & 0 deletions helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ microservice-chart:
NODO_HOSTNAME: https://api.dev.platform.pagopa.it
ECS_SERVICE_NAME: pagopa-ecommerce-transactions-service-beta
CHECKOUT_BASE_PATH: "https://pagopa-d-checkout-cdn-endpoint.azureedge.net"
CHECKOUT_NPG_GDI_URL: "https://pagopa-d-checkout-cdn-endpoint.azureedge.net/ecommerce-fe/gdi-check"
CHECKOUT_OUTCOME_URL: "https://pagopa-d-checkout-cdn-endpoint.azureedge.net/esito"
TRANSACTION_EXPIRATION_QUEUE_NAME: pagopa-d-weu-ecommerce-transactions-expiration-queue-b
TRANSACTION_CLOSE_PAYMENT_RETRY_QUEUE_NAME: pagopa-d-weu-ecommerce-transactions-close-payment-retry-queue-b
TRANSACTION_CLOSE_PAYMENT_QUEUE_NAME: pagopa-d-weu-ecommerce-transactions-close-payment-queue-b
Expand Down Expand Up @@ -164,6 +166,8 @@ microservice-chart:
NPG_AUTHORIZATION_REQUEST_TIMEOUT_SECONDS: "60"
TRANSACTION_DOCUMENT_TTL: "600"
CHECKOUT_BASE_PATH: "https://dev.checkout.pagopa.it"
CHECKOUT_NPG_GDI_URL: "https://dev.checkout.pagopa.it/ecommerce-fe/gdi-check"
CHECKOUT_OUTCOME_URL: "https://dev.checkout.pagopa.it/esito"
ECOMMERCE_EVENT_VERSION: "V1"
SEND_PAYMENT_RESULT_FOR_TX_EXPIRED_ENABLED: "true"
SESSION_URL_BASEPATH: "https://dev.checkout.pagopa.it"
Expand Down
2 changes: 2 additions & 0 deletions helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ microservice-chart:
NPG_AUTHORIZATION_REQUEST_TIMEOUT_SECONDS: "60"
TRANSACTION_DOCUMENT_TTL: "600"
CHECKOUT_BASE_PATH: "https://checkout.pagopa.it"
CHECKOUT_NPG_GDI_URL: "https://checkout.pagopa.it/ecommerce-fe/gdi-check"
CHECKOUT_OUTCOME_URL: "https://checkout.pagopa.it/esito"
ECOMMERCE_EVENT_VERSION: "V1"
SEND_PAYMENT_RESULT_FOR_TX_EXPIRED_ENABLED: "true"
SESSION_URL_BASEPATH: "https://checkout.pagopa.it"
Expand Down
2 changes: 2 additions & 0 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ microservice-chart:
NPG_AUTHORIZATION_REQUEST_TIMEOUT_SECONDS: "60"
TRANSACTION_DOCUMENT_TTL: "600"
CHECKOUT_BASE_PATH: "https://uat.checkout.pagopa.it"
CHECKOUT_NPG_GDI_URL: "https://uat.checkout.pagopa.it/ecommerce-fe/gdi-check"
CHECKOUT_OUTCOME_URL: "https://uat.checkout.pagopa.it/esito"
ECOMMERCE_EVENT_VERSION: "V1"
SEND_PAYMENT_RESULT_FOR_TX_EXPIRED_ENABLED: "true"
SESSION_URL_BASEPATH: "https://uat.checkout.pagopa.it"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.vavr.control.Either;
import it.pagopa.ecommerce.commons.client.NpgClient;
import it.pagopa.ecommerce.commons.domain.TransactionId;
import it.pagopa.ecommerce.commons.generated.npg.v1.dto.FieldsDto;
import it.pagopa.ecommerce.commons.generated.npg.v1.dto.StateResponseDto;
import it.pagopa.generated.ecommerce.redirect.v1.dto.RedirectUrlRequestDto;
Expand All @@ -27,23 +28,27 @@
@Slf4j
public abstract class TransactionRequestAuthorizationHandlerCommon
implements CommandHandler<TransactionRequestAuthorizationCommand, Mono<RequestAuthorizationResponseDto>> {
private static final String CHECKOUT_GDI_CHECK_PATH = "/gdi-check#gdiIframeUrl=";
private static final String WALLET_GDI_CHECK_PATH = "/ecommerce-fe/gdi-check#gdiIframeUrl=";
private static final String CHECKOUT_ESITO_PATH = "/esito";

private final PaymentGatewayClient paymentGatewayClient;

private final String checkoutBasePath;
private final String checkoutNpgGdiUrl;
private final String checkoutOutcomeUrl;

private final TransactionTemplateWrapper transactionTemplateWrapper;

protected TransactionRequestAuthorizationHandlerCommon(
PaymentGatewayClient paymentGatewayClient,
String checkoutBasePath,
String checkoutNpgGdiUrl,
String checkoutOutcomeUrl,
TransactionTemplateWrapper transactionTemplateWrapper
) {
this.paymentGatewayClient = paymentGatewayClient;
this.checkoutBasePath = checkoutBasePath;
this.checkoutNpgGdiUrl = checkoutNpgGdiUrl;
this.checkoutOutcomeUrl = checkoutOutcomeUrl;
this.transactionTemplateWrapper = transactionTemplateWrapper;
}

Expand Down Expand Up @@ -316,8 +321,13 @@ private Mono<AuthorizationOutput> invokeNpgConfirmPayment(
).append(base64redirectionUrl).append("&clientId=IO")
.append("&transactionId=")
.append(authorizationData.transactionId().value())
: new StringBuilder(CHECKOUT_GDI_CHECK_PATH)
.append(base64redirectionUrl);
: new StringBuilder(
formatGdiCheckUrl(
base64redirectionUrl,
"CHECKOUT",
authorizationData.transactionId()
)
);

yield URI.create(checkoutBasePath)
.resolve(
Expand All @@ -336,7 +346,7 @@ private Mono<AuthorizationOutput> invokeNpgConfirmPayment(
yield npgResponse.getUrl();
}
case PAYMENT_COMPLETE -> URI.create(checkoutBasePath)
.resolve(CHECKOUT_ESITO_PATH)
.resolve(checkoutOutcomeUrl)
.toString();
default -> throw new BadGatewayException(
"Invalid NPG confirm payment state response: " + npgResponse.getState(),
Expand Down Expand Up @@ -433,4 +443,14 @@ protected Mono<AuthorizationOutput> redirectionAuthRequestPipeline(
)
);
}

private String formatGdiCheckUrl(
String iframeUrl,
String clientId,
TransactionId transactionId
) {
return this.checkoutNpgGdiUrl.concat("#gdiIframeUrl=").concat(iframeUrl)
.concat("&clientId=").concat(clientId)
.concat("&transactionId=").concat(transactionId.value());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,16 @@ public TransactionRequestAuthorizationHandler(
TransactionsEventStoreRepository<TransactionAuthorizationRequestData> transactionEventStoreRepository,
TransactionsUtils transactionsUtils,
@Value("${checkout.basePath}") String checkoutBasePath,
@Value("${checkout.npg.gdi.url}") String checkoutNpgGdiUrl,
@Value("${checkout.outcome.url}") String checkoutOutcomeUrl,
EcommercePaymentMethodsClient paymentMethodsClient,
TransactionTemplateWrapper transactionTemplateWrapper
) {
super(
paymentGatewayClient,
checkoutBasePath,
checkoutNpgGdiUrl,
checkoutOutcomeUrl,
transactionTemplateWrapper
);
this.transactionEventStoreRepository = transactionEventStoreRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public TransactionRequestAuthorizationHandler(
TransactionsEventStoreRepository<TransactionAuthorizationRequestData> transactionEventStoreRepository,
TransactionsUtils transactionsUtils,
@Value("${checkout.basePath}") String checkoutBasePath,
@Value("${checkout.npg.gdi.url}") String checkoutNpgGdiUrl,
@Value("${checkout.outcome.url}") String checkoutOutcomeUrl,
EcommercePaymentMethodsClient paymentMethodsClient,
TransactionTemplateWrapper transactionTemplateWrapper,
@Qualifier(
Expand All @@ -91,6 +93,8 @@ public TransactionRequestAuthorizationHandler(
super(
paymentGatewayClient,
checkoutBasePath,
checkoutNpgGdiUrl,
checkoutOutcomeUrl,
transactionTemplateWrapper
);
this.transactionEventStoreRepository = transactionEventStoreRepository;
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ warmup.request.newTransaction.noticeCodePrefix=${WARMUP_REQUEST_NEW_TRANSACTION_


checkout.basePath=${CHECKOUT_BASE_PATH}
checkout.npg.gdi.url=${CHECKOUT_NPG_GDI_URL}
checkout.outcome.url=${CHECKOUT_OUTCOME_URL}
npg.uri=${NPG_URI}
npg.readTimeout=${NPG_READ_TIMEOUT}
npg.connectionTimeout=${NPG_CONNECTION_TIMEOUT}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
@ExtendWith(MockitoExtension.class)
class TransactionRequestAuthorizationHandlerTest {

private static final String NPG_CHECKOUT_ESITO_PATH = "/esito";
private static final String CHECKOUT_NPG_GDI_PATH = "http://checkout.pagopa.it/ecommerce-fe/gdi-check";
private static final String CHECKOUT_OUTCOME_PATH = "http://checkout.pagopa.it/esito";
private static final String NPG_URL_IFRAME = "http://iframe";
private static final String NPG_GDI_CHECK_PATH = "/gdi-check#gdiIframeUrl=";
private static final String NPG_GDI_FRAGMENT = "#gdiIframeUrl=";
private static final String NPG_WALLET_GDI_CHECK_PATH = "/ecommerce-fe/gdi-check#gdiIframeUrl=";
private TransactionRequestAuthorizationHandler requestAuthorizationHandler;

Expand Down Expand Up @@ -117,6 +118,8 @@ private void init() {
transactionEventStoreRepository,
transactionsUtils,
CHECKOUT_BASE_PATH,
CHECKOUT_NPG_GDI_PATH,
CHECKOUT_OUTCOME_PATH,
paymentMethodsClient,
transactionTemplateWrapper
);
Expand Down Expand Up @@ -411,7 +414,7 @@ void shouldSaveAuthorizationEventNpgCardsPaymentComplete() {

RequestAuthorizationResponseDto responseDto = new RequestAuthorizationResponseDto()
.authorizationRequestId(((CardsAuthRequestDetailsDto) authorizationData.authDetails()).getOrderId())
.authorizationUrl(NPG_CHECKOUT_ESITO_PATH);
.authorizationUrl(CHECKOUT_OUTCOME_PATH);
/* test */
StepVerifier.create(requestAuthorizationHandler.handle(requestAuthorizationCommand))
.expectNext(responseDto)
Expand Down Expand Up @@ -517,10 +520,10 @@ void shouldSaveAuthorizationEventGdiVerification() {
RequestAuthorizationResponseDto responseDto = new RequestAuthorizationResponseDto()
.authorizationRequestId(((CardsAuthRequestDetailsDto) authorizationData.authDetails()).getOrderId())
.authorizationUrl(
NPG_GDI_CHECK_PATH + Base64.encodeBase64URLSafeString(
CHECKOUT_NPG_GDI_PATH + NPG_GDI_FRAGMENT + Base64.encodeBase64URLSafeString(
NPG_URL_IFRAME
.getBytes(StandardCharsets.UTF_8)
)
).concat("&clientId=CHECKOUT&transactionId=").concat(transaction.getTransactionId().value())
);
/* test */
StepVerifier.create(requestAuthorizationHandler.handle(requestAuthorizationCommand))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@
@ExtendWith(MockitoExtension.class)
class TransactionRequestAuthorizationHandlerTest {

private static final String NPG_CHECKOUT_ESITO_PATH = "/esito";
private static final String CHECKOUT_BASE_PATH = "checkoutUri";
private static final String CHECKOUT_NPG_GDI_PATH = "http://checkout.pagopa.it/ecommerce-fe/gdi-check";
private static final String CHECKOUT_OUTCOME_PATH = "http://checkout.pagopa.it/esito";
private static final String NPG_URL_IFRAME = "http://iframe";
private static final String NPG_GDI_CHECK_PATH = "/gdi-check#gdiIframeUrl=";
private static final String NPG_GDI_FRAGMENT = "#gdiIframeUrl=";
private static final String NPG_WALLET_GDI_CHECK_PATH = "/ecommerce-fe/gdi-check#gdiIframeUrl=";
private it.pagopa.transactions.commands.handlers.v2.TransactionRequestAuthorizationHandler requestAuthorizationHandler;

Expand Down Expand Up @@ -102,7 +104,6 @@ class TransactionRequestAuthorizationHandlerTest {
@Captor
private ArgumentCaptor<Duration> durationArgumentCaptor;

private static final String CHECKOUT_BASE_PATH = "checkoutUri";
private static final Set<CardAuthRequestDetailsDto.BrandEnum> testedCardBrands = new HashSet<>();

private static boolean cardsTested = false;
Expand Down Expand Up @@ -149,6 +150,8 @@ private void init() {
transactionEventStoreRepository,
transactionsUtils,
CHECKOUT_BASE_PATH,
CHECKOUT_NPG_GDI_PATH,
CHECKOUT_OUTCOME_PATH,
paymentMethodsClient,
transactionTemplateWrapper,
transactionAuthorizationRequestedQueueAsyncClient,
Expand Down Expand Up @@ -599,7 +602,7 @@ void shouldSaveAuthorizationEventNpgCardsPaymentComplete() {

RequestAuthorizationResponseDto responseDto = new RequestAuthorizationResponseDto()
.authorizationRequestId(((CardsAuthRequestDetailsDto) authorizationData.authDetails()).getOrderId())
.authorizationUrl(NPG_CHECKOUT_ESITO_PATH);
.authorizationUrl(CHECKOUT_OUTCOME_PATH);
/* test */
StepVerifier.create(requestAuthorizationHandler.handle(requestAuthorizationCommand))
.expectNext(responseDto)
Expand Down Expand Up @@ -738,10 +741,10 @@ void shouldSaveAuthorizationEventGdiVerification() {
RequestAuthorizationResponseDto responseDto = new RequestAuthorizationResponseDto()
.authorizationRequestId(((CardsAuthRequestDetailsDto) authorizationData.authDetails()).getOrderId())
.authorizationUrl(
NPG_GDI_CHECK_PATH + Base64.encodeBase64URLSafeString(
CHECKOUT_NPG_GDI_PATH + NPG_GDI_FRAGMENT + Base64.encodeBase64URLSafeString(
NPG_URL_IFRAME
.getBytes(StandardCharsets.UTF_8)
)
).concat("&clientId=CHECKOUT&transactionId=").concat(transaction.getTransactionId().value())
);
Hooks.onOperatorDebug();
/* test */
Expand Down Expand Up @@ -1927,7 +1930,7 @@ void shouldSaveAuthorizationEventNpgCardsPaymentCompleteSavingReceivedSessionIdI

RequestAuthorizationResponseDto responseDto = new RequestAuthorizationResponseDto()
.authorizationRequestId(((CardsAuthRequestDetailsDto) authorizationData.authDetails()).getOrderId())
.authorizationUrl(NPG_CHECKOUT_ESITO_PATH);
.authorizationUrl(CHECKOUT_OUTCOME_PATH);

/* test */
StepVerifier.create(requestAuthorizationHandler.handle(requestAuthorizationCommand))
Expand Down Expand Up @@ -2066,10 +2069,10 @@ void shouldSaveAuthorizationEventGdiVerificationSavingReceivedSessionIdInEvent()
RequestAuthorizationResponseDto responseDto = new RequestAuthorizationResponseDto()
.authorizationRequestId(((CardsAuthRequestDetailsDto) authorizationData.authDetails()).getOrderId())
.authorizationUrl(
NPG_GDI_CHECK_PATH + Base64.encodeBase64URLSafeString(
CHECKOUT_NPG_GDI_PATH + NPG_GDI_FRAGMENT + Base64.encodeBase64URLSafeString(
NPG_URL_IFRAME
.getBytes(StandardCharsets.UTF_8)
)
).concat("&clientId=CHECKOUT&transactionId=").concat(transaction.getTransactionId().value())
);
/* test */
StepVerifier.create(requestAuthorizationHandler.handle(requestAuthorizationCommand))
Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/application-tests.properties
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ confidentialDataManager.personalDataVault.apiBasePath=http://personal-data-vault


checkout.basePath=http://localhost/checkout
checkout.npg.gdi.url=${CHECKOUT_NPG_GDI_URL}
checkout.outcome.url=${CHECKOUT_OUTCOME_URL}
npg.uri=http://localhost/npg
npg.readTimeout=10000
npg.connectionTimeout=10000
Expand Down
Loading