Erro ao processar PaymentData - Cannot read property 'output_ResponseCode' of undefined
gmahota opened this issue · comments
Estou com o seguinte erro ao processar o paymentData:
TypeError: Cannot read property 'output_ResponseCode' of undefined
at Service.buildResponse (service.cjs?67c7:302)
at eval (service.cjs?67c7:282)
import { Client } from '@paymentsds/mpesa'
const client = new Client({
apiKey: process.env.Mpesa_apiKey, // API Key
publicKey: process.env.Mpesa_publicKey,
serviceProviderCode: "171717", // input_ServiceProviderCode
origin: 'localhost:8080',
host: 'localhost:8080',
userAgent:'MPesa',
verifySSL: false,
debugging: true,
});
const set_paymentData = async (from,reference,transaction,amount)=>{
const paymentData = {
from: from, // input_CustomerMSISDN
reference: reference + Math.floor(Math.random()*100), // input_ThirdPartyReference
transaction: transaction, // input_TransactionReference
amount: amount // input_Amount
};
client.receive(paymentData).then(r => {
console.log(r)
// Handle success scenario
}).catch(e =>{
console.log(e)
// Handle success scenario
});
};
export{
set_paymentData
}
Obrigado pelo report @gmahota
@edsonmichaque peco para verificar o ultimo commit 2ba477d
Fiz o test e tive o mesmo problema.
Por algum motivo tenho essa resposta em producao... contudo... tudo clean em dev:
{ response: { status: 200, code: undefined, desc: undefined }, conversation: undefined, transaction: undefined, reference: undefined }
Muito obrigado @eltonlaice e @gmahota, estou a fazer as devidas verificações
@gmahota algumas alterações. Podes fazer o upgrade do pacote e testar novamente?
Acabo de testar com o mesmo input estou com este erro:
Cannot read property 'status' of undefined
at Service.buildResponse (service.cjs?67c7:314)
at eval (service.cjs?67c7:282)
@gmahota pode remover o host e origin?
Desculpa, distraí-me com o novo problema que tiveste teu problema
Sim. funcionou! Obrigado!