Jump to content

1.6.x Payment Module - Failing Validation

Recommended Posts

Im trying to create a payment module but stuck at the validation step

after visiting a third parties site to process payment, it returns to my validation script but always fails

the posted values from the 3rd party site are (order_number, transaction_status, transaction_value, date_time, authorisation_code)

I try to recall the cart using

$cart = new Cart((int)Tools::getValue('order_number'));

then check if valid

if ($cart->id_customer == 0) {
    $this->returnError('Invalid Cart', $postValues); // send email on fail of posted values, then kill script

I get an email informing of a failed validation

I suspect im missing something super simple, but cant see it (ive included my file for ref)


class payacardValidationModuleFrontController extends ModuleFrontController {

    public function postProcess() {

        // kill process if module is not active
        if ($this->module->active == false) {

        foreach ($_REQUEST as $key => $value) {
            $postValues .= "{$key}={$value}";

        // restore cart context
        $cart = new Cart(Tools::getValue('order_number'));

        if ($cart->id_customer == 0) {
  //    if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
            $this->returnError('Invalid Cart', $postValues);

        // set datas
        $transaction_status = Tools::getValue('transaction_status');
        $transaction_value_pence = Tools::getValue('transaction_value_pence');
        $date_time = Tools::getValue('date_time');
        $authorisation_code = Tools::getValue('authorisation_code');
        $paya_signature = Tools::getValue('paya_signature');
        // check payacard signature
        $tokenPreHash = $cart->id.':'.((float)$cart->getOrderTotal(true, Cart::BOTH)*100).':'.Configuration::get('PAYACARD_ID').':'.Configuration::get('PAYACARD_SIG');
        $tokenHash = hash('sha512', $tokenPreHash);
        if ($paya_siganture != $tokenHash)
            $this->returnError('Invalid Token',$postValues);

        // validate order
        $currency = new Currency((int)$cart->id_cuurency);
        $total_paid = $transaction_value_pence/100;
        $extra_vars = array(
            'transaction_id' => $authorisation_code,

        if ($transaction_status == "A" && $transaction_status != "D") {
            Configuration::get('PS_OS_PAYMENT'), $total_paid,
            $this->module->displayName, NULL, $extra_vars,
            (int)$currency->id, false, $customer->secure_key);
        } else {
            $this->returnError('Payment Declined',$postValues);


    public function returnError($subject, $message) {
            (int)(Configuration::get('PS_LANG_DEFAULT')), // defaut language id
            'contact', // email template file to be use
            'Payacard - Failed Validation - '.$subject, // email subject
                '{email}' => Configuration::get('PS_SHOP_EMAIL'), // sender email address
                '{message}' => $message, // email content
            Configuration::get('PS_SHOP_EMAIL'), // receiver email address 
            NULL, //receiver name
            NULL, //from email address
            NULL  //from name


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More