1

I try to get PayPal Express running but have quite some difficulties. I use the default templates for testing and can get through the whole checkout and payment process, but then PayPal closes and in the console I see the following

http.js:114 PaypalUncaught Error: Request to post http://xxx.local/index.php?p=actions/commerce/payments/complete-payment&commerceTransactionHash=xxx&token=xxx&PayerID=xxx failed with 400 error. 
Correlation id: unknown   
{"error": "Es ist nicht möglich, Ihre Dateneingabe zu prüfen."}

The error message can be translated to: It's not possible to check your data input.

In my Craft config, I changed the token name, as described here: https://github.com/craftcms/commerce-paypal

Any ideas what the reason for this could be?

2

The Craft support helped me to figure this out. The problem was, that the CSRF wasn't properly disabled.

So in my config/general.php I have the following:

if ( !function_exists('isApiRequest') ) {
    function isApiRequest ()
    {
        $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
        $query = parse_url($_SERVER['REQUEST_URI'], PHP_URL_QUERY);

        $actions = [
            'actions/charge/webhook/callback',
            'actions/commerce/payments/complete-payment',

        ];

        foreach ($actions as $action) {
            if ( strpos($path, $action) || strpos($query, $action) ) {
                return true;
            }
        }

        return false;
    }
}

return [

'*' => [

    'enableCsrfProtection' => !isApiRequest(),
    ...
  • Thank you! Seems 'complete-payment' got renamed from 'completePayment' which is why the code from another post didn't work for me. – portnull Apr 25 at 10:56

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.