You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug:
We are encountering an error when trying to make a payment using local communication with the adyen-node-api-library. The error message indicates that the payment request is missing, even though we are sending the payment request in the payload which is encrypted in Nexoblob.
Thanks for reaching out here and apologies for the delayed response. Did you try setting the DeviceID parameter in the MessageHeader? This is required for the nexo request.
Describe the bug:
We are encountering an error when trying to make a payment using local communication with the adyen-node-api-library. The error message indicates that the payment request is missing, even though we are sending the payment request in the payload which is encrypted in Nexoblob.
Error Message received:
To Reproduce:
PAYLOAD:
{
"MessageHeader": {
"MessageCategory": "Payment",
"MessageClass": "Service",
"MessageType": "Request",
"POIID": "123",
"ProtocolVersion": "3.0",
"SaleID": "1144506",
"ServiceID": "1144506"
},
"NexoBlob": "c0HqQlaWEjvG+SPutg2lDI7SR8oe0lygKSV9eLn5YrGKkl2DMxkdAeNk6zdQT2o+2cGx3uYQHOXuW6nGe/LK+raypSsSXJ17KlDhabmA4FM5Ws9ptjr2iyKG0Dcs8pvPfdDm9jYsIcXatPvdr5T+uDHqVbN+1OS+J1axcyUb0xn5EZ24WHBlhJkrMrtaMYs/HYZG6R5h4VgNWwzJxrDFsEkaL4dWngz1aC+8uFOKF47qs21zfPLfDsmmdIpMc2tdd6vcBFXofi8MN0rT4vNPGv2vXGPuHXwRhIRZ+MtVxEct5uwINU+lj0XmUm6njYgfoyve3CSKK7Txuat2qxU9L+eWHhEZzFvAQ21MjzauegHjpPoJPyoSfJZ8X4F9gUK64mqNA7W+ZcHNsB0hhM2uMU6udqQTyBs26+zMldOshPoFSHPEER1viq7igBefazV0Om13muSQF5WfTeAPCJboWvf8gjdmboQ1tAMS2kw5IF7J/Hz3PptRvh81XKAcZTkgxcFlj9quiULB7mwEz26ayQQXm0XW89t5tIqIJzXDPVtyrP5IXtRsmKDUGqPesa61CQzdDtrtRSWYd0hENHD074ac4L8kodneajFW5iWiiuyKgD1x4ELGzaifeOHBpA5PMItJ+pbUa8RQiEG8+eGjJT2TL1BOmJrEduZ14HiHoBhtDrtpwBmP5m2qRiaO2tbc9F/tpceLXedNo2n655D6AgMIcf+Msn+XhKoBd8ruMmamO4QbrBnnQjmc08ZqD0lEgEmpcDSd0Ywmhx3fD1nZkdKjqpRR4HqymcNrTxGPI8vKN5aZPdjbhkZncGyfKrxT",
"SecurityTrailer": {
"AdyenCryptoVersion": 1,
"Hmac": "UYSdo5A3nv2DED7rLuLvDgmDyAY+Bw7N/G3m29+10pw=",
"KeyIdentifier": "adyen-test",
"KeyVersion": 1,
"Nonce": "QcABehfViTcOafBgBq6EMQ=="
}
}`
CODE:
`
import { Client, Config, TerminalLocalAPI } from "@adyen/api-library"
import {
TerminalApiRequest,
MessageHeader,
SaleToPOIRequest,
PaymentTransaction,
PaymentRequest,
AmountsReq,
SaleData,
TransactionIdentification,
MessageCategoryType,
MessageClassType,
MessageType,
SecurityKey,
} from "@adyen/api-library/lib/src/typings/terminal/models"
const id = Math.floor(Math.random() * Math.floor(10000000)).toString()
const getMessageHeader = ({ messageCategory = MessageCategoryType.Payment }: { messageCategory?: MessageCategoryType } = {}): MessageHeader => ({
MessageCategory: messageCategory,
MessageClass: MessageClassType.Service,
MessageType: MessageType.Request,
POIID: '123',
ProtocolVersion: "3.0",
SaleID: id,
ServiceID: id,
})
const timestamp = (): string => new Date().toISOString()
const transactionIdentification: TransactionIdentification = {
TimeStamp: timestamp(),
TransactionID: id,
}
const saleData: SaleData = {
SaleTransactionID: transactionIdentification,
SaleToAcquirerData: {
applicationInfo: {
merchantApplication: {
version: "1",
name: "test",
},
},
metadata: {
someMetaDataKey1: "YOUR_VALUE",
someMetaDataKey2: "YOUR_VALUE",
},
},
}
const amountsReq: AmountsReq = {
Currency: "CAD",
RequestedAmount: 1,
}
const paymentTransaction: PaymentTransaction = {
AmountsReq: amountsReq,
}
const paymentRequest: PaymentRequest = {
PaymentTransaction: paymentTransaction,
SaleData: saleData,
}
const getSaleToPOIRequest = (messageHeader: MessageHeader, request: Partial): SaleToPOIRequest => ({
MessageHeader: messageHeader,
...request,
})
const createTerminalAPIPaymentRequest = (): TerminalApiRequest => {
const messageHeader = getMessageHeader()
const saleToPOIRequest = getSaleToPOIRequest(messageHeader, { PaymentRequest: paymentRequest })
return { SaleToPOIRequest: saleToPOIRequest }
}
const terminalAPIPaymentRequest = createTerminalAPIPaymentRequest()
const securityKey: SecurityKey = {
AdyenCryptoVersion: 1,
KeyIdentifier: "adyen-test",
KeyVersion: 1,
Passphrase: "foodhubadyen",
}
export const createClient = (apiKey = process.env.ADYEN_API_KEY): Client => {
const config: Config = new Config()
config.apiKey = "+5HzctViMSCJMYAc=-wzf2rXM6UC/OdvRbqTVok0piJmjMOOEnKjUVwyQ+Qoo=-i1i73^7nLgd&28e,}.k"
// config. = "FoodHubLimited_Pos-terminals_TEST"
}
const client = createClient()
const terminalLocalAPI = new TerminalLocalAPI(client)
const run = async () => {
try {
await terminalLocalAPI.request(terminalAPIPaymentRequest, securityKey)
} catch (e) {
console.log(e)
}
}
run()
`
The text was updated successfully, but these errors were encountered: