Skip to content

Commit

Permalink
Feat [CHK-3618] Added support for error 4xx on close payment (#47)
Browse files Browse the repository at this point in the history
* init

* updated v2

* updated test suites

* fixed tests

* Update setup-env.yml

* Update pagopa-code-review-pipelines.yml

* Update pagopa-deploy-pipelines.yml

* Update pagopa-deploy-pipelines.yml

* minor fix

* minor fix

* minor fix

* multiple bug fixes

* multiple bug fixes

* fixed tests

* finalized

* fix

* fix: set v2 env variables

* fix: pipeline variables

* fix pipeline

* Update pagopa-deploy-pipelines.yml

* fix logic

* Update pagopa-code-review-pipelines.yml

* Update pagopa-code-review-pipelines.yml

* added fix

* fix: exit from polling on error 4xx

* updated state name

* updated logic to handle not authorized transaction

* renamed ecommerceIOClientWithPollingV2

* minor edit

* Update package.json

* Update pagopa-code-review-pipelines.yml

* update name of createIOClientV2

* Update package.json

---------

Co-authored-by: Pietro Tota <[email protected]>
  • Loading branch information
EmanueleBVtech and pietro-tota authored Dec 18, 2024
1 parent 3c4b430 commit f15eea9
Show file tree
Hide file tree
Showing 18 changed files with 684 additions and 360 deletions.
9 changes: 7 additions & 2 deletions .devops/azure-templates/setup-env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ parameters:
type: string
default: ''

- name: 'io_api_path'
- name: "checkout_api_v2_path"
type: string
default: ""

- name: 'io_api_v2_path'
type: string
default: ''

Expand Down Expand Up @@ -48,7 +52,8 @@ steps:
ECOMMERCE_API_TIMEOUT=${{ parameters.api_timeout }} \
ECOMMERCE_API_HOST=${{ parameters.api_host }} \
ECOMMERCE_CHECKOUT_API_PATH=${{ parameters.checkout_api_path }} \
ECOMMERCE_IO_API_PATH=${{ parameters.io_api_path }} \
ECOMMERCE_CHECKOUT_API_V2_PATH=${{ parameters.checkout_api_v2_path }} \
ECOMMERCE_IO_API_V2_PATH=${{ parameters.io_api_v2_path }} \
ECOMMERCE_GDI_CHECK_TIMEOUT=${{ parameters.gdi_check_timeout }} \
ECOMMERCE_NPG_SDK_URL=${{ parameters.npg_sdk_url }} \
ECOMMERCE_IO_CLIENT_REDIRECT_OUTCOME_PATH=${{ parameters.io_client_redirect_outcome_path }} \
Expand Down
5 changes: 3 additions & 2 deletions .devops/pagopa-code-review-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ stages:
env: 'DEV'
api_timeout: 10000
api_host: 'http://localhost:1234'
checkout_api_path: '/ecommerce/checkout/v1'
io_api_path: '/ecommerce/webview/v1'
checkout_api_path: "/ecommerce/checkout/v1"
checkout_api_v2_path: "/ecommerce/checkout/v2"
io_api_v2_path: "/ecommerce/webview/v2"
npg_sdk_url: 'https://stg-ta.nexigroup.com/monetaweb/resources/hfsdk.js'
gdi_check_timeout: 12000
io_client_redirect_outcome_path: 'https://api.dev.platform.pagopa.it/ecommerce/io-outcomes/v1/transactions'
Expand Down
17 changes: 10 additions & 7 deletions .devops/pagopa-deploy-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ stages:
env: 'DEV'
api_timeout: 10000
api_host: 'https://api.dev.platform.pagopa.it'
checkout_api_path: '/ecommerce/checkout/v1'
io_api_path: '/ecommerce/webview/v1'
checkout_api_path: "/ecommerce/checkout/v1"
checkout_api_v2_path: "/ecommerce/checkout/v2"
io_api_v2_path: "/ecommerce/webview/v2"
npg_sdk_url: 'https://stg-ta.nexigroup.com/monetaweb/resources/hfsdk.js'
gdi_check_timeout: 20000
io_client_redirect_outcome_path: 'https://api.dev.platform.pagopa.it/ecommerce/io-outcomes/v1/transactions'
Expand Down Expand Up @@ -197,8 +198,9 @@ stages:
env: 'UAT'
api_timeout: 10000
api_host: 'https://api.uat.platform.pagopa.it'
checkout_api_path: '/ecommerce/checkout/v1'
io_api_path: '/ecommerce/webview/v1'
checkout_api_path: "/ecommerce/checkout/v1"
checkout_api_v2_path: "/ecommerce/checkout/v2"
io_api_v2_path: "/ecommerce/webview/v2"
npg_sdk_url: 'https://stg-ta.nexigroup.com/monetaweb/resources/hfsdk.js'
gdi_check_timeout: 20000
io_client_redirect_outcome_path: 'https://api.uat.platform.pagopa.it/ecommerce/io-outcomes/v1/transactions'
Expand Down Expand Up @@ -290,8 +292,9 @@ stages:
env: 'PROD'
api_timeout: 10000
api_host: 'https://api.platform.pagopa.it'
checkout_api_path: '/ecommerce/checkout/v1'
io_api_path: '/ecommerce/webview/v1'
checkout_api_path: "/ecommerce/checkout/v1"
checkout_api_v2_path: "/ecommerce/checkout/v2"
io_api_v2_path: "/ecommerce/webview/v2"
npg_sdk_url: 'https://xpay.nexigroup.com/monetaweb/resources/hfsdk.js'
gdi_check_timeout: 20000
io_client_redirect_outcome_path: 'https://api.platform.pagopa.it/ecommerce/io-outcomes/v1/transactions'
Expand Down Expand Up @@ -344,4 +347,4 @@ stages:
azureSubscription: 'PROD-PAGOPA-SERVICE-CONN'
scriptLocation: inlineScript
inlineScript: |
az cdn endpoint purge -g pagopa-p-checkout-fe-rg -n pagopa-p-checkout-cdn-endpoint --profile-name pagopa-p-checkout-cdn-profile --content-paths "/*"
az cdn endpoint purge -g pagopa-p-checkout-fe-rg -n pagopa-p-checkout-cdn-endpoint --profile-name pagopa-p-checkout-cdn-profile --content-paths "/*"
3 changes: 2 additions & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ ECOMMERCE_ENV=develop
ECOMMERCE_API_TIMEOUT=10000
ECOMMERCE_API_HOST=http://localhost:1234
ECOMMERCE_CHECKOUT_API_PATH=/ecommerce/checkout/v1
ECOMMERCE_IO_API_PATH=/ecommerce/webview/v1
ECOMMERCE_CHECKOUT_API_V2_PATH=/ecommerce/checkout/v2
ECOMMERCE_IO_API_V2_PATH=/ecommerce/webview/v2
ECOMMERCE_GDI_CHECK_TIMEOUT=12000
ECOMMERCE_NPG_SDK_URL=https://stg-ta.nexigroup.com/monetaweb/resources/hfsdk.js
ECOMMERCE_IO_CLIENT_REDIRECT_OUTCOME_PATH=http://localhost:1234/ecommerce/io-outcomes/v1/transactions
Expand Down
9 changes: 6 additions & 3 deletions .proxyrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ const {createProxyMiddleware} = require("http-proxy-middleware");
const apiHost = "http://127.0.0.1:8080";
const apiHostIO = "http://127.0.0.1:8082";
const ecommerceBasepathV1 = "/ecommerce/checkout/v1";
const ecommerceIOBasepathV1 = "/ecommerce/webview/v1";
const ecommerceBasepathV2 = "/ecommerce/checkout/v2";
const ecommerceIOBasepathV2 = "/ecommerce/webview/v2";

module.exports = function (app) {
app.use(createProxyMiddleware(ecommerceBasepathV1, {
target: apiHost,
}));

app.use(createProxyMiddleware(ecommerceIOBasepathV1, {
app.use(createProxyMiddleware(ecommerceBasepathV2, {
target: apiHost,
}));
app.use(createProxyMiddleware(ecommerceIOBasepathV2, {
target: apiHostIO,
}));

Expand Down
82 changes: 42 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ This repository contain webviews used for ecommerce payments flow (checkout-App

### Built With

* [Bootstrap](https://getbootstrap.com)
* [JQuery](https://jquery.com)
* [Parcel](https://parceljs.org)
* [Typescript](https://www.typescriptlang.org)
* [Azure Pipeline](https://azure.microsoft.com)
- [Bootstrap](https://getbootstrap.com)
- [JQuery](https://jquery.com)
- [Parcel](https://parceljs.org)
- [Typescript](https://www.typescriptlang.org)
- [Azure Pipeline](https://azure.microsoft.com)

## Getting Started

Expand Down Expand Up @@ -50,44 +50,46 @@ In order to build and run this project are required:
### Usage

In order to run the application on a local dev server with mock API responses:
- ```sh
yarn dev
```
the application is available at http://localhost:1234

Test use cases:
- ```sh
yarn dev
```
the application is available at http://localhost:1234

Test use cases:

- *CHECKOUT*
1. start checkout mock [pagopa-checkout-be-mock](https://github.com/pagopa/pagopa-checkout-be-mock)
2. open on browser http://localhost:1234/ecommerce-fe/esito#clientId=CHECKOUT&sessionToken=test&transactionId=1234
- _CHECKOUT_

- *APP IO*
1. start script ```yarn start-io-mock``` on other terminal
2. open on browser http://localhost:1234/ecommerce-fe/esito#clientId=IO&sessionToken=test&transactionId=1234
1. start checkout mock [pagopa-checkout-be-mock](https://github.com/pagopa/pagopa-checkout-be-mock)
2. open on browser http://localhost:1234/ecommerce-fe/esito#clientId=CHECKOUT&sessionToken=test&transactionId=1234

- _APP IO_
1. start script `yarn start-io-mock` on other terminal
2. open on browser http://localhost:1234/ecommerce-fe/esito#clientId=IO&sessionToken=test&transactionId=1234

## IO Mock outcome result
The ecommerce transaction get transaction endpoint `/checkout/webview/v1/transactions/:transactionId` is driven by the following mockFlow values:

| MOCK FLOW | Transaction Id Suffix | OUTCOME |
|----------------------------------------------------|-----------------------|----------------------|
| NOTIFIED_OK | other | SUCCESS (0) |
| NOTIFICATION_REQUESTED - Outcome OK | 61 | SUCCESS (0) |
| NOTIFICATION_REQUESTED - Outcome KO | 62 | PSP_ERROR (25) |
| NOTIFICATION_ERROR - Outcome OK | 63 | SUCCESS (0) |
| NOTIFICATION_ERROR - Outcome KO | 64 | PSP_ERROR (25) |
| NOTIFIED_KO | 65 | PSP_ERROR (25) |
| REFUNDED | 66 | PSP_ERROR (25) |
| REFUND_REQUESTED | 67 | GENERIC_ERROR (1) |
| REFUND_ERROR | 68 | GENERIC_ERROR (1) |
| EXPIRED_NOT_AUTHORIZED | 69 | TIMEOUT (4) |
| CANCELED | 70 | CANCELED_BY_USER (8) |
| CANCELLATION_EXPIRED | 71 | CANCELED_BY_USER (8) |
| CLOSURE_ERROR - NPG EXECUTED | 72 | GENERIC_ERROR (1) |
| CLOSURE_REQUESTED - NPG CANCELED | 73 | CANCELED_BY_USER (8) |
| AUTHORIZATION_COMPLETED - NPG AUTHORIZED | 74 | PSP_ERROR (25) |
| UNAUTHORIZED - NPG DENIED_BY_RISK | 75 | AUTH_ERROR (2) |
| CLOSED - Outcome NOT_RECEIVED | 76 | TAKE_IN_CHARGE (17) |
| CLOSED - Other | 77 | GENERIC_ERROR (1) |
| EXPIRED - Outcome OK | 78 | SUCCESS (0) |
| AUTHORIZATION_REQUESTED | 79 | TAKE_IN_CHARGE (17) |

The ecommerce transaction get transaction endpoint `/checkout/webview/v2/transactions/:transactionId` is driven by the following mockFlow values:

| MOCK FLOW | Transaction Id Suffix | OUTCOME |
| ---------------------------------------- | --------------------- | -------------------- |
| NOTIFIED_OK | other | SUCCESS (0) |
| NOTIFICATION_REQUESTED - Outcome OK | 61 | SUCCESS (0) |
| NOTIFICATION_REQUESTED - Outcome KO | 62 | PSP_ERROR (25) |
| NOTIFICATION_ERROR - Outcome OK | 63 | SUCCESS (0) |
| NOTIFICATION_ERROR - Outcome KO | 64 | PSP_ERROR (25) |
| NOTIFIED_KO | 65 | PSP_ERROR (25) |
| REFUNDED | 66 | PSP_ERROR (25) |
| REFUND_REQUESTED | 67 | GENERIC_ERROR (1) |
| REFUND_ERROR | 68 | GENERIC_ERROR (1) |
| EXPIRED_NOT_AUTHORIZED | 69 | TIMEOUT (4) |
| CANCELED | 70 | CANCELED_BY_USER (8) |
| CANCELLATION_EXPIRED | 71 | CANCELED_BY_USER (8) |
| CLOSURE_ERROR - NPG EXECUTED | 72 | GENERIC_ERROR (1) |
| CLOSURE_REQUESTED - NPG CANCELED | 73 | CANCELED_BY_USER (8) |
| AUTHORIZATION_COMPLETED - NPG AUTHORIZED | 74 | PSP_ERROR (25) |
| UNAUTHORIZED - NPG DENIED_BY_RISK | 75 | AUTH_ERROR (2) |
| CLOSED - Outcome NOT_RECEIVED | 76 | TAKE_IN_CHARGE (17) |
| CLOSED - Other | 77 | GENERIC_ERROR (1) |
| EXPIRED - Outcome OK | 78 | SUCCESS (0) |
| AUTHORIZATION_REQUESTED | 79 | TAKE_IN_CHARGE (17) |
Loading

0 comments on commit f15eea9

Please sign in to comment.