-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot read property 'CreditSale' of undefined #19
Comments
Thanks for the report, @arvinkx. We'll take a look on our end to see if we can reproduce this. Do you have a code snippet that calls into the library that we could review? |
Here is where I am calling it, just FYI the documentation needs some work, there is no mention as to what
|
@arvinkx Apologies for the delay. We definitely agree on the documentation, and we are actively working on improving it across the board. You can use this section of our documentation which applies to this SDK in its current form: https://developer.heartlandpaymentsystems.com/Documentation/v2/introduction. The I wrote this quick sample script to simulate your code: const heartland = require('heartland-nodejs');
const config = {
secretApiKey: 'skapi_cert_MTyMAQBiHVEAewvIzXVFcmUd2UcyBge_eCpaASUp0A',
versionNumber: '0000',
developerId: '000000'
};
const url = 'https://cert.api2.heartlandportico.com/hps.exchange.posgateway/posgatewayservice.asmx';
function chargeCreditCardToken(amount, token, purchaseID, cb) {
console.log(token);
new heartland.HpsCreditService(config, url).chargeWithToken(
amount,
'usd',
token,
null,
false,
purchaseID,
(err, response) => {
if (err) {
console.log('error', err);
return;
}
console.log('response', response);
}
);
}
// here down just grabs a single-use token and executes the above function
const http = require('https');
const options = {
headers: {
"Content-Type": "application/json",
},
hostname: 'cert.api2.heartlandportico.com',
port: 443,
path: '/Hps.Exchange.PosGateway.Hpf.v1/api/token?api_key=pkapi_cert_jKc1FtuyAydZhZfbB3',
method: 'POST',
};
const req = {
token_type: 'supt',
object: 'token',
card: {
number: '4242424242424242',
exp_month: '12',
exp_year: '2025',
cvc: '123'
}
};
let token = '';
const request = http.request(options, (res) => {
res.on('data', (d) => token += d);
res.on('end', () => {
const response = JSON.parse(token);
if (response.token_value) {
chargeCreditCardToken(1.00, response.token_value, '123456', () => {});
}
});
});
request.write(JSON.stringify(req));
request.end(); Sadly, I'm not able to reproduce the same issue with reading the
Are you able to send more details about the account and when you're seeing these errors to [email protected] and CC my team [email protected]? We can dive more into your account to see what may be happening. |
Hi-
I am getting this error intermittently, works fine most of the time. It seems the response is missing the body and the code doesn't handle that well. The charge goes through but the callback throws an error when it returns.
This is the code it is referencing:
Any ideas?
The text was updated successfully, but these errors were encountered: