Access denied to add Payment Method (all role) on Drupal 10 (new)

Created on 18 June 2024, 3 months ago
Updated 19 June 2024, 3 months ago

Hello,

I re-open this issue https://www.drupal.org/project/commerce/issues/3412625 💬 Access denied to add Payment Method (all role) on Drupal 10 Fixed , because I get the same problem: access denied for the administrator (account 1) with the right permissions (all options are checked). Have you found a solution for this ?

Thanks.

💬 Support request
Status

Closed: won't fix

Version

2.39

Component

Payment

Created by

🇫🇷France kumkum29

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kumkum29
  • Status changed to Closed: won't fix 3 months ago
  • 🇮🇱Israel jsacksick

    Access denied is returned in case there are no payment options. You need to configure a payment gateway that supports tokenization... For example Commerce Stripe, Commerce Braintree, Commerce Authorize.net...

    See the code below:

    if (!$payment_options) {
          $payment_options = $this->buildPaymentOptions($form_state);
          if (!$payment_options) {
            throw new AccessDeniedHttpException();
          }
          $form_state->set('payment_options', $payment_options);
        }

    ANd then buildPaymentOptions() has that:

        $payment_gateway_storage = $this->entityTypeManager->getStorage('commerce_payment_gateway');
        $payment_gateways = $payment_gateway_storage->loadByProperties(['status' => TRUE]);
        $payment_gateways = array_filter($payment_gateways, function ($payment_gateway) {
          return $payment_gateway->getPlugin() instanceof SupportsCreatingPaymentMethodsInterface;
        });
    
Production build 0.71.5 2024