Support » Plugin: WooCommerce mPAY24 Gateway » SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON dat

  • Resolved volkan64


    When I try to pay in test mode everything works fine.
    But when I deactivate the test mode and try to submit a real payment I get this error:
    SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data

    How can I fix this?

    WP: 4.3.4
    Plugin: WooCommerce mPAY24 Gateway 1.5.1

    Thank you in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey Volkan,

    I was wondering if you could solve that problem. Since we have that problem aswell I’m interessted how to fix it.

    Hope to hear from you




    Dear all,

    I found out the problem and solved it (maybe many people also did it as well).

    It all comes from the fact that the “URLType” elements in the SOAP structures are not well formatted.

    In my particular case, two parameters in the SOAP call to the function “” contained values that did not pass the URLType because they were escaped (with the function “esc_url()”).
    Escaping these two URLs was not needed in this case and I just set the URLs without escaping.

    The changes were made in the file /wp-content/plugins/woocommerce-mpay24-gateway/gateway-mpay24.php , method WC_Gateway_MPAY24->process_payment()

    $shop->setErrorUrl( $order->get_cancel_order_url_raw() );
    $shop->setCancelUrl( $order->get_cancel_order_url_raw() );

    … instead of…

    $shop->setErrorUrl( $order->get_cancel_order_url() );
    $shop->setCancelUrl( $order->get_cancel_order_url() );

    This fixed my problem, but every parameter of the URLType for the MPAY24’s SOAP API is used, should be non-escaped.

    All the best


    • This reply was modified 6 years ago by jbugella.
    Plugin Author datenwerk


    Hi jbugella,
    thank you very much for your bugfix. I put it in the plugin immediately and send a notice to mPAY24 support, that they should check the URLType. They will consider changes with the next schema update (MDXI.xsd).
    The other URLs (success and confirm) didn’t have an escaping, so they stay unchanged.

    Kind regards

    Hi Datenwerk,

    No problem, I am happy to help others to solve it as well (because it is a very common problem since mpay24 updated its URLType format restriction).

    Just take into account that there are two checkings: one in the client (where the plugin is running) and one in mpay24 side (the internal API).

    Also, as the change is about checking the URLType format, the change would apply to all any the parameters of the type URLType of every mpay24’s API function.

    To end, this problem could pass unnoticed due to the fact that the result of *get_cancel_order_url_raw()* and *get_cancel_order_url()* are the same for most of simple URLs (considering simple as URL without strange characters).

    Best regards.

    Joaquin M. Bugella

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON dat’ is closed to new replies.