Jump to content

How to format PayPal message in backoffice orders page? (Prestashop 1.6.1.1 + PayPal 3.10.2 Europe)


serdib

Recommended Posts

Hello!

 

When i make any PayPal transaction from orders page in prestashop i got messages in one line (please see screenshot).

 

Refund operation result:REFUNDTRANSACTIONID: 51876667NM744635YFEEREFUNDAMT: 1.56GROSSREFUNDAMT: 46.00NETREFUNDAMT: 44.44CURRENCYCODE: GBPTOTALREFUNDEDAMOUNT: 46.00TIMESTAMP: 2015-10-19T10:23:11ZCORRELATIONID: 2d5659572b776ACK: SuccessVERSION: 106.0BUILD: 18308778REFUNDSTATUS: InstantPENDINGREASON: NonePayPal refund successful!

 

I need to make paypal messages lookes like this (write new parameter as new line)

 

Refund operation result:

REFUNDTRANSACTIONID: 51876667NM744635YFEE

REFUNDAMT: 1.56

GROSSREFUNDAMT: 46.00

NETREFUNDAMT: 44.44

CURRENCYCODE: GBP

TOTALREFUNDEDAMOUNT: 46.00

 

 I think this is some kind of bug. Because in 'paypal.php' i see this section with <br> tag included

public function formatMessage($response, &$message)
{
foreach ($response as $key => $value)
$message .= $key.': '.$value.'<br>';
} 

How can i fix this? Already tried to: replace <br> with <br />, reinstall module, clear cache.

 

Thank you :mellow:

 

P.S. (Prestashop 1.6.1.1 + PayPal 3.10.2 Europe)

post-836203-0-22579700-1445250805_thumb.png

Edited by serdib (see edit history)
Link to comment
Share on other sites

I do not know the exact reason, but my guess is that the message is being sanitized before it is displayed.  You would have to trace through Prestashop's code and see what it is doing. 

 

Did you look at the message in the database and see if those <br> exist in the database?  Perhaps they are removed before they are saved

Link to comment
Share on other sites

this means that either the paypal module or the prestashop core has 'cleansed' this message before adding it to the database. 

 

This is the function from the Paypal module that is actually storing it in the database.  You can see that the module uses the php strip_tags function to cleanse the message, but does use '<br>' as the second parameter, which means to ignore cleansing it.  So either this is defective, or something in Prestashop core is removing them.

 

You can prove this theory by commenting out the strip_tags line from the addNewPrivateMessage function and perform a test to see what happens.  If it works, then you know the strip_tags function is defective.  If it does not work, then you will need to dive deeper into the PS core code to see what is happening.

    public function _addNewPrivateMessage($id_order, $message)
    {
        if (!(bool)$id_order)
            return false;

        $new_message = new Message();
        $message = strip_tags($message, '<br>');

        if (!Validate::isCleanHtml($message))
            $message = $this->l('Payment message is not valid, please check your module.');

        $new_message->message = $message;
        $new_message->id_order = (int)$id_order;
        $new_message->private = 1;

        return $new_message->add();
    }
Link to comment
Share on other sites

You can prove this theory by commenting out the strip_tags line from the addNewPrivateMessage function and perform a test to see what happens.  If it works, then you know the strip_tags function is defective.  If it does not work, then you will need to dive deeper into the PS core code to see what is happening.

 

Thanks for your reply!

 

I tried to comment and delete this line

$message = strip_tags($message, '<br>');

but it is still the same. In database too. Even tried in three different versions of Prestashop.  :(

 

Updated: tried with Prestashop 1.6.1.2rc4 — same issue.

 

 

VQugkFv.png

Edited by serdib (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...