-
Notifications
You must be signed in to change notification settings - Fork 3
/
dev-server.js
72 lines (66 loc) · 2.65 KB
/
dev-server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Development server built as an express application,
* able to run frontend (thanks to parcel-bundler) and an API server with json response example.
*
* Note: to run the development server must be set CHECKOUT_PAGOPA_APIM_HOST=http://localhost:1234
*/
const express = require("express");
const app = express();
app.get("/checkout/payments/v1/payment-requests/:rptId", (_, res) => {
// test scenario for an error message
if (_.params.rptId == "00000000000000000000000000000") {
res.status(500).send("Error!");
} else if (_.params.rptId == "00000000000000000000000000009") {
res.status(400).send({ detail: "PAA_PAGAMENTO_DUPLICATO" });
} else if (_.params.rptId == "00000000000000000000000000008") {
res.status(400).send({ detail: "PAA_PAGAMENTO_IN_CORSO" });
} else if (_.params.rptId == "00000000000000000000000000007") {
res.status(400).send({ detail: "PAA_PAGAMENTO_SCADUTO" });
} else if (_.params.rptId == "00000000000000000000000000006") {
res.status(400).send({ detail: "PPT_DOMINIO_SCONOSCIUTO" });
} else if (_.params.rptId == "00000000000000000000000000005") {
res.status(400).send({ detail: "PPT_SINTASSI_EXTRAXSD" });
} else if (_.params.rptId == "00000000000000000000000000004") {
res.status(400).send({ detail: "UNKNOWN_ERROR" });
} else if (_.params.rptId == "00000000000000000000000000010") {
res.status(400).send({ detail: "PPT_PAGAMENTO_DUPLICATO" });
} else if (_.params.rptId == "00000000000000000000000000011") {
res.status(400).send({ detail: "PPT_PAGAMENTO_IN_CORSO" });
} else {
res.send({
importoSingoloVersamento: 1100,
codiceContestoPagamento: "6f69d150541e11ebb70c7b05c53756dd",
ibanAccredito: "IT21Q0760101600000000546200",
causaleVersamento: "Retta asilo [demo]",
enteBeneficiario: {
identificativoUnivocoBeneficiario: "01199250158",
denominazioneBeneficiario: "Comune di Milano",
},
});
}
});
app.post("/payportal/v1/payment-activations", (_, res) => {
if (_.body.rptId == "00000000000000000000000000099") {
res.status(400).send({ detail: "PAA_PAGAMENTO_DUPLICATO" });
} else {
res.send({
codiceContestoPagamento: "6f69d150541e11ebb70c7b05c53756dd",
ibanAccredito: "IT21Q0760101600000000546200",
causaleVersamento: "Retta asilo [demo]",
enteBeneficiario: {
identificativoUnivocoBeneficiario: "01199250158",
denominazioneBeneficiario: "Comune di Milano",
},
importoSingoloVersamento: 1100,
});
}
});
app.get(
"/payportal/v1/payment-activations/:codiceContestoPagamento",
(_, res) => {
res.send({
idPagamento: "123455",
});
}
);
app.listen(Number(8080));