The paypal Express checkout option at cart takes to "There was an error bringing you to PayPal." error page without actually showing any error in dblog or php log.

Below code does it. I suggest we log some exception/message just before returning this message.

$paypal_response = $payment_gateway_plugin->setExpressCheckout($payment, $extra);

    if (!empty($paypal_response['TOKEN'])) {
      $order = $payment->getOrder();
      $order->setData('paypal_express_checkout', [
        'flow' => 'ec',
        'token' => $paypal_response['TOKEN'],
        'payerid' => FALSE,
        'capture' => $extra['capture'],
      ]);
      $order->save();
    }
    else {
      return [
        '#type' => 'inline_template',
        '#template' => "<span>{{ 'There was an error bringing you to PayPal.'|t }}</span>",
      ];
    }

Comments

sumanthkumarc created an issue.

sumanthkumarc’s picture

@matt should we log an exception here instead of just showing an error using inline template? In my case currency was not supported by gateway and that error is hidden from user and was just a normal message shown. It took me some time to find the error.