I'm trying to setup a test payment session on a Verifone p400 plus terminal from Adyen.
I'm following This guide using node and in my case "@adyen/api-library": "13.1.3"
.
The plan is to run the code in a alpine container, but during testing I'm on a mac.
I've downloaded the root cert and run openssl on it.
openssl x509 -outform der -in adyen-terminalfleet-test.pem -out adyen-terminalfleet-test.crt
I added the crt file to my keychain using security import adyen-terminalfleet-test.crt
, it seemed to work.
I created a shared key and put everything as envs.
Then I ran my code:
... (imports + load envs) ...
async function main() {
const config: Config = new Config();
config.merchantAccount = ADYEN_COMPANY_ID;
config.certificatePath = ADYEN_CERT_PATH; // full path to the .crt file (?)
config.terminalApiLocalEndpoint = 'https://192.168.1.199';
config.apiKey = ADYEN_API_KEY;
const client = new Client({ config });
client.setEnvironment('TEST');
const terminalLocalAPI = new TerminalLocalAPI(client);
const securityKey: SecurityKey = {
AdyenCryptoVersion: 1,
KeyIdentifier: ADYEN_ID,
KeyVersion: parseInt(ADYEN_VERSION),
Passphrase: ADYEN_PASS,
};
const terminalApiRequest: TerminalApiRequest = {
SaleToPOIRequest: {
MessageHeader: {
MessageCategory: MessageCategoryType.Payment,
MessageClass: MessageClassType.Service,
MessageType: MessageType.Request,
POIID: ADYEN_TERMINAL_ID,
},
PaymentRequest: {
PaymentTransaction: {
AmountsReq: {
Currency: 'SEK',
RequestedAmount: 142,
},
},
SaleData: {
SaleTransactionID: {
TimeStamp: Date.now().toString(),
TransactionID: '123456',
},
},
},
},
};
try {
const terminalApiResponse: TerminalApiResponse =
await terminalLocalAPI.request(terminalApiRequest, securityKey);
console.log('terminalApiResponse', terminalApiResponse);
} catch (err) {
console.error(err);
}
}
main();
The result I get from this is:
ApiException {
name: 'ApiException',
message: 'unable to get local issuer certificate',
statusCode: 500
}
If the cert path is pointing to the .pem file it does not work at all.
I'm getting the same responses under alpine linux as mac.
Any idea?
PS: When it comes to linux I installed the crt using this: (Still no luck)
RUN apk add ca-certificates
COPY adyen-terminalfleet-test.crt /usr/local/share/ca-certificates/adyen-terminalfleet-test.crt
RUN update-ca-certificates
When setting the certificatePath to the pem file I get:
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined ..