mirror of
https://github.com/jlengrand/adyen-node-api-library.git
synced 2026-03-10 08:01:20 +00:00
return undefined response item
This commit is contained in:
@@ -32,6 +32,8 @@ import {
|
|||||||
TerminalApiSecuredResponse
|
TerminalApiSecuredResponse
|
||||||
} from "../typings/terminal/models";
|
} from "../typings/terminal/models";
|
||||||
import NexoCryptoException from "./exception/nexoCryptoException";
|
import NexoCryptoException from "./exception/nexoCryptoException";
|
||||||
|
import HttpClientException from "../httpClient/httpClientException";
|
||||||
|
import apiException from "./exception/apiException";
|
||||||
|
|
||||||
class TerminalLocalAPI extends ApiKeyAuthenticatedService {
|
class TerminalLocalAPI extends ApiKeyAuthenticatedService {
|
||||||
private readonly localRequest: LocalRequest;
|
private readonly localRequest: LocalRequest;
|
||||||
@@ -58,16 +60,13 @@ class TerminalLocalAPI extends ApiKeyAuthenticatedService {
|
|||||||
SaleToPOIRequest: saleToPoiSecuredMessage,
|
SaleToPOIRequest: saleToPoiSecuredMessage,
|
||||||
}, "TerminalApiSecuredRequest");
|
}, "TerminalApiSecuredRequest");
|
||||||
|
|
||||||
const jsonResponse = await getJsonResponse<TerminalApiSecuredRequest, TerminalApiResponse>(
|
// Catch Exceptions and an empty jsonResponse (i.e. Abort Request)
|
||||||
this.localRequest,
|
|
||||||
securedPaymentRequest
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log("jsonresponse type" + typeof jsonResponse);
|
|
||||||
console.log(jsonResponse);
|
|
||||||
|
|
||||||
// Catch an empty jsonResponse (i.e. Abort Request)
|
|
||||||
try {
|
try {
|
||||||
|
const jsonResponse = await getJsonResponse<TerminalApiSecuredRequest, TerminalApiResponse>(
|
||||||
|
this.localRequest,
|
||||||
|
securedPaymentRequest
|
||||||
|
);
|
||||||
|
|
||||||
const terminalApiSecuredResponse: TerminalApiSecuredResponse =
|
const terminalApiSecuredResponse: TerminalApiSecuredResponse =
|
||||||
ObjectSerializer.deserialize(jsonResponse, "TerminalApiSecuredResponse");
|
ObjectSerializer.deserialize(jsonResponse, "TerminalApiSecuredResponse");
|
||||||
|
|
||||||
@@ -78,11 +77,10 @@ class TerminalLocalAPI extends ApiKeyAuthenticatedService {
|
|||||||
return ObjectSerializer.deserialize(JSON.parse(response), "TerminalApiResponse");
|
return ObjectSerializer.deserialize(JSON.parse(response), "TerminalApiResponse");
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if(e instanceof NexoCryptoException){
|
if(e instanceof NexoCryptoException || e instanceof HttpClientException || e instanceof apiException) {
|
||||||
throw e;
|
throw e;
|
||||||
} else {
|
} else {
|
||||||
const requestType = terminalApiRequest.SaleToPOIRequest.MessageHeader.MessageCategory;
|
return new TerminalApiResponse();
|
||||||
throw new Error(`Request of type ${requestType} has no response!`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user