globalpayments / globalpayments-3ds-js

Helper library for leveraging 3DSecure 2 for Strong Customer Authentication (SCA)
https://www.npmjs.com/package/globalpayments-3ds
GNU General Public License v2.0
5 stars 10 forks source link

Unexpected End of JSON Input #13

Open bpowerie opened 4 years ago

bpowerie commented 4 years ago

Hi guys,

I hope you don't mind me asking a question here. I have set up a very simple system using all examples and looking at the REST API issue to try and get this working. but I'm having no joy.

At its simplest let's say I have 2 PHP files, one which is my index and the other is my check3DsVersion

using the example code if I fire this from the Try/Catch block I keep getting the error

const versionCheckData = await checkVersion('/3ds2/check3dsVersion', { methodNotificationUrl: 'http://localhost/3ds2/methodNotification', card: { number: document.getElementById('card-number').value, }, });

I am then going into the other PHP file and simply returning a hardcoded JSON object {"enrolled":true,"serverTransactionId":"af65c369-59b9-4f8d-b2f6-7d7d5f5c69d5","methodUrl":"https://www.acsurl.com/method","methodData":"ewogICJ0aHJlZURTU2VydmVyVHJhbnNJRCIgOiAiNmRhN2VjYWItNjY2ZC00YTNiLWI5NTItY2MxZDU4MzA4NWI2IiwKICAidGhyZWVEU01ldGhvZE5vdGlmaWNhdGlvblVSTCIgOiAiaHR0cDovL2xvY2FsaG9zdDo2MDUxNy9UaHJlZURTZWN1cmUyL01ldGhvZFVybFJlc3BvbnNlIgp9"}

The Catch block is catching the error:

(2) [{…}, {…}] 0: {code: "Error", message: "Error: see reasons property"} 1: {code: "SyntaxError", message: "Unexpected end of JSON input"} length: 2

I am sending a valid JSON object (via JSLint) but I can't seem to get past this.

Any thoughts?

Thanks