0

i am actually not sure if this should be a wordpress question/issue or should be asked elsewhere (but one thing might cause the other..) in any event, trying to write a custom rabobank omnikassa integration , i only ever get a "Invalid or missing signature" result. according to the (not very helpful) omnikassa support answer this is down to

  • the refresh token is not complete
  • a expired token
  • use of the sandbox token or vice versa

which isn't really helpful at all as

  • a) of course i have used the whole refresh token
  • b) token expired is not the case (refresh toke expires in 2099 - as its a sandbox token)
  • c) of course i am using sandbox token etc for sandbox testing

the code - as it stands - looks like this (of course using variables for the order parameters), so if there's anyone at all that can come up with an idea why this does not work / what i'm doing wrong or has any ideas or hints as to what else i should be trying , i would be more than grateful.

        /*
            [url - sandbox]
        */
        $apiUrl = 'https://betalen.rabobank.nl/omnikassa-api-sandbox';

        /*
            Sandbox RefreshToken and Signing key
            (obviuosly the whole token/keys are being used here)
        */
        $RefreshToken = 'abc...xyz';
        $SigningKey = 'ABC...XYZ';


        /*
            get token
        */
        $response = wp_remote_get( $apiUrl.'/gatekeeper/refresh', array(
            'headers'  => array( 
                'Authorization' => 'Bearer ' . $RefreshToken ,
            ),
        ));
        $body = wp_remote_retrieve_body( $response );
        $token_data = json_decode( $body, true);


        /*
        token_data returns something like
            [token] => eyJr.......................EnxK
            [validUntil] => 2018-04-07T18:03:23.692+0000
            [durationInMillis] => 3600000
        */


        /*
            [set orderData]
        */
        $omnikassaOrder=array();
        $omnikassaOrder['timestamp'] = 2018-04-07T17:03:20+00:00;
        $omnikassaOrder['merchantOrderId'] = 101;
        $omnikassaOrder['amount'] = array();
        $omnikassaOrder['amount']['currency'] = 'EUR';
        $omnikassaOrder['amount']['amount'] = 797;
        $omnikassaOrder['language'] = 'NL';
        $omnikassaOrder['description'] = 'Your order at test' ;
        $omnikassaOrder['merchantReturnURL'] = 'http://www.test.com/orders/?id=2666ea175d0a223114db596c86';


        /*
            string to hash 
        */
        $toHash = array();
        $toHash[] = $omnikassaOrder['timestamp'];
        $toHash[] = $omnikassaOrder['merchantOrderId'];
        $toHash[] = $omnikassaOrder['amount']['currency'];
        $toHash[] = $omnikassaOrder['amount']['amount'] ;
        $toHash[] = $omnikassaOrder['language'];
        $toHash[] = $omnikassaOrder['description'];
        $toHash[] = $omnikassaOrder['merchantReturnURL'];

        /*
            add signature
        */
        $omnikassaOrder['signature'] = hash_hmac('sha512', json_encode(implode(',',$toHash)), base64_decode($SigningKey));



        /*
            post to omnikassa 
        */
        $response = wp_remote_post( $apiUrl.'/order/server/api/order', array(
            'headers'  => array( 
                'Content-Type' => 'application/json' ,
                'Authorization' => 'Bearer ' . $token_data['token'] ,
            ),
            'body' => json_encode($omnikassaOrder),
        ));
        $body = wp_remote_retrieve_body( $response );
        $redirect_data = json_decode( $body, true );            


        /*
        redirect_data  returns always
        Array
        (
            [errorCode] => 5001
            [consumerMessage] => Invalid or missing signature
        )
        */
0

turns out (in case it's helpful to someone else) that

$omnikassaOrder['signature'] = hash_hmac('sha512', json_encode(implode(',',$toHash)), base64_decode($SigningKey));

should have been simply the following (without json_encode )

$omnikassaOrder['signature'] = hash_hmac('sha512', implode(',',$toHash), base64_decode($SigningKey));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.