Skip to content
Advertisement

Stripe Unexpected token < in JSON at position 0

I am getting this error, it points to client.js line 21. It is the second .then of the fetch(create.php).

The first response returns 200. So, not sure how to fix it. The whole code so far is as extracted from demo instructions. https://stripe.com/docs/payments/integration-builder

See browser console info:

JavaScript

Advertisement

Answer

It turned out the error was on the require './stripe-php/init.php'; on the create.php file.

As I am developing it with WordPress I had it as require plugin_dir_url(__FILE__) . 'stripe-php/init.php';.

Summary:

Make sure the path to require stripe-php/init.php is correct, as below:

JavaScript

Thanks to @jason who recommended checking the Network tab.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement