public function ensureCorrectOrderNumber($orderNumber)
    {
        if (strlen($orderNumber) > self::ORDER_NUMBER_MAXIMUM_LENGHT) {
            throw new LogicException('Payment number can\'t have more than 12 characters');
        }

        // add 0 to the left in case length of the order number is less than 4
        $orderNumber = str_pad($orderNumber, self::ORDER_NUMBER_MINIMUM_LENGTH,
            '0', STR_PAD_LEFT);

        if (!preg_match('/^[0-9]{4}[a-z0-9]{0,12}$/i', $orderNumber)) {
            throw new LogicException('The payment gateway doesn\'t allow order numbers with this format.');
        }

        return $orderNumber;
    }
public function ensureCorrectOrderNumber($orderNumber)
    {
        if (strlen($orderNumber) > self::ORDER_NUMBER_MAXIMUM_LENGHT) {
            throw new LogicException('Payment number can\'t have more than 12 characters');
        }

        // add 0 to the left in case length of the order number is less than 4
        $orderNumber = str_pad($orderNumber, self::ORDER_NUMBER_MINIMUM_LENGTH,
            '0', STR_PAD_LEFT);

        if (!preg_match('/^[0-9]{4}[a-z0-9]{0,12}$/i', $orderNumber)) {
            throw new LogicException('The payment gateway doesn\'t allow order numbers with this format.');
        }

        return $orderNumber;
    }
public function ensureCorrectOrderNumber ( $ orderNumber ) { if ( strlen ( $ orderNumber ) > self :: ORDER_NUMBER_MAXIMUM_LENGHT ) { throw new LogicException ( 'Payment number can\'t have more than 12 characters' ) ; } // add 0 to the left in case length of the order number is less than 4 $ orderNumber = str_pad ( $ orderNumber , self :: ORDER_NUMBER_MINIMUM_LENGTH , '0' , STR_PAD_LEFT ) ; if ( ! preg_match ( '/^[0-9]{4}[a-z0-9]{0,12}$/i' , $ orderNumber ) ) { throw new LogicException ( 'The payment gateway doesn\'t allow order numbers with this format.' ) ; } return $ orderNumber ; }
Validate the order number passed to the bank. it needs to pass the
following test

- Must be between 4 and 12 characters
- We complete with 0 to the left in case length or the number is lower
than 4 in order to make the integration easier
- Four first characters must be digits
- Following eight can be digits or characters which ASCII numbers are:
- between 65 and 90 ( A - Z)
- between 97 and 122 ( a - z )

If the test pass, orderNumber will be returned. if not, a Exception will be thrown

@param string $orderNumber

@return string
Validate the order number passed to the bank . it needs to pass the following test