Support » Plugin: Secure Trading Gateway for WooCommerce » Plugin no longer working – Cannot split date correctly, Error 30000

  • Resolved Andi Lee Davis


    Hi there,

    The plugin for woocommerce fails as the expiryyear field is undefined and we get an Error 30000

    This is a JS API post error.

    ** NOTE I have masked out my credit card number, site ref for security below.

    I think the plugin is not correctly picking up and splitting the field by the forward slash /.

    there is one field for the card expiry date which in our case read 10/2021

    expirymonth: “10/2021” = should be 10
    expiryyear: “20undefined” = should be 2021

    JSON Response Error Details.

    “requestreference”: “W5-41a73wp5”,
    “version”: “1.00”,
    “response”: [
    “errorcode”: “30000”,
    “requesttypedescription”: “ERROR”,
    “transactionstartedtimestamp”: “2019-01-29 14:26:04”,
    “errormessage”: “Invalid field”,
    “errordata”: [
    “secrand”: “eEvgM64zY2hIm4z”

    Posted data:

    {version: “1.00”,…}
    request: [{requestid: “J-2h91imf7”, sitereference: “siteref”, pan: “xxxx xxxx xxxx xxxx”,…}]
    0: {requestid: “J-2h91imf7”, sitereference: “siteref”, pan: “xxxx xxxx xxxx xxxx”,…}
    expirymonth: “10/2021”
    expiryyear: “20undefined”
    pan: “xxxx xxxx xxxx xxxx”
    requestid: “J-2h91imf7”
    requesttypedescription: “CACHETOKENISE”
    securitycode: “XXX”
    sitereference: “siteref”
    version: “1.00”
    versioninfo: “STJS::N/A::1.0.9::N/A”



    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Josh Bedford


    Hi Andi,

    Apologies for the error you’re facing here.

    This has been fixed recently but is yet to be pushed up to the repo. 2.1.0 will be deployed later this week along with some other fixes, so stay tuned – we’re working as quick as we can on this!


    Your error is here:

    assets / front-end /js /main.js (main.min.js)

    Line 85:

    $('#' + + '-cc-year').val( "20" + date_details[1] );

    * You do not need to prefix the 20
    * the 20 + string of date_details[1] which is probably an integer equates to undefined.


    remove the spaces around the / and make sure it is a string

    var date_details = $(this).val().toString().split('/');

    Check the array length is > 1 to prevent undefined error on the second part of the array trying to populate the hidden page fields.

    if(date_details.length > 1) {

    remove the 20 and trim any white space so it reads…

    $('#' + + '-cc-year').val( date_details[1].trim() );

    This is the whole fix in place.

    $(document).on('change, keyup', '#' + + '-card-expiry', function () {
    		if ($(this).val().indexOf('/')) {
    			///var date_details = $(this).val().split(' / ');
    			var date_details = $(this).val().toString().split('/');
    			if(date_details.length > 1) {				
    				/// 29.01.2019 - Fixed
    				$('#' + + '-cc-month').val( date_details[0].trim() );
    				///$('#' + + '-cc-year').val( "20" + date_details[1] );
    				$('#' + + '-cc-year').val( date_details[1].trim() );

    Now this all works and checks out but the return post never updates the WC checkout so you are stuck on the same page.



    On a “side-note”, hoping that the developers of this plugin read this:

    This plugin has caused our company significant disruption since we first encountered problems last year, nearly four months ago and probably way before that.

    I ask you, the developers, to please test this plugin in the next release robustly. On mobile, desktop, and with other payment service providers enabled too, such as paypal and stripe.

    We disabled the plugin, and no longer use it, which then means securetrading are not making as much money from us.

    We’ll use it if it works, which currently, it does not.

    ok also in this file…

    classes / class-st-payment-gateway.php

    in three instance around lines 531, 631, 901

    $expiry_date[1] = '20' . $expiry_date[1];
    the issue with this is that it expects the date input is going to be just the last 2 digits. ie 2021, 21.

    my card data is saved in the rowser and returns the full date wgereas the paynent gateway mask is 2 digits or yy, however this gets overwritten and sends yyyy format.

    so after i figured out that part of the issue is some lines of code prefixing 20 as in the centuary before the array part as in the class is expecting… i added this function.

    public function prefix_year($date){
    	    $pattern ='/^([0-9]{2})$/';
    	    $date = preg_replace($pattern, '20$1', $date);
    	    return $date;

    thus function will check the length of a value and return the prefix if it is only 2 characters long, or the four digit date.

    so all you have to do with those three lines is pass it to the filter method above.

    ///$expiry_date[1] = '20' . $expiry_date[1];
    		$expiry_date[1] = $this->prefix_year($expiry_date[1]);

    dont forget the js solution as well…then it all works… or should do.



Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Plugin no longer working – Cannot split date correctly, Error 30000’ is closed to new replies.